<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Wendy Su on Medium]]></title>
        <description><![CDATA[Stories by Wendy Su on Medium]]></description>
        <link>https://medium.com/@w696905?source=rss-673226873d98------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*79zOwaIWlnn39blX.jpg</url>
            <title>Stories by Wendy Su on Medium</title>
            <link>https://medium.com/@w696905?source=rss-673226873d98------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:34:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@w696905/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Use Raspberry Pi 5 for web hosting]]></title>
            <link>https://medium.com/@w696905/use-raspberry-pi-5-for-web-hosting-83f19f976b4c?source=rss-673226873d98------2</link>
            <guid isPermaLink="false">https://medium.com/p/83f19f976b4c</guid>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[raspberry]]></category>
            <dc:creator><![CDATA[Wendy Su]]></dc:creator>
            <pubDate>Wed, 18 Dec 2024 14:03:45 GMT</pubDate>
            <atom:updated>2024-12-27T14:32:15.097Z</atom:updated>
            <content:encoded><![CDATA[<p>The web pages I am going to setup will contain two parts, one is the home page and one is my Raspberry Pi status page, including system info., CPU usage and memory usage. And then tunneled the Raspberry Pi to Cloudflare for the public internet access.</p><p>If I turn on my Raspberry Pi, then you can access my web on <a href="https://raspi.cwstechlife.com/">https://raspi.cwstechlife.com/</a></p><p>(The Raspberry Pi project is actually inspired by <a href="https://www.youtube.com/watch?v=Vp4glSVPT8o&amp;t=492s&amp;pp=ygUYcmFzcGJlcnJ5IHBpIHByb2dyYW1taW5n">https://www.youtube.com/watch?v=Vp4glSVPT8o&amp;t=492s&amp;pp=ygUYcmFzcGJlcnJ5IHBpIHByb2dyYW1taW5n</a> and he also provided the code on <a href="https://www.picourse.dev/ssh-key">https://www.picourse.dev/ssh-key</a>.)</p><h3>Steps</h3><ol><li>Setup the Raspberry Pi 5 first. If you haven’t done this step, there’s a story I wrote before: <a href="https://medium.com/@w696905/lets-get-started-with-the-raspberry-pi-5-9f9a8e9d35eb">Let’s get started with the Raspberry Pi 5</a>.</li><li>SSH to Raspberry Pi on my laptop.</li><li>Download nvm: can refer to <a href="https://github.com/nvm-sh/nvm">https://github.com/nvm-sh/nvm</a> and find the latest version.</li><li>Run the command: curl -o- <a href="https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh">https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh</a> | bash</li><li>Restart the terminal.</li><li>Check if nvm install sucessfully: nvm --version</li><li>Install latest node.js: nvm install node , and check the node version: node -v</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2pYW56rs_gxEifEONrCNag.png" /></figure><p>8. Create Next.js project: npx create-next-app@latest , and I use the default settings as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lvx4RoxdksO5mMX8brC_Dg.png" /></figure><p>9. If you want to browse the default web page: cdinto the project: my-app and run npm run dev</p><p>10. Type raspberrypi.local:3000into the browser, then you can see the page as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t1Cweyqxk3YIvo8Z0m3pTg.png" /></figure><p>11. Edit the file on VS code on my own laptop: use remote ssh from VS code.</p><p><a href="https://code.visualstudio.com/docs/remote/ssh">Developing on Remote Machines using SSH and Visual Studio Code</a></p><p>If you successfully connect through ssh on VS code, it should show SSH: raspberrpi at the left buttom corner.</p><p>12. Use shadcn/ui card for the Raspberry Pi status page: npx shadcn@latest init (The shadcn updated their CLI tool name few months ago from shadcn-ui to shadcn )</p><p>13. Add card and progress :npx shadcn@latest add card progress</p><p>14. The page.tsx under app should be the web home page and the page.tsx under stats is for the Raspberry Pi status.</p><p>The file structure should look like below. I uploaded the code on my github: <a href="https://github.com/wendy696905/my-app">https://github.com/wendy696905/my-app</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*n9vRxViqrMMnqJDg1unuWA.png" /></figure><h3>Check Results on localhost</h3><ul><li>Pages browsed from my laptop showing as below.</li><li>Pages can also browsed from my phone. (To browse the page from localhost, you need to connect your phone to the same network as Raspberry Pi!!)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4PphSAZKmYsxx2BkHMqLyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*poKXvB0T7q9Na64Xhj0uFQ.png" /></figure><h3>Before Tunneling the Public Access</h3><p>It is annoying that I have to run npm run dev every time to make the project works. pm2 can solve this problem.</p><ul><li>Install pm2 globally: npm install -g pm2</li><li>Navigate to the project directory and start the application: pm2 start npm -- name {project name} -- run dev</li><li>To make the app start automatically on system boot: pm2 startup and the terminal will generate a command line to ask you copy/paste the following command to setup the Startup script in PATH. Follow the instruction.</li><li>And remember to run pm2 save to save the process list.</li></ul><h3>Tunnel Raspberry Pi For Public Access</h3><ul><li>Create a domain and find a fast and secured way to host the app through internet. Ex. Cloudflare, Amazon CloudFront, Imperva, etc. I use Cloudflare here.</li><li>Go to Zero Trust | Networks | Tunnels . If it’s the first time setting up, you have to setup a team name, plan and payment method. I chose the $0 plan here.</li><li>Under Networks -&gt; Tunnels -&gt; Add a tunnel -&gt; Select cloudfared</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7blhKGyiP2cZoLc6rZb4rg.png" /></figure><ul><li>Run the command showing at the bottom of the page above. It should setup the Cloudflare service on the host.</li><li>Setup the subdomain and the localhost port.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XhAQ-Xhs2LM5moVs8sU2Ng.png" /></figure><p>And that’s it! Now you can access your webpage hosted on Raspberry Pi through public internet!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83f19f976b4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s get started with the Raspberry Pi 5]]></title>
            <link>https://medium.com/@w696905/lets-get-started-with-the-raspberry-pi-5-9f9a8e9d35eb?source=rss-673226873d98------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f9a8e9d35eb</guid>
            <category><![CDATA[raspberry-pi-5]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Wendy Su]]></dc:creator>
            <pubDate>Mon, 18 Nov 2024 11:48:49 GMT</pubDate>
            <atom:updated>2024-11-18T11:51:04.559Z</atom:updated>
            <content:encoded><![CDATA[<p>I just bought a Raspberry Pi 5, and it needs some set up before it can be functioned. I also want to be able to SSH into the Raspberry Pi 5 from my Windows laptop directly, instead of setting up another full set of screen/mouse/keyboard. So, let’s get started!</p><h4><strong>Install the Raspberry Pi OS</strong></h4><p>First step is to install the Raspberry Pi OS since there’s no pre-written OS on the board.</p><ol><li>Prepare a microSD card to write the OS in.</li><li>Download and install Raspberry Pi Imager to a Windows/macOS/Ubuntu computer from <a href="https://www.raspberrypi.com/software/">https://www.raspberrypi.com/software/</a></li><li>Insert the SD card reader with the microSD card into the computer where the Raspberry Pi Imager was installed.</li><li>Open the Raspberry Pi Imager and should like the below.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*V5FItlrozQ_qtoHT7cnfkw.png" /></figure><p>5. Choose the Raspberry Pi device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yHxOR1M2npwpKRc_WEdXNA.png" /></figure><p>6. Choose the Operating System and I chose Raspberry Pi OS (64-bit).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*hZ0eunzg5lKmgxPYUqd7Pg.png" /></figure><p>7. Choose the where you want to store the OS. (Make sure that is the microSD you want to write in or the original data will be erased!!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*Q4YVAEaDchm3Xn_-ngJfCQ.png" /></figure><p>8. After few minutes, it will pop up a window that you can configure the hostname, WiFi, username/password, time zone, enable the SSH… (which it’s not necessary to set the configuration now. There will be setting windows pop up when you first launch the Raspberry Pi with the micro SD.)</p><p><strong>Set up and test the SSH</strong></p><p>Second, I want to have the remote access the Raspberry Pi from my Windows laptop, so I setup the SSH on Raspberry Pi.</p><ol><li>Make sure that your Raspberry Pi is connected to the network that has the same subnet as where you want to control the device from!!</li><li>You can also turn on the SSH on Raspberry Pi UI: <strong>Prefrences</strong> &gt; <strong>Raspberry Pi Configuration</strong> &gt; <strong>Interfaces</strong> &gt; <strong>Enable SSH</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BZd0b46TWVi_yROXpD6dXQ.png" /></figure><p>3. Few ways to SSH to the Raspberry Pi device on your own PC:</p><ul><li>$ssh &lt;username&gt;@&lt;ip address&gt; , and the ip address can be found when typing in hostname -I in Raspberry Pi terminal.</li><li>$&lt;username&gt;@raspberrypi</li></ul><p>4. First time SSH, there will be a message asking in terminal if you want to establish the fingerprint, and just type yes . After that, it will ask you to type in the Raspberry Pi device password.</p><p>5. Then you can control the Raspberry Pi directly in the terminal on your own PC.</p><p>6. Try the scp function to transfer the .png from Raspberry Pi device to PC: $scp &lt;username&gt;@&lt;ip address&gt;:~&lt;file location&gt; &lt;destination on PC&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H1q9xiQ9Irvv-ioNWkh1Dg.png" /></figure><p><strong>Reference</strong></p><ol><li><a href="https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up/2">https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up/2</a></li><li><a href="https://www.raspberrypi.com/documentation/computers/getting-started.html">https://www.raspberrypi.com/documentation/computers/getting-started.html</a></li><li><a href="https://www.raspberrypi.com/documentation/computers/remote-access.html">https://www.raspberrypi.com/documentation/computers/remote-access.html</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f9a8e9d35eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[上課心得]GT OMSCS 7638: Robotics: AI Techniques]]></title>
            <link>https://medium.com/@w696905/%E4%B8%8A%E8%AA%B2%E5%BF%83%E5%BE%97-gt-omscs-7638-robotics-ai-techniques-06909c66e9f9?source=rss-673226873d98------2</link>
            <guid isPermaLink="false">https://medium.com/p/06909c66e9f9</guid>
            <category><![CDATA[rait]]></category>
            <category><![CDATA[omscs]]></category>
            <dc:creator><![CDATA[Wendy Su]]></dc:creator>
            <pubDate>Sat, 04 May 2024 13:15:53 GMT</pubDate>
            <atom:updated>2024-05-04T13:15:53.071Z</atom:updated>
            <content:encoded><![CDATA[<p>這門課簡稱RAIT，或是AI4R（因為之前的課程全名是Artificial Intelligence for Robotics)，錄影的課程還有整體的課程架構主要是由Sebastian Thrun教授，他領導了Standford University and Google self-driving car 的研究，在課程中他分享了很多建造無人駕駛車的模型還有障礙，課程裡教的Algorithm都有實際被運用在他建造的無人駕駛車上。有興趣的話，他的整堂課可以在<a href="https://www.udacity.com/course/artificial-intelligencefor-robotics--cs373">Udacity</a>上找到。</p><p>這堂課先從Localization開始，教我們要怎麼讓Robot自己找到身處的位置，對人腦來說相對直覺的事，對Robot則是要透過很多機率來計算。假設一條走廊上有三扇綠色的門，Robot有sensor可以感知面前的門是什麼顏色，那要怎麼讓Robot知道自己是在走廊上哪扇綠色的門前面（當然這只是簡單的離散舉例，而且前提是Robot有這走廊的map）。Localization這邊提到的技巧包含Histogram filters, Kalman filters, 還有Particle filters。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*QjzVeFmbGSbCze6CtwSE8w.png" /><figcaption>GT OMSCS 7638: Robotics: AI Techniques Histogram Filters</figcaption></figure><p>接著是Planning，要怎麼讓Robot以最有效率而且安全的方式從起點移動到目的地。假設有段路左轉是一個危險的舉動，要怎麼讓Robot避免做這個動作，並且規劃另一條路徑。或是要怎麼讓Robot知道在轉彎之前要先變換到哪條車道。這裏Planning提到的包含Breadth-first search, Uniform cost search (a kind of Dijkstra), A*, Dynamic programming policy and value iteration。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Im0U9YOyelgVaY2OYxmnVA.png" /><figcaption>GT OMSCS 7638: Robotics: AI Techniques Planning</figcaption></figure><p>Plan了之後就是執行，要怎麼順暢的讓Robot按照剛剛的路徑行走，假設要變換車道，要怎麼不讓Robot overshoot 或是Oscillation，這裡用的就是PID control。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lwB8ErMSleGlNICrW5RhrA.png" /><figcaption>GT OMSCS 7638: Robotics: AI Techniques PID Control</figcaption></figure><p>最後是SLAM (Simultaneous Localization and Mapping)，另外一種定位方式，這堂課提到的是GraphSLAM，Robot已知的只有起點位置，接著靠可能有noise的感應Landmark相對位置或是移動來建構地圖。利用線性方程式，但不是用Substitution來解，因為Robot在偵測和移動會產生很多的誤差，如果用Substitution會讓誤差更大，如下圖。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*Muod3taYsCHCsH2en7-RfA.png" /><figcaption>GT OMSCS 7638: Robotics: AI Techniques Tutorial 16: Graph SLAM</figcaption></figure><p>所以這裡用的是Method of least squares，以助教舉的例子來說，Substitution得到的x, y 再代回去方程式，得到的violation magnitude是2，但Least squares得到的violation magnitude只有0.8。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*Qw4ZOkpTdRx66_LDNHsT4w.png" /><figcaption>GT OMSCS 7638: Robotics: AI Techniques Tutorial 16: Graph SLAM</figcaption></figure><p>雖然錄影的課程跟Udacity很類似，最大的不同是助教課還有Project，不得不說Chris Wirgler的助教課非常有趣！而且是以非常淺顯易懂的方式補足錄影課程的gap，這堂課的Project也設計得很認真（而且每個學期都會有點不一樣！）總共五個Project，2024 Spring Semester 第一個Project是運用Kalman filters來定位Asteriods，讓Spaceship跳上回家的路。第二個是利用Particle filters來找到自己在Solar System中運行的位置，並且傳送訊號回到自己的星球。第三個是用PID來控制無人機。第四個是用A*或Value iteration讓機器人按照順序找到在倉庫的箱子，然後搬到指定的地點。最後是在沒有map的叢林中找寶藏！（<a href="https://mediaspace.gatech.edu/media/CS7638%20Robotics%20Artificial%20Intelligence%20Techniques%20(Project%20Introductions)/1_nwfvmgph?fbclid=IwZXh0bgNhZW0CMTAAAR0AHqbKAqe805NMoSAXTNaBDnwGhambE4tydZDW6yh5Ph_kOm6dkPb7c8c_aem_AcSpnEWEM3ZcwxjqjzjGnhziyqCcd75rpzw-G3ahjsyaWPxiEaZz4_9p9pTExY7lrTwjEoihMjgTgzRmwJlzdwv5">助教的Project介紹影片連結</a>）真的非常推薦這堂課！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06909c66e9f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Google Analytics Case Study] How Does a Bike-Share Navigate Speedy Success?]]></title>
            <link>https://medium.com/@w696905/google-analytics-case-study-how-does-a-bike-share-navigate-speedy-success-805683b87738?source=rss-673226873d98------2</link>
            <guid isPermaLink="false">https://medium.com/p/805683b87738</guid>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[google-analytics]]></category>
            <dc:creator><![CDATA[Wendy Su]]></dc:creator>
            <pubDate>Sat, 23 Dec 2023 03:17:55 GMT</pubDate>
            <atom:updated>2023-12-23T03:17:55.070Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Google Analytics Case Study] How Does a Bike-Share Navigate Speedy Success? — Compare Tableau with R</h3><p>From last post, I used <strong>R</strong> language to conduct the analysis. (For those who is interested in the analysis by R:<a href="https://medium.com/@w696905/google-analytics-case-study-how-does-a-bike-share-navigate-speedy-success-6a1c6af9ae2c"> [Google Analytics Case Study] How Does a Bike-Share Navigate Speedy Success? — by R Programming Language</a>) However, I am going to use <strong>Tableau</strong> to analyze in this post and compare these two analytical methods.</p><h3>Background</h3><p>Just to recap the background, Cyclistic is a bike-share program. The company categorizes the customers into two: customers who purchase single-ride or full-day passes are referred to as <strong>casual riders</strong>; customers who purchase annual memberships are Cyclistic <strong>members</strong>. The financial analysts in the company have concluded that annual members are much more profitable than casual riders. Therefore, the marketing director believes that the company’s future depends on maximizing the number of annual memberships. The team needs to come up new marketing strategies to convert casual riders to annual members based on the data insights and data visualization, and get recommendations approval from the Cyclistic executives.</p><h3>Ask</h3><ul><li>Problem statement: How do annual members and casual riders use Cyclistic bikes differently?</li><li>Stakeholders: The director of marketing, marketing team and Cyclistic executive team.</li></ul><h3><strong>Data Structure &amp; Cleaning</strong></h3><ol><li>Combine the datasheets between July 2023 to July 2022. With Tableau, multiple spreadsheets with the same columns can be concatenated with one click on the “New Union” in data source panel without typing any code.</li></ol><p>2. Check the column names on the data source panel to see data structure.</p><p>3. Filter the NA rows. It can be done in the worksheet and applied to all the worksheets using the same data source.</p><h3>Analysis</h3><ol><li><strong>Bike types</strong></li></ol><p>In Tableau, it is easy to build a graph and change the layout with three dimensional parameters just by dragging the columns to different places. It all depends on what story’s going to be told, what kind of arrangement is more eye-catching and easily understood by the audience.</p><p>The three figures below show the different combinations of three columns from the data source, which are member_casual, rideable_type and count different ride_id. The interesting part here is that no annual members using docked bikes during the data period. If I want to highlight this part, I will probably choose <strong>Figure 1</strong> to present because it is easier to recognize the docked_bike among all other data. However, depends on the analysis below, the figure presented at the end might be different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*efpj29SSlRKSqy-Id6uKKQ.png" /><figcaption>Figure 1 — Bike types usage by different member types (columns: member_casual, rideable_type; rows: count different ride_id; colors: rideable_type).</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0tAsuyrtxoTibH7yUnB1w.png" /><figcaption>Figure 2— Bike types usage by different member types(columns: rideable_type, member_casual; rows: count different ride_id; colors: member_casual).</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZTB-eAsOtX8Ozuqbga4-DQ.png" /><figcaption>Figure 3 — Bike types usage by different member types (columns: member_casual; rows: count different ride_id; colors: rideable_type).</figcaption></figure><p>2. <strong>Mean travel time for each ride</strong></p><p>It is simple to do some calculations in Tableau by typing the function into the “Create Calculated Field”. Therefore, the time spent on each ride can be computed.</p><p>The figure below also shows that the docked bikes are only used by casual riders and the mean travel time by docked bikes reaches 50.38 min. The statistics data can be shown on the same panel after the graph’s built without extra coding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*HyEPXojmanVUgyx07MYQMw.png" /><figcaption>Figure 4 — Mean travel time for each ride by different member types and rideable types.</figcaption></figure><p>3. <strong>Mean distance for each ride</strong></p><p>From <strong>Figure 5</strong>, the mean travel distance by each member types and bike types doesn’t show much difference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*ILyMxOeEWb7U_hKwoNC7xA.png" /><figcaption>Figure 5 — Mean travel distance for each ride by different member types and rideable types.</figcaption></figure><p>4. <strong>Day of the week</strong></p><p>Tableau is very convenient to build the interface to interact with the users/audience. The figure below shows the number of rides on each day of the week by different member types. The rideable_type click boxes are created to check if there’s special trend between different bike type. From <strong>Figure 6–9</strong>, no matter by classic bikes or electric bikes, annual members use more on the weekday. On the contrary, casual riders use bikes more on weekends. In conclusion, annual members contain higher percentages of commuters than casual riders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKdDly7f5SgHAh_dBPdD7w.png" /><figcaption>Figure 6 — Number of rides on each day of the week by different member types and <strong>all types of bike.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eko92vZ4BtmmgDXrDso_eA.png" /><figcaption>Figure 7— Number of rides on each day of the week by different member types using <strong>classic bikes</strong>.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lX7yOB83DK7hBRHtlnK5CA.png" /><figcaption>Figure 8— Number of rides on each day of the week by different member types using <strong>docked bikes</strong>.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Wscooac6qUzuzJIhqNn9g.png" /><figcaption>Figure 9— Number of rides on each day of the week by different member types using<strong> electric bikes.</strong></figcaption></figure><p>5. <strong>Popular start stations</strong></p><p>Creating maps by R is pretty complicated, which a map package needs to be loaded. Different map packages have different structures, so it takes time to understand the correct functions and parameters to illustrate a map needed. However, combining the map with data in Tableau is much more simple which basically just drag the longitude and latitude to column shelf and row shelf, and then the data will automatically be created on the OpenStreetMap.</p><p>Figures below are the maps and lists of popular start start stations by different member types. The count of ride_id from each start start stations is categorized into different levels so that the users can easily filter. The conditions beside the map synchronize with map and list. After the cursor moves to the dot on the map, the start station name will show directly on the panel, as shown on <strong>Figure 10</strong>.</p><p>From <strong>Figure 10</strong>, the clusters of the popular start stations by casual riders are around the parks or places that people usually hang out on weekends. For example, the most popular start station by casual riders is Streeter Dr &amp; Grand Ave which is nearby the Milton Lee Olive Park, Chicago Children’s museum, Ohio Street Beach and Centennial Wheel. On the other hand, the clusters of the popular start stations by annul members are mainly located in the Chicago central business district as marked in <strong>Figure 11</strong>.</p><p>Compare the lists in <strong>Figure 10 </strong>and <strong>11</strong>, the ride counts of the top start stations by casual riders are much more than annual members. The ride count of the most popular station by casual riders is even double of the annual member one. From <strong>Figure 3</strong>, during the data period, the total ride counts of annual members are around 3100k and casual riders are around 1900k. Combine these two results which indicates that the preference of the start stations by casual riders are highly focus on these six stations. If the marketing strategies can convert these casual riders start from these six stations to become annual members, the revenue will be highly increased.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKn9GUn-mWzB6svjq-sNEQ.png" /><figcaption>Figure 10 — Popular start stations by casual riders.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kmlA1NSpRogPd7yEI_xUnA.png" /><figcaption>Figure 11 — Popular start stations by annual members.</figcaption></figure><h3>Conclusion</h3><p>According to the analysis above, the suggestions are pretty much the same as the one conducted by R and will be separated into two parts. First part is to try to use the pricing strategy and advertisement area/time to convince the casual riders to transfer to annual memberships (1, 2). Second is to think about other kinds of memberships that casual riders will be more interested into (3, 4).</p><p><strong>1. Pricing strategy</strong></p><p>From <strong>Figure 4</strong>, the casual riders spend longer on each ride than the annual members. Therefore, if the current annual membership fee (or discuss to amend) is competitive when riding beyond certain amount of time, then the casual riders might be persuaded.</p><p><strong>2. Advertisement/promotion area and time</strong></p><p>From the 5th part of the analysis above, most of the casual riders usually start from the bike stations near the parks or area with specific facilities (ex. aquarium, museum). Therefore, to assure that the casual riders understand and well-noted the information of annual membership, company can do the related advertisement around that certain area. Besides, according to 3rd part of the analysis, most casual riders bike on Saturday. Therefore, combining the information mentioned, a promotion activity can be held nearby a bike route on Saturday to increase the annual memberships information exposure.</p><p><strong>3. Annual weekend memberships</strong></p><p>According to 4th part of the analysis, there are more casual riders biking on weekends. Therefore, an annual weekend memberships might be more appealing to this group of people rather than paying a full annual membership.</p><p><strong>4. A seasonal travel package cooperate with specific facilities</strong></p><p>From 5th part of the analysis, casual riders usually start the biking close to certain facilities, such as Shedd aquarium, Chicago Children’s museum, Centennial Wheel. Therefore, a seasonal travel package collaborated with all these facilities in Chicago might be attractive to the people who like to bike around these spots on weekends.</p><p>The analysis result is pretty much the same as the one conducted by R except for the map part. With the map built in Tableau, it is more convenient for the analyst and audience to understand the relative location of each station with its surroundings. Different layouts are easily conducted in Tableau, so it is easier to look at the data from different aspects. The interface created by Tableau is more user friendly and can interact with audience, so it is a powerful tool to apply in a presentation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=805683b87738" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[上課心得]GT OMSCS ML4T]]></title>
            <link>https://medium.com/@w696905/%E4%B8%8A%E8%AA%B2%E5%BF%83%E5%BE%97-gt-omscs-ml4t-c48a3afdcb99?source=rss-673226873d98------2</link>
            <guid isPermaLink="false">https://medium.com/p/c48a3afdcb99</guid>
            <category><![CDATA[omscs]]></category>
            <category><![CDATA[ml4t]]></category>
            <dc:creator><![CDATA[Wendy Su]]></dc:creator>
            <pubDate>Tue, 19 Dec 2023 01:49:14 GMT</pubDate>
            <atom:updated>2023-12-19T01:49:14.621Z</atom:updated>
            <content:encoded><![CDATA[<p>這堂課全名是Machine Learning For Trading，掛名教授是Dr.Balch和Dr.Joyner(目前OMSCS director)，但線上課程的影片都是由Dr.Balch在2015年錄的（YouTube上其實都找得到影片），所以一開始會懷疑這堂課是不是有點跟時下現況脫節，後來想想覺得都是基礎知識，所以跟時代沒有關係，我想這也是為什麼他們保留了2015的影片到現在。作業繳交的Python版本是3.6，所以整個coding的環境都要config。但整個學期的架構很完整（<a href="https://lucylabs.gatech.edu/ml4t/">歷年來的ML4T資訊</a>），每周都會有該完成的進度和作業，尤其是對我這種不是資工背景的很友善（意思就是有資工背景的人可能前半部會覺得很簡單XD），而且每個助教的來頭都不小，也都很認真的對待在助教課上的每一位學生，在論壇上發表問題，基本上一天內就會得到回覆。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Xj9CpFEc5EKuahS4JP5xA.png" /><figcaption><a href="https://www.youtube.com/watch?v=_z6I9K6Sy6A&amp;ab_channel=GeorgiaTechCollegeofComputing">Excerpts from Machine Learning for Trading</a></figcaption></figure><p>總共有12次小考、8個Project和2次Exam。小考基本上只要有上課都拿得到分。全部的作業都是在Python環境下完成，第一個Project是應用Martingale Strategy在美式輪盤賭上，讓我們了解Monte Carlo Method，熟悉一下之後要被大量運用的機率問題和這堂課寫論文的方式（Dr.Joyner開的課基本上都會要寫論文！如果之前碩班有寫過，這絕對不是什麼問題），第二、五、七項Project跟Trading比較有關，要找出指定股票的最佳投資組合，計算投資組合的獲利情況，運用股票技術指標探討獲利，當然這些全部都是用Python寫，這堂課其實教了滿多財經相關的知識（Dr.Balch開過一家對沖基金的AI策略公司，也寫過一本對沖基金的書，他相信technical analysis運用得好，就可能打敗市場XD）其他Project包含建構Decision Tree Learner, Random Tree Learner, Bag Learner, Q Learner，最後一個Project是capstone，選一個Learner並結合技術指標來執行簡單的股市交易，讓獲利達到最大。</p><p>這學期的考試都是Open book的多選題，因為財經和ML交雜在一起，還有很多本必讀的教材(其實我沒有全看lol)，所以要準備的範圍滿廣的，雖然Practice Exam裡面一堆財經的問題，但其實考試還是著重在ML的觀念。</p><p>這整堂課我覺得算是在現實生活中非常有用的，Dr.Balch的教學方式也滿有趣的，所以不會有種在囫圇吞棗的感覺，還會推薦一些影片讓我們自己消化，像是2015的電影The Big Short，探討當初2008發生金融海嘯的原因與事情經過(Nettflix上可以觀看!)，或是YouTube影片: <a href="https://www.youtube.com/watch?v=DX9djYus9tY&amp;ab_channel=60Minutes">Is the stock market rigged?</a> 探討其實我們散戶所投資的股票市場在背後有High frequency trader操縱著。結論就是我認為這堂課滿適合OMSCS初心者的，有心的話其實可以學到很多東西，教授跟助教也都很樂意幫忙，是一堂值得六百多美金的課。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c48a3afdcb99" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Google Analytics Case Study] How Does a Bike-Share Navigate Speedy Success?]]></title>
            <link>https://medium.com/@w696905/google-analytics-case-study-how-does-a-bike-share-navigate-speedy-success-6a1c6af9ae2c?source=rss-673226873d98------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a1c6af9ae2c</guid>
            <dc:creator><![CDATA[Wendy Su]]></dc:creator>
            <pubDate>Fri, 15 Dec 2023 19:54:36 GMT</pubDate>
            <atom:updated>2023-12-23T02:48:15.900Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Google Analytics Case Study] How Does a Bike-Share Navigate Speedy Success? — by R Programming Language</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*-hxLbwxrIuvkdQTAP1OHdA.png" /></figure><h3><strong>Background</strong></h3><p>Cyclistic is a bike-share program that features more than 5,800 bicycles and 600 docking stations. Cyclistic’s finance analysts have concluded that annual members are much more profitable than casual riders. (Customers who purchase single-ride or full-day passes are referred to as casual riders. Customers who purchase annual memberships are Cyclistic members.) The director of marketing Lily Moreno has set a clear goal: <strong>Design marketing strategies aimed at converting casual riders into annual members.</strong> In order to do that, the marketing analyst team needs to better understand how annual members and casual riders differ, why casual riders would buy a membership, and how digital media could affect their marketing tactics.</p><h3><strong>Case Study Roadmap — Ask</strong></h3><ol><li><strong>Problem Statement</strong><br>Moreno has assigned the first question to answer: How do annual members and casual riders use Cyclistic bikes differently?</li><li><strong>Consider Key Stakeholders</strong><br>The key stakeholders are the director of marketing Lily Moreno, marketing team and Cyclistic executive team.</li><li><strong>Business Task</strong><br>The main goal is to convert casual riders into annual members. Therefore, concluding the goal and the problem, the business task should be to <em>identify the patterns between casual riders and annual members, and figure out if there’s opportunity to motivate the casual riders to become annual members.</em></li></ol><h3><strong>Case Study Roadmap — Prepare</strong></h3><ol><li><strong>Is The Data ROCCC? (Reliable, Original, Comprehensive, Current, Cited)</strong><br>The data source is from Cyclistic directly and it has been made available by Motivate International Inc. under certain license. It contains data from 2013 to 2023.</li><li><strong>Data Structure</strong><br>The datasets in recent 12 months are pretty organized, which all the column names and counts are aligned. It contains ride id, ride type(classic/electric), casual/members, start and end station name, id, time, latitude and longitude.</li><li><strong>Sort And Filter Data</strong><br>The datasets used in this study is from July 2023 to July 2022. There are still some empty cells, which need to be filtered.</li></ol><pre># load useful package<br>library(tidyverse)<br>library(dplyr)<br>library(readr)<br>library(lubridate)<br>library(geosphere)</pre><pre># combine all the datasets from July, 2022 to July, 2023<br>df &lt;- list.files(path = &quot;/kaggle/input/cyclistic-bike-case-study-july22-july23&quot;, pattern = &quot;*.csv&quot;, full.names = TRUE) %&gt;% lapply(read_csv) %&gt;% bind_rows()<br># view the first 6 rows<br>head(df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LKVxoHXKltzD84I6Ul2gtQ.png" /></figure><h3><strong>Case Study Roadmap — Process</strong></h3><ol><li><strong>Tools</strong><br>R programming language is used in this case study. R is very convenient to merge multiple files together just with few lines of code and faster to deal with big data than excel.</li><li><strong>Cleaning Process</strong><br>After browsing the data, some columns need to be added: the travel time for each ride, the distance for each bike ride and transfer the date to day of the week (ex, Monday, Tuesday…)</li></ol><pre># drop the NA rows<br>new_df &lt;- drop_na(df)<br># create the columnd needed<br>new_df$ride_time &lt;- difftime(new_df$ended_at,new_df$started_at)<br># ride distance by km<br>new_df$ride_distance &lt;- distGeo(matrix(c(new_df$start_lng, new_df$start_lat), ncol = 2), matrix(c(new_df$end_lng, new_df$end_lat), ncol = 2))/1000<br># week of the day<br>new_df$week_day &lt;-  weekdays(new_df$started_at)</pre><h3><strong>Case Study Roadmap — Analyze</strong></h3><p>Again, the goal is very important:<em> Find the differences or patterns between annual members and casual riders. </em>I will focus on 5 different aspects as below:</p><ol><li><strong>Bike types</strong></li></ol><p>From Figure 1, annual members’ and casual riders’ favorites are classic bikes. However, no dock bike used by the annual members during the data period.</p><pre>ggplot(data = new_df,aes(x = rideable_type, fill = member_casual)) + <br>    geom_bar(position =&#39;dodge&#39;)+<br>    labs(title=&#39;Figure 1 - Bike types usage by different memberships&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*ZOMe7VixfbWf3569wtduDA.png" /></figure><p>2. <strong>Mean travel time for each ride</strong></p><p>From the table and Figure 2 below, we can see that casual riders spend longer on each ride than the annual members on average no matter by which type of bike. Especially the docked bikes, casual riders spend around 50 mins/ride.</p><p>-&gt; Can the pricing strategy now persuade the casual riders that it is cheaper to have the annual memberships if they spend on the bikes longer than certain amount of time?</p><p>-&gt; From Figure 1 and 2, docked bikes are the least used ones, but with the longest mean travel per ride. Is it because of the location? (Near biking route?)</p><pre>ride_time_mean &lt;- new_df %&gt;% group_by(member_casual, rideable_type) %&gt;% summarise(mean_time = mean(ride_time))<br>View(ride_time_mean)<br>ggplot(data = ride_time_mean) +<br>    geom_col(mapping = aes(x = rideable_type, y = mean_time, fill = member_casual), position =&#39;dodge&#39;) +<br>    labs(title = &#39;Figure 2 - Mean travel time per ride&#39;, y = &#39;mean_time(sec)&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*-q200_3OhodqJUgrYsijKQ.png" /><figcaption>Table — Mean travel time for each ride by different member types.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*7_MZa1hqtlYjeGoPk-1NuA.png" /></figure><p><strong>3. Mean distance for each ride</strong></p><p>From the table and bar chart below, we can see that there’s not much difference for the biking distance between casual riders and annual members.</p><pre>ride_distance_mean &lt;- new_df %&gt;% group_by(member_casual, rideable_type) %&gt;% summarise(mean_distance = mean(ride_distance))<br>View(ride_distance_mean)<br>ggplot(data = ride_distance_mean) +<br>    geom_col(mapping = aes(x = rideable_type, y = mean_distance, fill = member_casual), position =&#39;dodge&#39;) +<br>    labs(title = &#39;Figure 3 - Distance per ride by different member types&#39;, y = &#39;Distance(km)&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*rLUvzS0dnytzt_C05efo2g.png" /><figcaption>Table — Mean distance for each ride by different member types.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*I01k7Wb-MEonU2_FQtDC3w.png" /></figure><p><strong>4. Day of the week</strong></p><p>From Figure 4 below, we can see that there are more casual riders using the bikes on the weekends than the weekdays. On the contrary, the peak of annual members’ riding shows up on the weekdays. Figure 5 indicates that most members use the bikes on Saturday.</p><p>-&gt; Annual memberships contain higher percentage of commuter and that’s why the annual members have shorter bike usage time.</p><p>-&gt; Will it help to do the annual memberships promotion on Saturday?</p><pre># rearrange the order of x-axis<br>week_order &lt;- c(&#39;Sunday&#39;, &#39;Monday&#39;, &#39;Tuesday&#39;, &#39;Wednesday&#39;, &#39;Thursday&#39;, &#39;Friday&#39;, &#39;Saturday&#39;)<br><br>#barplot<br>ggplot(data = new_df, aes(x = factor(week_day, level = week_order), fill = member_casual)) +<br>    geom_bar(position =&#39;dodge&#39;) +<br>    labs(title = &#39;Figure 4 - Numbers of ride by different member types on each day&#39;, x = &#39;day&#39;, y = &#39;count&#39;)<br><br>ggplot(data = new_df, aes(x = factor(week_day, level = week_order), fill = rideable_type)) +<br>    geom_bar(position =&#39;dodge&#39;) +<br>    labs(title = &#39;Figure 5 - Numbers of ride by different bike types on each day&#39;, x = &#39;day&#39;, y = &#39;count&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kAZFDgIcG8jiqLDlNfj6Og.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UsmaZ5S3YQh5mhpGOsweZw.png" /></figure><p><strong>5. Top 6 popular start stations</strong></p><p>From the analysis above, we can have some first insight that there are more commuters having annual memberships. To get more information, the tables below show top 6 popular start stations by the casual riders, casual riders using docked bikes and annual members respectively. According to the charts below, the docked bike start stations are either near the bike routes or specific facilities (ex. aquarium, museum), and the rankings are also similar to the casual riders’ start stations. The results can support the analysis above as well.</p><pre>new_df_casual &lt;- filter(new_df, member_casual == &#39;casual&#39;)<br>new_df_casual_top_station &lt;- new_df_casual %&gt;% count(start_station_name) %&gt;% arrange(desc(n))<br>head(new_df_casual_top_station)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*tDOKkrzOmhd26Q6bn9BtYg.png" /><figcaption>Table — Top 6 start stations by the casual riders.</figcaption></figure><pre>new_df_casual_docked &lt;- filter(new_df_casual, rideable_type == &#39;docked_bike&#39;)<br>new_df_casual_docked_top_station &lt;- new_df_casual_docked %&gt;% count(start_station_name) %&gt;% arrange(desc(n))<br>head(new_df_casual_docked_top_station)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*PxHsxdotZT2zoog8RQtE3g.png" /><figcaption>Table — Top 6 start stations by the casual riders using docked bikes.</figcaption></figure><pre>new_df_member &lt;- filter(new_df, member_casual == &#39;member&#39;)<br>new_df_member_top_station &lt;- new_df_member %&gt;% count(start_station_name) %&gt;% arrange(desc(n))<br>head(new_df_member_top_station)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*s06AT3w-3uQ3sz_7vPV69g.png" /><figcaption>Table — Top 6 start stations by the annual members.</figcaption></figure><h3><strong>Case Study Roadmap — Act</strong></h3><p>According to the analysis above, the suggestions will be separated into two parts. First part is to try to use the pricing strategy and advertisement area/time to convince the casual riders to transfer to annual memberships (1, 2). Second is to think about other kinds of memberships that casual riders will be more interested into (3, 4).</p><p><strong>1. Pricing strategy</strong></p><p>From Figure 2, the casual riders spend longer on each ride than the annual members. Therefore, if the current annual membership fee (or discuss to amend) is competitive when riding beyond certain amount of time, then the casual riders might be persuaded.</p><p><strong>2. Advertisement/promotion area and time</strong></p><p>From the 5th part of the analysis above, the casual riders usually start from the bike stations near the bike routes or area with specific facilities (ex. aquarium, museum). Therefore, to assure that the casual riders understand and well-noted the information of annual membership, company can do the related advertisement around that certain area. Besides, according to 3rd part of the analysis, most casual riders bike on Saturday. Therefore, combining the information mentioned, a promotion activity can be held nearby a bike route on Saturday to increase the annual memberships information exposure.</p><p><strong>3. Annual weekend memberships</strong></p><p>According to 4th part of the analysis, there are more casual riders biking on weekends. Therefore, an annual weekend memberships might be more appealing to this group of people rather than paying a full annual membership.</p><p><strong>4. A seasonal travel package cooperate with specific facilities</strong></p><p>From 5th part of the analysis, casual riders usually start the biking close to certain facilities, such as Shedd aquarium, Chicago Children’s museum, Centennial Wheel. Therefore, a seasonal travel package collaborated with all these facilities in Chicago might be attractive to the people who like to bike around these spots on weekends.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a1c6af9ae2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[學習筆記] Markov Decision Process (MDP)]]></title>
            <link>https://medium.com/@w696905/%E5%AD%B8%E7%BF%92%E7%AD%86%E8%A8%98-markov-decision-process-mdp-a1c56c206b78?source=rss-673226873d98------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1c56c206b78</guid>
            <category><![CDATA[markov-decision-process]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <dc:creator><![CDATA[Wendy Su]]></dc:creator>
            <pubDate>Sun, 10 Dec 2023 05:09:14 GMT</pubDate>
            <atom:updated>2023-12-11T01:28:15.264Z</atom:updated>
            <content:encoded><![CDATA[<p>MDP是Reinforcement Learning (RL)很重要的概念，幾乎大部分的RL問題都能套用MDP。先大略解釋一下RL，RL跟其他機器學習不一樣的地方在於它不對資料作標記，也不需找出規則，只有一個目標：在每次Trial and error中，讓獎勵(Reward)最大化。有很廣的應用範圍，例如：投資組合的管理、管理發電廠、控制機器人行走等等。最近鬧得沸沸揚揚關於OpenAI共同創辦人Sam Altman被解聘又在短期之內回鍋的新聞，很多人都在猜測是跟OpenAI的新項目”Q*”有關，而Q*或許就是Q-Learning 和A*演算法的結合[1]，其中Q-Learning就是屬於RL。</p><p>(以下基本上就是Google DeepMind RL Course by David Silver Lecture 2的筆記[2, 3])</p><blockquote>Introduction of Reinforcement Learning</blockquote><p>RL的機器人(Agent)在每個階段會執行一個動作(Action)，和環境互動之後，能觀察(Observation)到環境的狀態，並接收相對應的懲賞(Reward)，機器人會藉由這次的狀態來選擇下一個動作。(圖一)當整個環境是可被觀察的(Fully Observable)，也就是機器人的狀態(Agent State)等於現在環境的狀態(Environment State)，那就是符合Markov Property。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*zzcFqLW1zXtwuwzRwD1e2Q.png" /><figcaption>圖一、機器人和環境示意圖</figcaption></figure><p>圖二是一個迷宮遊戲，每走一步的獎勵是-1，有四個方向的移動選項，狀態(State)是機器人的位置，圖二(a)的白色格子代表機器人有走過的地方，以此遊戲來舉例機器人做決策的方式有以下幾種:</p><ol><li>策略(Policy): 機器人的行為函數，如圖二(b)，在機器人眼中每個狀態都是以動作來表示。</li><li>價值(Value): 以未來的懲賞來判斷該狀態的好壞，如圖二(c)。</li><li>模型(Model): 機器人預測環境會給的反饋，如圖二(d)。</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VuPssZBGms7VBWbzpJ0ofg.png" /><figcaption>圖二、迷宮遊戲</figcaption></figure><blockquote>Markov</blockquote><p>定義一下Markov，如果一個狀態(state)符合Markov Property：</p><blockquote>“The future is independent of the past given the present.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*p_FOoyOJsOLhOjik1t14Mg.png" /></figure><p>換句話來說也就是現在的狀態能代表過去所有關聯的歷史紀錄，那就可以摒棄這些歷史紀錄。舉一個真實生活中的例子，在一家咖啡店由機器人處理咖啡訂單，如果機器人得到reward的方式是處理當下的訂單，那就符合Markov Property，但如果機器人是藉由處理之前還沒被製作的訂單來得到reward，那就是一個Non-Markov reward。</p><blockquote>Markov Reward Process</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*R2F8onr9FajsIQPEhA_vEA.png" /></figure><p>以下用學生MRP舉例，Termination是Sleep，在Class1當下的reward 是-2，滑個臉書的reward還比上課還高，去個Pub還能得到+1，但這只考慮到當下的reward(只要有進入該狀態，在離開該狀態時，不管往哪個方向都會得到的懲賞)，在考慮選擇的時候，我們通常要以更宏觀的角度來看，如果上完所有的課，最後Pass了，能得到的獎勵其實是最多的。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*PPFvT36decemJsfK80XKiA.png" /></figure><blockquote>Discounted Factor</blockquote><p>在考慮未來獎賞時會乘上discounted factor (gamma)，以人類行為來說的話就是我們通常都會偏好當下得到獎賞（短視近利？），讀書可能可以讓未來生活好過一點，但跟馬上出去玩比更痛苦，而且讀書未來能得到的獎賞也是不一定的，所以越遠的未來，乘上的discounted factor會更多。另外一個原因就是為了讓馬可夫鏈收斂，假設沒有dicsounted factor，我們在Class 3的狀態下看到Pass 能得到10，去Pub能得到1，以得到最大獎勵為目標的話，其實我們可以一直在Pub的loop不出去，也能得到跟Pass一樣的獎勵值。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*MgGf9mmLM5qNhcDMwuNXIQ.png" /></figure><blockquote>Bellman Equation</blockquote><p>Bellman Equation用來計算MRP裡狀態的價值，是<strong>當下的獎賞加上下一步discounted狀態價值的期望值</strong>(基本上就是當作可以預測下一步的概念one step ahead)，為什麼只考慮下一個狀態價值，以下有推導。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*NHtSbe4Cl-7lAbF7-t-jmQ.png" /></figure><p>舉個例，要計算紅色圈圈裡的價值，只要考慮離開該狀態能馬上拿到的reward (-2)，和下一個可能狀態的期望值(0.6機率得到10，0.4機率得到0.8)。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*P_llViVtxdiBe3GVfdbb8Q.png" /></figure><blockquote>Markov Decision Process</blockquote><p>以上都只考慮到狀態的價值，接下來要加入動作，也就是Markov Decision Process。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*2oOcxPCVllO1efXjFaC64Q.png" /></figure><p>這裡狀態價值函數(v)加入了動作，也就是告訴我們當機器人如果使用策略π在狀態s的好壞程度，用剛剛學生MRP的例子來說就是可以計算如果我們按照「完成課程」這個策略進行的話，能拿到多少獎賞。</p><p>第二個價值函數是動作價值函數(q)，也就是告訴我們當機器人按照已知策略π執行動作a在狀態s的好壞程度，這是我們直覺上更重視的，一樣拿學生的例子來說，在Class3的狀態下，q可以提供的就是讓機器人知道要往Pass的方向走還是Pub的方向走才能拿到最多的獎賞。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*1pwZF97RWyb7rkDN6uH8cA.png" /></figure><p>用下面兩張圖來解釋v和q的關係，圖三當我們處在白點狀態s，有機會往左下的黑點走，也有可能往右下走，機率取決於此時的策略，s狀態價值函數是兩個動作價值函數的期望值加總。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*-bckO_UMPZqvVvFa1rku_A.png" /><figcaption>圖三、Bellman Equation for v</figcaption></figure><p>相反的，圖四當我們站在黑點狀態s採取動作a，但可能會有不同的環境作用，像是我本來想向右走，但風一吹，我的下一步落點(s&#39;)就不一樣了，s的動作價值函數就會是兩個不同未來狀態的價值函數期望值總和。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*K2_7uJNgmXvWqpASoxpmIw.png" /><figcaption>圖四、Bellman Equation for q</figcaption></figure><p>將上面兩張圖合併起來，就會得到圖五，得到v和q的Bellman Expectation Equation，以及當下狀態的價值函數與下一步狀態的價值函數的關係。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUFd41Liet5gvns3LxZL9A.png" /><figcaption>圖五、v和q的Bellman Expectation Equation</figcaption></figure><p>剛剛學生MRP的例子改成MDP，讓狀態變成動作並驗證上述提到的Bellman Expectation Equation。在Class3狀態下執行一半機率Study或是去Pub的策略，去Pub之後的狀態會有機率停留在Class1、Class2或是回到Class3，把這些期望值加總，就能得到7.4。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*aMnIGxgYyuISD5Upm_RXsQ.png" /></figure><p>所以Bellman Equation把價值函數都轉換成可解的線性方程式，但以上都沒提到要怎麼讓機器人做最好的選擇，我們實際上只在乎怎樣才能得到最大的獎賞，基本上只要找到q*，就會找到勝利方程式。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*lRY-xb05blA25IuQy-gcEA.png" /></figure><p>再回到學生MDP，我們的策略就是跟著q*最大的方向走，也就是圖中紅色的路徑。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*T08IRbnf2RDQS5ECzMkHyg.png" /></figure><p>以上就是MDP的概念，之後再找個時間看能不能補上怎麼實際上計算v值和q值(也就是學生MRP/MDP裡那些框框裡面的數字是怎麼算出來的)。</p><p>資料來源:</p><ol><li><a href="https://www.barrons.com/articles/q-star-algorithm-openai-chatgpt-sam-altman-3956175f">https://www.barrons.com/articles/q-star-algorithm-openai-chatgpt-sam-altman-3956175f</a></li><li><a href="https://www.davidsilver.uk/teaching/">https://www.davidsilver.uk/teaching/</a></li><li><a href="https://youtu.be/lfHX2hHRMVQ?si=NZ6wauAjmIQU4e7u">https://youtu.be/lfHX2hHRMVQ?si=NZ6wauAjmIQU4e7u</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1c56c206b78" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>