<?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 Chawannut Prommin on Medium]]></title>
        <description><![CDATA[Stories by Chawannut Prommin on Medium]]></description>
        <link>https://medium.com/@chawannut157?source=rss-c20c5daed60d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*eVLWHdJ90qSX2ry9.</url>
            <title>Stories by Chawannut Prommin on Medium</title>
            <link>https://medium.com/@chawannut157?source=rss-c20c5daed60d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 03:44:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chawannut157/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[ประสบการณ์การสัมภาษณ์งาน Data Scientist กับ tech firm อย่าง Facebook, Twitter, Microsoft, Amazon…]]></title>
            <link>https://medium.com/@chawannut157/%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B8%AA%E0%B8%9A%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%93%E0%B9%8C%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%B1%E0%B8%A1%E0%B8%A0%E0%B8%B2%E0%B8%A9%E0%B8%93%E0%B9%8C%E0%B8%87%E0%B8%B2%E0%B8%99-data-scientist-%E0%B8%81%E0%B8%B1%E0%B8%9A-tech-firm-%E0%B8%AD%E0%B8%A2%E0%B9%88%E0%B8%B2%E0%B8%87-facebook-twitter-microsoft-amazon-ad061010f687?source=rss-c20c5daed60d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad061010f687</guid>
            <dc:creator><![CDATA[Chawannut Prommin]]></dc:creator>
            <pubDate>Mon, 02 Jul 2018 02:30:28 GMT</pubDate>
            <atom:updated>2018-07-02T02:49:55.461Z</atom:updated>
            <content:encoded><![CDATA[<h3>ประสบการณ์การสัมภาษณ์งาน Data Scientist กับ tech firm อย่าง Facebook, Twitter, Microsoft, Amazon, PayPal และวิธีการเตรียมตัว</h3><p>ในช่วง 6 เดือนที่ผ่านมา ผมได้มีโอกาสไปสัมภาษณ์งานตำแหน่งงาน Data Scientist กับ tech firm หลากหลายที่ในสหรัฐอเมริกา โดยในโพสนี้ผมจะสรุป Process การสัมภาษณ์หลักๆ และ tip และ trick ต่างๆที่ผมได้เรียนรู้มาจนทำให้ได้งาน ซึ่งน่าจะเป็นประโยชน์ต่อคนที่กำลังหางานด้านนี้ทั้งในไทยและสหรัฐอเมริกาครับ</p><p>ก่อนอื่นต้องบอกก่อนว่า งานด้าน Data Sciene เป็นอะไรที่ ้hot มากๆ และต้องบอกว่า competitive มากๆในการหางาน ตัวอย่างข้างล่างคือตัวอย่างคนที่ส่ง resume ผ่าน Linkedin (ยังไม่รวมแหล่งอื่น) กับตำแหน่ง Data Scientist ของที่ Lyft (ซึ่งเป็น start up แบบเดียวกับ Uber และเป็นคู่แข่งหลักเลยทีเดียว)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0t_IEe_yzj3cpQj91g6HYg.png" /></figure><p>อย่างที่เห็นว่าคนสนใจด้านนี้เยอะมากๆ เกือบ<strong> 2 พันคนต่อตำแหน่งเดียว!</strong> โดยมีตั้งแต่ PhD Student หรือ Working Professional ที่มาจากสายอื่น (แต่เรียนจบ Data Science Boot camp มา) ยังไม่รวมนักเรียน ปโท หรือ ปตรี จาก Top ยูต่างๆ หรือจะเป็นคนที่มีประสบการณ์ด้านนี้มาแล้วอีกมากมาย!</p><p>คราวนี้มาพูดถึงในแง่ process</p><p>ส่วนมากการสัมภาษณ์งาน Data Science ในอเมริกานั้นจะแบ่งออกเป็น 4 ขั้นตอน</p><h4>1. Phone Interview with HR</h4><h4>2. Technical Phone Interview</h4><h4>3. Data Science Homework</h4><h4>4. Onsite Interview</h4><h3>ด่านแรก ทำอย่างไรให้ได้สัมภาษณ์ ?</h3><p>ผมเริ่มจากการส่ง resume ตามช่องทางออนไลน์ต่างๆ</p><p>…….แต่จากสถิติที่ผมลองนับดู ผมส่ง resume ไปเกิน100 ที่ได้ แต่ได้ตอบกลับมาน้อยกว่า 5 !!<strong>แถมไม่ใช่ tech firm ดังๆเลยสักที่</strong></p><p>หลังจากลองผิดลองถูกอยู่พักใหญ่และได้คุยกับรุ่นพี่หลายๆคน ผมจึงสรุปสองวิธีที่ effective ที่สุดในการให้ได้สัมภาษณ์ ตามนี้</p><ol><li>Networking</li></ol><p>คือพยายาม Connect กับคนที่ทำงานอยู่บริษัทที่เราต้องการทำงาน และขอคุยกับเขา เพื่อให้ได้ Internal Reference ให้เราได้สัมภาษณ์งาน วิธีนี้จะง่ายหน่อยถ้าเรารู้จักคนข้างในเป็นการส่วนตัว แต่ถ้าไม่รู้จักใครเลยจะทำอย่างไรหละ ? นั่นนำมาสู่วิธีที่สองครับ</p><p>2. Advertising</p><p>วิธีนี้คือเป็นวิธีที่ Creative มากๆซึ่งเพื่อนคนจีนแนะนำผมมา นั่นก็คือการยิง Ads บน Facebook! แต่วิธีนี้ต้องลงทุนหน่อยคือเราต้องมีเวป portfolio ของเราเองเพื่อใช้เป็น landing page แล้ว target คนในบริษัทที่เราต้องการทำงาน</p><p>มาดูตัวอย่างความสำเร็จของวิธีนี้ตามด้านล่างครับ Conversion Rate ที่ผมได้รับคือ 100% ทำให้ได้สัมภาษณ์ทันทีไม่ต้องไปยื่น resume ผ่านช่องทางออนไลน์ และผมก็ไม่ได้มี Connection กับคนในบริษัทนั้นๆเลย !</p><p>ตัวอย่างอันแรกเป็น Billion Dollar Startup Unicorn ด้าน Real Estate HR ส่งเมลมาหาโดยตรง !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SHbkrD5qs7iZZHccWBczbA.png" /></figure><p>ตัวอย่างที่สอง อันนี้ที่ Facebook มี Engineer เจอ ads เลยส่ง message มาหาโดยตรงเพื่อ refer ให้!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*5o8XK8djsUOzetGUDpU0yQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Nm-Flhm3aYT2XuLwX40Jw.png" /></figure><p>อย่างที่บอกไปว่าวิธีนี้ นั่นไม่ง่ายและใช้เวลา เพราะเราต้องมี website portfolio และเสียเงินค่า ads ด้วยนิดหน่อย (ผมเสียประมาณ $15 ต่ออาทิตย์)</p><h4>อย่างไรก็ตามนี่เป็นเพียงแค่ด่านแรกครับ เราจะได้งานไม่ได้งานขึ้นอยู่กับ performance เราหลังจากนี้เป็นหลักครับ</h4><h3>ด่านสอง Technical Interview -&gt; Focus on the basic</h3><p>(ในส่วนนี้ผมขอรวมทั้ง technical interview ทั้งแบบ phone interview และ onsite ไปเลยครับ)</p><p>ต้องบอกว่า Technical Interview งานด้าน Data Science นี้ เป็นอะไรที่ “จับฉ่าย” มากๆเพราะสามารถโดนถาม ได้ตั้งแต่ <strong>Algorithm, ML, Stats, Business, SQL และ A/B Testing</strong></p><p>ต้องบอกว่า ในการสัมภาษณ์แต่ละที่อาจจะไม่ถามครบ ส่วนใหญ่ จะถาม 3–4 อันจาก 6 concept ที่ผมได้บอกไว้ เช่น บางที่ อาจจะถาม Algo + ML + Stats + Business เป็นต้น</p><p>แต่ในระหว่างการเตรียมตัวสัมภาษณ์นั้นผมแนะนำให้ทวนครบทั้งหมดครับ</p><h3><em>1) Algorithm</em></h3><p>คำถามด้าน Algorithm สำหรับ Data Science จะมีความแตกต่างจาก Software engineer แต่มีหลายส่วนที่คล้ายๆกัน อย่างที่ผมเคยสัมภาษณ์กับ Twitter จะให้เรา debug code real time เลยทีเดียว! (ผ่านทาง Platform Hacker Rank) แล้วเขาจะโยน test case มาเรื่อยๆ ถือว่าโหดพอสมควร แต่ถ้าใครแน่นด้าน algorithm ไม่น่ามีปัญหาครับ</p><p><strong>หลายคนอาจจะสงสัยทำไมเขาถึงถาม Algorithm? </strong>มันไว้ถามพวก software engineer ไม่ใช้หรอ? ต้องบอกว่า เนื่องจากคนสนใจ Data Science เยอะมากๆ บริษัทต่างๆเลยคาดหวังว่า candidate จะมี basic ด้าน Algorithm ที่แน่น และคำถามด้านนี้ในมุมมองของบริษัทนั้นเป็นการกรองคนได้ระดับหนึ่ง (แต่อย่างไรก็ตามไม่ได้หมายความว่า ถ้าคุณไม่เทพ algo คุณจะทำงานแล้ว performance ไม่ดีนะครับ มันเหมือนข้อสอบ ที่ tech firm ส่วนใหญ่เชื่อว่าวัดคนได้ในมุมมองหนึ่งครับ)</p><p>ตัวอย่างคำถามด้านนี้สำหรับ Data Scientist</p><ul><li>หา Median ของ array โดยไม่ sort array</li><li>ให้ array มาแล้วให้หาว่ามีเลขสามตัวที่บวกรวมกันได้ค่าที่ต่องการหรือไม่</li><li>Dynamic Programming (ถามเป็นบางที่)</li></ul><p>สำหรับ Resoruce ที่แนะนำในการเตรียมตัวคือ Cracking the coding Interview / Leetcode และ Geekforgeek ครับ</p><p>โดยส่วนตัว trick ที่ผมเรียนรู้มาสำหรับ coding interview คือ<strong>เราต้องพยายามพูดในสิ่งที่เราคิดอยู่ออกมา </strong>ถึงแม้เรามาผิดทาง เราต้องพยายาม communicate ออกมาว่าเราคิดอะไรอยู่</p><p>นอกจากนี้อย่า focus ที่ best solution ทันที ถ้าเราคิด algo ที่ complexity เป็น O(n²) ได้ ให้พยายามเริ่มจากตรงนั้นก่อน พูดออกมา เขียน code ออกมา พอเราทำเสร็จเขาจะบอกวา Can you do better? ซึ่งเราก็จะมีเวลาเพิ่มในการคิด code ที่ดีกว่าเดิม ดีกว่าพยายามเสียเวลาคิดวิธีที่ดีที่สุดตั้งแต่แรก แล้วสุดท้ายสรุปคิดไม่ออก แล้วไม่สามารถแก้ปัญหาที่เขาให้มาได้</p><p>การสัมภาษณ์ด้าน algorithm ของ Data Scientist อาจจะไม่ยากเท่า Software Engineer แต่ถ้าคนที่ไม่ได้มาจาก ด้าน computer science (เช่นผม) อาจจะมีปัญหาบ้าง แก้ปัญหา ไม่ยากครับ <strong>practice practice และ practice!</strong></p><p>สำหรับ Trick เพิ่มเติม อ่านได้จากลิ้งด้านล่างครับของ Interview Cake ดีมากๆครับ ช่วยผมได้เยอะมากทีเดียวเวลาสัมภาณ์งาน</p><p><a href="https://www.interviewcake.com/tricks-for-getting-unstuck-programming-interview">Tricks For Getting Unstuck During a Coding Interview | Interview Cake</a></p><p>โดยส่วนตัวผม เรียน stats มา ทำให้อาจจะไม่คุ้นกับ coding interview มากเท่าไร ในช่วงแรกๆที่ผมได้ทำ coding interview กับบริษัทบางที่ พอเราเขียน code ออกไป นี่คนสัมภาษณ์นั่งขำผมเลยทีเดียว T_T …… หลังจากนั้นผมก็<strong> ฝึก ฝึก และ ฝึกครับ</strong> ใช้ครบมาหมดแล้ว Leetcode/Hacker Rank/Interview Cake รวมถึงหนังสืออีกหลายๆเล่ม ทำให้ตอนนี้คุ้นเคยขึ้นเยอะครับ</p><p>สำหรับใครที่อยู่ในสถานะคล้ายๆผม เช่น จบ Econ/Physics/Stats แล้วกังวลว่าจะไปสู้คนจบ Computer Science ได้หรอ? คุณทำได้ครับ ขนาดผมยังทำได้เลย!</p><h3>2) Machine Learning</h3><p>สำหรับด้าน Machine Learning นั้นจะเป็นลักษณะการถามตอบปากเปล่ามากกว่า ซึ่ง Basic เราต้องแน่นจริงครับถึงจะผ่านคำถามเหล่านี้ไปได้ สำหรับ Concept ที่เน้นถามจะเป็น</p><ul><li>ฺBias-Variance Trade off เช่นทำอย่างไรให้รู้ว่าเรามี Bias หรือ Variance problem?</li><li>ข้อดี ข้อเสีย ของ Algo ต่างๆ เช่น ข้อจำกัดของ SVM คือ? หรือ L1 vs L2 มีข้อดีข้อเสียอย่างไร</li><li>อธิบาย Algo ต่างๆเช่น Boosting/Random Forest</li></ul><p>สำหรับการเตรียมตัวของผมนั้น เนื่องจากผมเรียนจบคอร์สด้าน Machine Learning ของมหาลัยพอดี ซึ่งได้ implement ทุก algo จาก 0 เลยเป็นการเตรียมตัวไปในเวลาเดียวกัน <strong>ผมจึงแนะนำให้ เรารู้ machine learning model อย่างลึกจริงครับ จะช่วยได้เยอะมากๆครับ</strong></p><p>อย่าพึ่งไป Advance มากถ้า Basic คุณยังไม่แน่น! (เช่น บางคน พูดถึง Deep learning แต่ อธิบาย Naive Bayes ไม่ได้ เขาก็จะรู้ทันทีว่า เราส่วนใหญ่นั้น import library ใช้อย่างเดียวไม่ได้มีความเข้าใจสิ่งที่เกิดขึ้นเลย)</p><p>และที่สำคัญมากๆคือ<strong> ถ้าเราไม่รู้อะไร ให้บอกว่า ไม่รู้ครับ อย่าพยายามแถ technical concept ครับ</strong> เขาจะจับได้อยู่แล้ว เช่น ผมเคยเจอคำถามว่า Missing Value มี สามประเภท คืออะไรบ้าง ผมเคยเรียนมาแต่จำไม่ได้ ผมก็บอกไปตรงๆ ไม่พยายามแถ <strong>บางทีการบอกว่า เราไม่รู้อะไรทำให้เราน่าเชื่อถือมากกว่ารู้ไปซะทุกเรื่องครับ</strong></p><p>ความสำคัญอีกอย่างหนึ่งคือ วิธีการเล่าเรื่องครับ เช่น ถ้าเขาถามให้อธิบาย K mean clustering เราควรเริ่มจากภาพรวมก่อนคือ ปัญหาคืออะไร -&gt; เราใช้ K-mean ทำไม -&gt; Algo ทำงานอย่างไร -&gt; มีข้อดีข้อเสียอย่างไร การตอบแบบนี้ดีกว่ามาถึงโป้ง ก็ลง detail algo เลยทันทีครับ</p><p>อีกทริคนึงคือ ถึงแม้เป็นคำถามปากเปล่า แต่ถ้าเราวาดรูประหว่างเราพูดประกอบไปด้วยก็จะช่วยได้เยอะครับ เช่น วาดกราฟ ระหว่าง accuracy กับ complexity ในระหว่างอธิบาย concept อันนี้</p><p>และข้อควรระวังอย่างยิ่งคือ อย่าแสดงอาการไม่พอใจถ้าคำถามง่ายเกินไป ! เช่นถ้าเขาถามว่า overfitting คืออะไร ผมเชื่อว่าคนเรียน Machine Learning ทุกคนรู้ว่ามันคืออะไร แต่ที่เขาอยากวัดคือ communication skill ของเราต่างหากครับ</p><h3>3) Statistics</h3><p>สำหรับคำถามด้าน Statistics นั้นจะเป็นการทดสอบความเข้าใจ concept อย่าง p-value หรือ Central limit theorem หลายๆคนอาจจะเข้าใจว่า อ้อ p-value หรอ ถ้า &lt; 0.05 ก็ sig จบข่าว ไม่เห็นมีอะไรเลย ……ตอนแรกผมก็คิดงั้นครับ แต่ความเข้าใจแบบข้างตนเป็นลักษณะของการ “ท่องจำ” เสียมากกว่า</p><p>ตัวอย่างคำถาม</p><ul><li>โยนลูกเต่าสองครั้ง ออก 6 ทั้งสองครั้ง ให้ทำ hypothesis testing …..ถ้าเราเข้าใจ p-value จริงๆ เราจะสามารถ derive hypothesis testing ออกมาได้เลยโดยไม่ต้องท่องจำมาว่าต้องใช้ test อะไรทำครับ</li><li>อธิบาย CLT และประโยชน์ของ CLT</li><li>อธิบาย Multiple Comparison</li></ul><p>Trick ที่ผมแนะนำคือ ต้องเข้าใจ Statistics แบบจริงๆครับถึงจะช่วยได้ resource หลักๆที่ช่วยผมได้เยอะคือ โพส ใน Quora ครับ</p><h3>4) Business case</h3><p>คำถามแนว Business case จะเป็นแนวให้โจทย์จริงของบริษัทมาแล้วลองวัดวิธีคิดของเราว่าเราจะแก้ปัญหาอย่างไร</p><p>ตัวอย่างคำถาม</p><ul><li>ถ้าต้องการ Predict Customer Life Time Value เราจะทำอย่างไร</li><li>ถ้าจะ Build Classification Model สำหรับ Churn Model จะทำอย่างไร</li></ul><p>Trick ของการตอบคำถามแบบนี้คือ ต้องพยายาม เก็บ requirement ให้ได้เยอะๆก่อนครับ ว่าโอเค ใครเป็นคนใช้ Model , Accuracy สำคัญไหม, Data ใหญ่แค่ไหน ….</p><p>พอเรายิงคำถามกลับไปเรื่อยๆแล้วเขาตอบกลับมา เราก็จะเห็นภาพรวมปัญหามากขึ้นและเลือกวิธีแก้ปัญหาได้ถูกต้องครับ</p><p>อีก Trick นึงที่ช่วยได้เยอะคือพยายามศึกษาบริษัทที่เราไปสัมภาษณ์ดีๆครับว่าเขาอยู่ใน Business แบบไหนและ Data หน้าตามันจะประมาณไหน</p><h3><strong>5) SQL</strong></h3><p>สำหรับ SQL นั้นส่วนใหญ่นั้นจะเป็นแนวแบบว่าให้ table มาและคำนวณ Metric ที่เขาต้องการครับ</p><p>ตัวอย่างคำถาม</p><ul><li>ให้ table มา ให้ เขียน Query คำนวณ Conversion Rate</li><li>ให้ table มา ให้ คำนวณ Year Over Year Growth</li></ul><p>ผมไม่ได้เสียเวลาเตรียมตัว SQL มากเท่าไร เพราะเป็นสิ่งที่ผมถนัดอยู่แล้ว แต่ถ้าใครไม่ถนัด ผมแนะนำให้ ทบทวน คำสั่งพื้นฐาน SQL ก็เพียงพอครับ หรือถ้าอยากลองแก้โจทย์ลองหาโจทย์ใน Leetcode ดูครับมีส่วนของ SQL อยู่ในนั้น</p><h3><strong>6) A/B testing</strong></h3><p>หลายๆคนคิดว่า Data Scientist ทำแต่ Deep learning….. ผมเห็นมีเพื่อนผมในไทยบอกว่า A/B testing เป็นเรื่องของ data analyst ….. A/B testing เป็นเรื่อง “ง่ายๆ” และ “ไม่ cool” ไม่ต้องถึงมือ Data Scientist หรอก …</p><p>ต้องบอกว่าเข้าใจผืดอย่างรุนแรงครับ</p><p>การทำ A/B testing ยากกว่าที่คิดเยอะครับ บริษัทอย่าง Microsoft , Pinterest , Netflix มีทีม ทำด้านนี้โดยเฉพาะครับ</p><p>ตัวอย่างงานด้านนี้ตามด้านล่างครับจาก Pinterest</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*997arczs-IXOpjC5FKvDaA.png" /></figure><p>ลองดู blog ของการทำ A/B testing ที่ Netflix ครับ แล้วจะรู้ว่ามันซับซ้อนและไม่ง่ายอย่างที่คุณคิด</p><p><a href="https://medium.com/netflix-techblog/interleaving-in-online-experiments-at-netflix-a04ee392ec55">https://medium.com/netflix-techblog/interleaving-in-online-experiments-at-netflix-a04ee392ec55</a></p><p>ส่วน resource ที่ดีที่สุดที่ผมเจอมาคือเว็ปนี้ของ Microsoft ครับดีมากๆๆๆ</p><p><a href="https://exp-platform.com/">ExP Platform</a></p><p>ตัวอย่างคำถาม</p><ul><li>จะต้องรัน A/B testing นานเท่าไรถึงสรุปผล?</li><li>Metric ที่ใช้วัดความสำเร็จควรใช้อะไร?</li><li>จะ randomize กลุ่มตัวอย่างอย่างไร?</li></ul><p>Trick ที่สำคัญของการตอบคำถามด้านนี้คือเราต้องรู้ metric ที่ใช้ครับเช่นใน context ของ tech firm ก็จะมี average time per session หรือ conversion rate และเลือก metric ให้เหมาะสม พร้อมบอกข้อดีข้อเสียของ metric นั้นๆครับ</p><h3>ด่านสาม Data Science Homework (มีเป็นบางที่)</h3><p>ด่านนี้ ทางบริษัทจะส่ง data set มาให้ พร้อมทั้งโจทย์ ให้เวลาเราประมาณ 5–7 วันในการเขียน code และ สรุปผล</p><p>ตัวอย่าง</p><ul><li>ให้ data set มา ให้สร้าง model</li><li>ให้ data set มา ให้ทำ A/B testing</li></ul><p>ความสำคัญของขั้นตอนนี้คือ<strong> เราต้องทำการบ้านให้ละเอียด เหมือนเราทำงานจริงครับ และต้อง และต้อง “ตอบโจทย” ์ที่เขาถามครับ</strong> เช่น ถ้าเขาให้ทำ insight จาก data แต่ดันไป focus ทำ machine learning แบบนี้ก็จะไม่ผ่านครับ</p><p>ทริคที่ผมแนะนำคือ<strong> Go beyond expectation</strong> และ พยายามคิดจากมุมมองของบริษัทเป็นหลัก เช่นผมได้การบ้าน มาให้ทำ Machine Learning model แทนที่จะหยุดแค่ โอเคทำโมเดลละ ได้ accuracy 80% …. เราเขียนต่อไปด้วยว่า เราสามารถ implement โมเดลนี้จริงๆได้อย่างไร และมีข้อดีข้อเสียอย่างไร ถ้าเราเอาไปใช้จริง และเรามีข้อแนะนำในการปรับปรุง model อย่างไร เช่นอาจจะเขียนไปว่า แนะนำให้เก็บ data เหล่านี้เพิ่ม จะช่วยเพิ่ม accuracy ได้</p><p>นอกจากนี้อีกสิ่งที่สำคัญคือ พยายาม ทำให้ code ของเรา reproduce ได้ครับ เช่น ใน R ก็อาจจะใช้ R notebook พร้อม fix seed เป็นต้น</p><h3>ด่านสุดท้าย Onsite interview</h3><p>หลังจาก สามขั้นตอนผ่านไปด้วยดี บริษัทก็จะออกค่าตั๋ว + ค่าโรงแรม ให้เราบินไปสัมภาษณ์กับ team data science เป็นเวลา 5–6 ชม ครับ โดยเราจะได้คุย กับ data scientist หลากหลายคนภายในทีม (บางครั้งอาจจะมี software engineer ด้วย) โดยแต่ละคนนั้นจะพยายามวัดเราทั้ง technical skill และ culture fit</p><p><strong>สิ่งที่สำคัญที่สุดของขั้นตอนนี้นอกจาก technical skill แล้วคือ mind set ครับ!</strong></p><blockquote>ใช่แล้วครับ mind set สำคัญมาก และ mind set ที่ถูกต้องคือ “ How can I solve their problems”</blockquote><p>การคิดแบบนี้จะทำให้เราพยายามที่จะช่วยแก้ปัญหาที่เขามีอยู่ แทนที่จะมา focus ที่ตัวเราเองว่าเรา จะได้งานหรือไม่ได้งาน การคิดแบบนี้ ช่่วยได้เยอะมากครับ</p><p>นอกจากนี้สิ่งที่ผมแนะนำเพิ่มเติมมีดังนี้</p><ul><li>List คำถามล่วงหน้า ผม list คำถามไว้ล่วงหน้าเกิน 10 ข้อ และอย่างที่บอก ถ้าเรามี mind set ที่ถูกต้องแล้ว เราอาจจะคิดคำถามเพิ่มเติมได้อีกครับ คำถามที่ดีที่ควรถามเช่น “How do you measure success?”</li><li>ทำ research บริษัท ล่วงหน้า ผมใช้เวลา 8–10 ชม ทำ research ก่อนไป onsite เพื่อให้เราเข้าใจบริษัทอย่างแท่จริง ลองหาข้อมูลเพิ่มเติม จาก Quora, Linkedin , Slideshare หรืออาจจะเป็น talk ที่บริษัทเคยไปพูดตามที่ต่างๆครับ</li></ul><p>นอกจากนี้คำถามยอดฮิตอันหนึ่งคือ <strong>“Tell me about yourself” หรือ “Tell me about Machine Learning project …..”</strong></p><p>trick ที่ผมชอบใช้ตอบคำถามแนวนี้คือ STAR method เพราะจะเป็นการสิ่อสารที่มีประสิทธิภาพสูงสุดครับ ห้ามมองข้ามเด็ดขาดครับ</p><h3>STAR method</h3><p><strong>Situation </strong>— describe a situation or problem that you have encountered.</p><p><strong>Task </strong>— describe the task that the situation required or your ideas for resolving the problem.</p><p><strong>Action </strong>— describe the action you took, obstacles that you had to overcome.</p><p><strong>Results </strong>— highlight outcomes achieved.</p><p>ดูเพิ่มเติมได้ที่นี่ครับ <a href="https://www.badenochandclark.lu/en-gb/candidates/advice/star-method/">https://www.badenochandclark.lu/en-gb/candidates/advice/star-method/</a></p><p>อย่างที่เห็นครับว่า กว่าจะได้งานที นั้นมีหลายขั้นตอนมาก ต้องบอกก่อนว่าผมไม่ได้ งานทุกที่นะครับ ไม่เทพขนาดนั้น โดน reject มาแล้วมากมาย <strong>ผมตกรอบ onsite interview มาแล้วถึง 4 ที่ </strong>แต่ทุกครั้งที่ โดน reject ผมไม่เคยยอมแพ้หรือท้อ ทุกครั้งที่โดน reject ผมจะได้เรียนรู้เสมอและได้พัฒนาตัวเองต่อไปครับ เช่น โอเคเราอ่อน algo เราต้องฝึกเพิ่ม หรือ เราอ่อน A/B testing เราต้องอ่านเพิ่มด้านนี้ ดังที่เคยมีคนกล่าวไว้ว่า</p><blockquote>Every failure is a step to success</blockquote><p>จนสุดท้ายผมได้งาน Data Scientist หนึ่งใน tech firm ที่ List ไว้ในหัวข้อแต่ขอยังไม่บอกว่าที่ไหน เพราะผมยังไม่ได้เริ่มงาน ฮ่าๆๆ</p><p>สุดท้ายนี้ใครมีข้อแนะนำหรือต้องการสอบถามอะไรเพิ่มเติม สามารถติดต่อผมได้ที่ cp626@cornell.edu ครับ :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad061010f687" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A/B testing กับ Data Science]]></title>
            <link>https://medium.com/@chawannut157/ab-testing-%E0%B8%81%E0%B8%B1%E0%B8%9A-data-science-5ee43e828ee1?source=rss-c20c5daed60d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ee43e828ee1</guid>
            <dc:creator><![CDATA[Chawannut Prommin]]></dc:creator>
            <pubDate>Sun, 01 Apr 2018 07:00:37 GMT</pubDate>
            <atom:updated>2018-04-01T08:55:04.938Z</atom:updated>
            <content:encoded><![CDATA[<p>ถ้าให้พูดถึง Data science สิ่งที่หลายๆคนนึกถึงอย่างแรกคือ Machine learning และ AI แต่มีอีกศาสตร์หนึ่งใน Data science ที่หลายๆคนไม่ค่อยพูดถึงนั่นคือ การทำ A/B testing ซึ่งเป็นอะไรที่สำคัญมาก บริษัทอย่าง Microsoft หรือ AirBnB ต่างมี data scientist ด้านนี้โดยเฉพาะ ซึ่งเรียกแตกต่างกันไป แต่ส่วนใหญ่จะเรียกว่า Inference data scientist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KY7ej47h8g2KwkvHb8ajAA.jpeg" /></figure><h3><strong>A/B testing คืออะไร ?</strong></h3><p>หลักการของการทำ A/B testing คือการทำ experiment เพื่อทดสอบว่า treatment ที่เราต้องการทดสอบนั้นมี impact มากน้อยเท่าไร ยกตัวอย่างเช่น ถ้าหากเราเป็นเจ้าของ Website E-commerce แห่งหนึ่ง แล้วเราต้องการทดสอบว่า การเพิ่มปุ่ม “Filter” ในหน้าเลือกสินค้านั้นเกิดผลลัพธ์กับบริษัทอย่างไรบ้าง เราจะทำ A/B testing เพื่อตอบคำถามนี้</p><p>โดยกระบวนการคร่าวๆของ A/B testing แบ่งออกได้ตามด้านล่างนี้</p><ul><li>Split user เป็น A และ B group โดย A group จะเป็นกลุ่มที่ไม่ได้รับ treatment (ในที่นี้คือไม่เห็นปุ่ม filter) ในขณะที่ B group จะเห็นปุ่ม Filter</li><li>กำหนด metric ที่ต้องการ วัดผล เช่น เราจะวัด Conversion Rates / revenue per user เทียบกันระหว่าง A และ B group</li><li>Implement experiment</li><li>Statistical analysis เพื่อสรุปผล</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*11WnxWB17dMcI6y6HFskKA.jpeg" /></figure><p>ความยากของ A/B testing คืออะไรบ้าง ?</p><ul><li>เราจะ Split user อย่างไรเพื่อให้ไม่มี selection bias ยกตัวอย่างเช่นถ้าเรา split user โดยให้ ลูกค้าประจำของเราไปอยู่ group B หมด ในขณะที่ user ที่เลิกเข้าเวปเราไปแล้วอยู่ group A ….ผลลัพธ์ออกมายังไง B group ก็ชนะแน่ๆถ้าเราทำแบบนี้ …….การทำแบบนี้ทำให้ experiment ของเรา bias และสรุปผลไม่ได้ การทำ A/B testing ที่ดี เราควรจะ randomize user ไปใน กลุ่ม A และ B (สามารถใช้ <a href="https://en.wikipedia.org/wiki/Hotelling%27s_T-squared_distribution">Hotelling’s T-squared test</a> ช่วยเช็คได้)</li><li>เราต้องใช้ขนาดตัวอย่างเท่าไรถึงจะสรุปผลได้ ?</li><li>เราจะวัด Metric อะไรบ้าง ถ้า short term ก็จะเป็น clicks / conversion rate แต่ถ้า long term ก็จะเป็น customer life time value</li><li>ถ้าผลลัพธ์ออกมาดี เราควรจะ implement เลยหรือไม่ ?</li></ul><h3><strong>ทำไม A/B testing ถึงสำคัญ ?</strong></h3><blockquote><strong>Small Changes can have a Big Impact to Key Metrics</strong></blockquote><p>A/B testing เป็นสิ่งที่สำคัญมากๆ และ <strong>เกิด impact กับบริษัทได้จริงๆ </strong>ตัวอย่างที่ชัดๆเลยจาก Microsoft คือการเปลี่ยนสี font ของ search engine ตามรูปด้านล่าง</p><p>ผลลัพธ์ก็คือ เพิ่มรายได้ให้บริษัทเกือบ สิบล้าน ดอลลาร์ !!</p><p>(ถึงแม้ผลสรุปจะฟังดูไม่น่าเชื่อถือ แต่ทางทีมงานได้ลองทดสอบกับกลุ่มตัวอย่างที่ใหญ่ขึ้นและได้ข้อสรุปแบบเดิม !)</p><p><strong>ซึ่งถ้าเราลองคิดดู การเปลี่ยนสี แค่นี้ทำยากไหม ? คำตอบคือ cost of implementation นั้นน้อยมาก แต่เกิดประโยชน์มหาศาล !</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*GHNyFoQ6o3-k3WrIoC2INg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lwuHTTZBERbFxLWiuChEfg.jpeg" /></figure><p>ตัวอย่างจาก Microsoft อื่นๆที่ <strong>Small Changes can have a Big Impact to Key Metrics</strong></p><ul><li>การกดลิ้งในเวปแล้วขึ้น tab ใหม่ ทำให้ engagement เพิ่มขึ้น</li><li>การมีปุ่ม “Discount coupon” หน้า checkout เวลาซื้อของทำให้ conversion rate ลดลงใน short term (เพราะคนจะไปหาส่วนลดแทนที่จะกดซื้อทันที) แต่ใน long term ไม่มีผลมากนัก (ถ้าลูกค้าอยากได้สินค้าจริงๆ ก็จะกลับมา ถึงแม้หาส่วนลดไม่ได้)</li></ul><h3>ตัวอย่างข้อผิดพลาดเวลาทำ A/B Testing</h3><ol><li><strong>เลือก Metric ผิด</strong></li></ol><p>ตัวอย่าง classic หนึ่งซึ่งมา paper ของ Stanford (<a href="http://ai.stanford.edu/~ronnyk/ExPThinkWeek2009Public.pdf">http://ai.stanford.edu/~ronnyk/ExPThinkWeek2009Public.pdf</a>)</p><p>พูดถึง เวปไซต์ Bing ซึ่งเป็น search engine ของ Microsoft ได้ทำ A/B testing เพื่อทดสอบว่าการเพิ่ม feature ใหม่ใน search engine เกิดผลลัพธ์อย่างไรบ้าง</p><h4>และเมื่อผลลัพธ์ออกมาทางทีมงานพบว่า revenue per user เพิ่มขึ้นถึง 30% !!!</h4><p>ถ้า experiment ของเราเกิดผลลัพธ์แบบนี้ และคุณเป็น data scientist คุณจะทำอย่างไร ? …….. implement เลยใช่หรือไม่ ? ผลลัพธ์ดีขนาดนี้ !</p><h4><strong>แต่ๆๆ กฏข้อแรกของการทำ A/B testing คือ ถ้าเราพบอะไรที่ “ Too good too be true” ให้ assume ไว้เลยว่า ส่วนใหญ่ ผลลัพธ์นั้นจะไม่จริงเสมอไป สิ่งนี้เรียกว่า Twyman’s law</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*8PhyJpH6lS7HJ8YQMMq0lA.jpeg" /></figure><p>พอทางทีมงาน Bing ได้ลองตรวจสอบการ implement ของระบบจึงพบว่า A/B testing นั้นได้ถูก implement แบบผิดๆ …. อธิบายได้ง่ายๆก็คือ เกิด bug ทำให้ search result ไม่ดี ทำให้คนต้อง search มากขึ้นกว่าปกติ และมีโอกาสที่คนจะคลิก ads มากตามจึงทำให้ revenue per user สูงขึ้น</p><p>แล้วเราจะแก้ปัญหานี้อย่างไร ?</p><p>คำตอบก็คือเราต้องเลือก metric ให้เหมาะสมกับสิ่งที่เราต้องการจะ test</p><p>ถ้า search engine เราดีขึ้นจริง…… user ควรจะใช้เวลาน้อยลงในการ search หาสิ่งที่ต้องการ …………ดังนั้น <strong>session per user ควรจะลดลง</strong></p><p><strong>metric </strong>นี้คือ metric ที่เหมาะสมมากกว่า revenue per user เพราะ วัดสิ่งที่เราต้องการจาก experiment ได้จริงๆ</p><p>(ในทางปฎิับัติ เรามักจะวัด หลายๆ metric เพื่อให้เห็นภาพรวมของผลลัพธ์ที่เกิดขึ้นแต่ make final decision ด้วย metric ตัวเดียว)</p><h3><strong>2. Peaking at data</strong></h3><p>Peaking at data คืออะไร เพื่อให้เข้าใจง่ายเรามาลองดูตัวอย่างด้านล่าง</p><p>สมมติว่าเราวัด revenue per user ของ A และ B group และได้ผลลัพธ์ในแต่ละวันตามด้านล่างนี้ พร้อมทั้งทำ T-test เพื่อดูว่า significant หรือไม่</p><p><strong>วันที่ 1:</strong> A group = $15 ……..B group = $20 — -&gt; T-test -&gt; <strong>significant</strong></p><p><strong>วันที่ 2:</strong> A group = $15 ……..B group = $19 — -&gt; T-test -&gt; <strong>significant</strong></p><p><strong>วันที่ 3</strong>: A group = $17 ……..B group = $20— -&gt; T-test -&gt; <strong>significant</strong></p><p>….</p><p><strong>วันที่ 20:</strong> A group = $20 ……..B group = $21— -&gt; T-test -&gt; <strong>not significant</strong></p><p>(ตัวเลขด้านบนเป็นการรวมแบบ cumulative)</p><p>คำถามก็คือ ถ้าเราต้องทำ test โดยใช้ T-test เราจะ run test วันไหน …..</p><p>ถ้าเรารันวันแรก เราจะพบว่าผลลัพธ์ significant พร้อมสรุปว่า กลุ่ม B ดีกว่าทันที แต่ถ้าเรารันวันที่ 20 เราจะพบว่า ทั้งสองกลุ่มไม่ต่างกัน !!</p><ul><li>คำตอบที่ถูกต้องก็คือ เราควรจะกำหนดขนาดตัวอย่างล่วงหน้า เช่น เราจะ ทำ T- test ก็ต่อเมื่อ กลุ่ม A มี User ครบ 1000 คน และกลุ่ม B ครบ 1000 คน (ซึ่งคำนวณได้จากการทำ power analysis) เมื่อ user ครบแล้ว เราจึง รัน test ในตอนนั้นเพื่อสรุปผล โดยในระหว่างนั้นเราจะไม่ แอบ ทำ t-test โดยเด็ดขาด หรือเรียกว่าเราจะไม่ peak at data นั่นเอง</li><li>แล้วถ้าเรา รัน T-Test ทุกวัน มันผิดอย่างไร ? คำตอบก็คือ เรากำลังทำ multiple comparison ซึ่งเป็นปัญหาอย่างหนึ่งของวงการทาง สถิติ การใช้ threshold p-value ที่ 0.05 นั้นจะเชื่อถือไม่ได้อีกต่อไป</li></ul><p>เพื่อให้เห็นภาพชัดๆ ผมลองทำ simulation ตาม ด้านล่างนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQx72BjdNr_mm3doV-jLQA.jpeg" /></figure><p>โดยการทำ simulation นี้เราจะสมมติว่าเรารู้ว่า กลุ่ม A และ B มาจาก distribution อะไร (แต่ในโลกความจริงเราไม่รู้…. เราทำ simulation เพื่อให้ดูความเป็นไปได้ที่จะเกิดขึ้น)</p><p>ภาพด้านบน เราได้ generate user A และ B group มาจาก normal distribution เหมือนกันทั้งสองกลุ่ม <strong>(ดังนั้น การทดลองนี้ ควรจะสรุปว่าทั้งสองกลุ่มเหมือนกัน)</strong></p><p>หลังจากนั้นเราได้รัน t-test ทุกวัน โดยในแต่ละวันเรามี user จาก A และ B group เข้ามาใหม่ โดยทำแบบนี้ 50 วันแล้ว plot p-value ที่เราได้จากการทำ t-test แต่ละวัน ออกมาตามด้านบน</p><p>สิ่งที่เราเห็นได้ในที่นี้คือ <strong>ในช่วง 10 วันแรก มีโอกาสที่เราทำ T-test ออกมาแล้ว ได้ผลลัพธ์ significant ออกมา ! ทั้งๆที่ สองกลุ่มนี้มาจาก distribution แบบเดียวกันทุกอย่าง !</strong></p><h3>แล้วถ้าเรา peak at data และทำ t-test ทุกวันจะแก้ปัญหานี้อย่างไร</h3><p>คำตอบก็คือยิ่่งเรา peak at data เรายิ่งต้องลด threshold ของเราลง</p><p>เช่น</p><ul><li>ทำ multiple comparison แต่ แทนที่จะใช้ alpha = 0.05 เราใช้ alpha = 0.05/n โดย n คือจำนวนครั้งที่ เรา peak at data (หรือจำนวนครั้งที่เรารัน t-test) อีกทางเลือกหนึ่งคือการทำ Bonferroni correction</li></ul><p>ข้อเสียของ สองวิธีข้างต้นคือ threshold ใหม่ของเราจะ conservative มากและมีโอกาสน้อยที่เราจะพบกับ significant result วิธีที่ modern มากขึ้นคือ การ control false discovery rate ซึ่งจะไม่ขอพูดถึงในตอนนี้</p><p>อีกวิธีที่แก้ปัญหานี่ได้คือการทำ simulation เพื่อ กำหนด threshold ของแต่ละวันให้แตกต่างออกไป เช่นวันแรกๆ จะมี threshold ที่ค่อนข้างสูงกว่าวันหลังๆ (ซึ่งที่ Airbnb ทำแบบนี้) การทำแบบนี้ ข้อดีคือเราสามารถทำ experiment ได้เร็วมากขึ้นไม่ต้องรอแบบวิธีแรก</p><p>โดยสรุป มีสามวิธีที่เราสามารถทำได้</p><ul><li>คำนวณ sample size ล่วงหน้า จาก power analysis และรอจนได้ sample size ครบที่ต้องการจึง run test (T-test / Proportion test …etc)</li><li>รัน test ทุกวัน แต่ต้องใช้ multiple comparison เพื่อเปลี่ยน significant threshold</li><li>ทำ simulation เพื่อกำหนด threshold ของแต่ละวัน</li></ul><p>ถ้าหากใครสนใจด้านนี้สามารถอ่านเพิ่มเติมได่จาก paper นี้ครับ</p><p><a href="http://www.exp-platform.com/Documents/2014%20experimentersRulesOfThumb.pdf">http://www.exp-platform.com/Documents/2014%20experimentersRulesOfThumb.pdf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ee43e828ee1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Bayesian Structural Time Series Model to Analyze Cryptocurrencies.]]></title>
            <link>https://medium.com/@chawannut157/using-bayesian-structural-modelling-to-analyze-cryptocurrencies-d08b6069284c?source=rss-c20c5daed60d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d08b6069284c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Chawannut Prommin]]></dc:creator>
            <pubDate>Sun, 14 Jan 2018 22:37:21 GMT</pubDate>
            <atom:updated>2018-01-15T03:48:41.411Z</atom:updated>
            <content:encoded><![CDATA[<p>There are many cryptocurrencies out there. According to CoinMarketCap, there are over 1,037 different types of cryptocurrencies. Let’s say you want to analyze all the cryptocurrencies data. How would you analyze them? The simplest way is to use simple correlation, but this is not an ideal way to do it as we might find spurious correlations and might end up with many high correlated pairs. Instead, in this post we will focus on variable selection method to analyze cryptocurrencies data. Why this is important? This is because all the relations can be used as extra predictors to enhance the prediction of one cryptocurrency in addition to variables like trend, seasonality or news data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*CE2fUD2X7SMdNhVYYK4xjQ.png" /></figure><p>Consider an example where we want to predict unemployment rate, we can use trend of search terms from Google as regressors in the model. As part of the work done at Google shown in <a href="http://www.unofficialgoogledatascience.com/2017/07/fitting-bayesian-structural-time-series.html">here</a>, the problem is that there are millions of search terms e.g. “office of unemployment near me” or “how to file the unemployment form”. Variable selection method like <strong>Lasso </strong>will help us choose which search term will improve the prediction of the unemployment rate. However, Lasso regression is derived by using <strong>Laplace distribution</strong> as a prior on the coefficients. The result gives us sparse solution, <strong>but on the mode of the posterior.</strong> The figure below explain what I just said.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aKD19PCO2xS-uBx8Ot3eWg.png" /><figcaption>Sparse solution is at the mode of the posterior. That’s we are making one single decision to include or exclude the variable. (Figure from STEVEN L. SCOTT tutorial)</figcaption></figure><p>You can also check my blog post <a href="https://medium.com/@chawannut157/two-other-ways-to-construct-ridge-regression-732edb620c4c">here </a>on how we can construct <strong>Ridge regression</strong> by introducing prior on the coefficients. This is similar to Lasso but with different prior. Traditional variable selection methods are making <strong>“one single decision”</strong> e.g. which variable to use and which variable not to use in the model. What if we don’t want to be limited by one single decision ? but want to include each variable with different probability…. Yes, that’s right ….we are thinking like a Bayesian now !</p><p>In Bayesian structural modelling, <strong>spike and stab prior (a mixture of Gaussian with low and high variance) </strong>is used to do variable selection. Since there’s no closed-form, Gibbs sampling is then used to do inference for the posterior distribution. (I won’t go over the detail of Bayesian structural modelling, but <a href="http://www.unofficialgoogledatascience.com/2017/07/fitting-bayesian-structural-time-series.html">here </a>is a good place to start)</p><p>Without going through the maths, let’s look at an example when we apply this method to cryptocurrency data. Note that here I will analyze only the top 10 cryptocurrencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*FFTKqn253tq6RC1CaRFOUQ.png" /></figure><p>The figure above shows the result for the coin “<strong>ADA</strong>”. We can interpret the chart as follows: over 90% of the time <strong>XRP </strong>is used as regressor in the model (excluding burn in period) to predict <strong>ADA </strong>while <strong>MIOTA, OMG </strong>and <strong>TRX </strong>are used less than 10% of the time in the model.</p><p>If we repete the same process but for every top 15 crytocurrencies and then visualize the result as a network graph with inclusion probablity. Below is the result. Note that vertice represents crytocurrency, the size of edge represent inclusion probability and direction of the arrow indicates whether the cryptocurrency is used as a response or regressor e.g. ADA -&gt; XRP means we used ADA to predict XRP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*TIa8Wa2w-15zFTXWsodPVA.png" /><figcaption>ฎ</figcaption></figure><p>Ok…that’s a fancy visualization but a bit hard to see. To make it easier to see, let’s filter only inclusion probability (p) &gt;0.025</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*_szJuUdvZVANhZRqNu9gjw.png" /></figure><p>So here we see that if we want to predict <strong>ETH</strong>, it would be wise to include <strong>OMG </strong>data in our model and vice versa. On the other hand, using other cryptocurrency as regressors in the model does not help much for <strong>BCH. </strong>Also, it is interesting to see that although we have many possible pairs, only 10 pairs of the result have inclusion probability greater than 10%. This means each cryptocurrency is quite independent and using the price of other cryptocurrency won’t help much with the prediction except for the pairs we found here.</p><p>Another question that you might have is that how Bayesian structural modelling make a prediction if we are not making “single decision” to choose variable but represent variable selection with inclusion probability. Well, if you took Bayesian classes before, you will know that this can be done via the <a href="https://en.wikipedia.org/wiki/Posterior_predictive_distribution">predictive distribution formula </a>which can be viewed as averaging over many models and hence we are less likely to overfit.</p><p><strong>Take away</strong></p><p>Here are the top 10 pairs in detail. If you want to analyze the price it would be helpful to focus on these pairs. For modelling purpose, using bsts method with other variables like trend, seasonality and news data will likely to improve the model. Also, in my opinion, we can use bsts model as one candidate and do ensemble method with other models like neural network and gbm which tend to result in high predictive performance in practice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*PO_7YkKXCRDqjHhg7fNsLg.png" /></figure><p><strong>Resources</strong></p><ul><li><a href="https://arxiv.org/pdf/math/0505633.pdf">Spike and slab prior</a></li><li><a href="https://sites.google.com/site/stevethebayesian/googlepageforstevenlscott/course-and-seminar-materials/bsts-bayesian-structural-time-series">Bsts tutorial</a></li></ul><p>R code for this analysis can be found <a href="https://github.com/dunkchawannut/bitcoin_bstm">here</a></p><p>Also, special thanks to <a href="https://www.kaggle.com/jessevent/all-crypto-currencies">great work of jvent</a> for building an easy to use R package to scrape all the crytocurrency data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d08b6069284c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Will Avenger Infinity War surpass Titanic ?]]></title>
            <link>https://medium.com/@chawannut157/will-avenger-infinity-war-surpass-titanic-633638c9ac24?source=rss-c20c5daed60d------2</link>
            <guid isPermaLink="false">https://medium.com/p/633638c9ac24</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[movies]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Chawannut Prommin]]></dc:creator>
            <pubDate>Fri, 05 Jan 2018 21:32:44 GMT</pubDate>
            <atom:updated>2018-01-12T04:25:35.308Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*3yG0iO1pNYdF0iMDn6FOTw.png" /><figcaption>Robert Downey JR vs Leonardo DiCaprio</figcaption></figure><p>I don’t know if you do this like me but every time new superhero movie came out, I have to keep checking its revenue on the box office website. According to Box Office, Titanic made <strong>$2,187.5 M </strong>worldwide while recent successful movies like <a href="http://www.boxofficemojo.com/movies/?id=starwars7.htm">Star Wars: The Force Awakens</a><strong> ($2,068.2 M ) </strong>and <a href="http://www.boxofficemojo.com/movies/?id=avengers11.htm">Marvel’s The Avengers</a> <strong>($1,518.8 M) </strong>still can’t surpass Titanic. This makes me wonder that can we predict how much revenue each promising movies will make and what are some interesting insights we can learn from the data? This is not an easy question to answer, but given that in the last couple of years the movie industry seem to focus on producing great movie trailer and the quality of trailer is significantly better than trailer in the early 2000s (If you don’t believe me watch the trailer of<a href="https://www.youtube.com/watch?v=eOrNdBpGMv8&amp;t=1s"> <em>Marvel: The avenger</em></a> compared to <a href="https://www.youtube.com/watch?v=6ZfuNTqbHE8&amp;t=9s"><em>Marvel: Infinity War</em></a>), I believe we should be able to answer this question.</p><p>To do this, I used Python to scrape all the top 719 movies from <a href="http://www.boxofficemojo.com/alltime/world/">Box Office,</a> IMDB and Youtube then do the analysis in R to answer the following questions.</p><ul><li><strong>What’s the relation between total Youtube view and total revenue? Is it true that success on the key metrics like view, like ,dislike and comment give us a big hint on how much money will the film make?</strong></li><li><strong>What makes a great movie ? and does a great movie a profitable one ?</strong></li><li><strong>Putting everything together, will Avenger Infinity War surpass Titanic ?</strong></li></ul><p>Code is available at the end of this article.</p><p><strong>TLDR — From the current model, we expect the movie to make around $1,522.5 M to $1,728.5 M which is less than Titanic. However, the predictive interval of 2 standard deviation still cover the number that is greater than Titanic. Hence, it’s hard to say right now but as we have more data we should be able to get more accurate answer.</strong></p><h3><strong>1. Youtube View vs Total Revenue.</strong></h3><p>Let’s first look at total view on Youtube vs total revenue. To do this, I sum all the metrics from the top three result of the search query “Movie + Trailer” and measure the correlation. There are several kind of correlation measurement. The most common one is <a href="https://en.wikipedia.org/wiki/Pearson_correlation_coefficient">Pearson correlation coefficient</a> which measures “linear” relation between variables. However, as you can see from the picture from Wikipedia below that it does not measure non-linear relationship i.e. if there is a curvature relationship then Pearson correlation will fail to capture such pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*AGlyf2S-SKH-jjHlySMuLA.png" /><figcaption>Pearson correlation measures only “linear” correlation</figcaption></figure><p>Instead, we use <a href="https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient">Spearman rank correlation</a> which does not limit itself to linear relationship but measures monotonic relationship. For example, the figure below shows that Pearson correlation is 0.88 while Spearman rank correlation is 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*nO4Gv-0fc2RIGGnFa7rP0w.png" /></figure><p>It should be note that correlation is not causation. Casual inference is actually a very interesting area. If you are interested in casual inference, I highly recommend the <a href="https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/">book </a>by Miguel Hernan and Jamie Robins from Harvard school of public health which provides a comprehensive detail on this topic.</p><p>Now let’s look at the data. On the left plot below the Y axis is revenue and X axis is the log scaled of total Youtube view, it seems that both metrics are not very correlated (correlation &lt; 0.3). This is probably because watching trailer on Youtube is not what most people did in the early 2000s. So we decide to split the year variable to “before 2010” and “after 2010” as Google Trend indicates that 2010 is when the search index for Youtube is relatively the same as the present day. As you can see on the right, after 2010 both metric tend to me more correlated (The correlation is at 0.2 before 2010 and at 0.5 after 2010). From the modelling perspective, there might be an interaction effect between year and total view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tOy8eDll8hOmRPwWtdHzoQ.png" /></figure><p>Furthermore, we split the plot by genre as shown below. As you can see, different genre has different correlation. For example, the correlation for action is at 0.41 , action/adventure is at 0.51 and drama is at 0.35. This means most superhero (action) should pay attention on the performance of its trailer while movie like Superbad (comedy) should not worry too much on this measurement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kNKg0ZRDuGAPYR_Da9BMA.png" /></figure><p>As a side note, the genre is based on how Box Office categorized each movie. Here are some examples of each category.</p><p><strong>Action </strong>: Fast and Furious , Mission Impossible and The Expendable <strong>Action/Adventure</strong>: X-men , Avenger, Wonder Woman</p><h3>2) What makes a great movie ? and does a great movie a profitable one ?</h3><p>The movie rating on famous site like IMDB , Rotten Tomatoes and Metacritics are quite reliable for consumer. However, there are some discrepancy between the ratings as found in <a href="https://medium.freecodecamp.org/whose-reviews-should-you-trust-imdb-rotten-tomatoes-metacritic-or-fandango-7d1010c6cf19">here</a>. In summary,</p><blockquote>The verdict: use Metacritic’s metascore</blockquote><blockquote>All in all, I recommend checking the metascore whenever you are looking for a movie rating. Here’s how it works, and its downsides.</blockquote><blockquote>In a nutshell, the metascore is a weighted average of many reviews coming from reputed critics. The Metacritic team reads the reviews and assigns each a 0–100 score, which is then given a weight, mainly based on the review’s quality and source. You can find more about their rating system <a href="http://www.metacritic.com/faq#item11">here</a>.</blockquote><p>but sadly at the time of writing this article I only scraped data from IMDB. So I will stick to IMDB here.</p><p><strong>Rating vs Genre</strong> : We use box plot to show movie rating from IMDB for different genre of movies. It’s interesting to see that some genre tend to receive lower rating than the others e.g. Family Comedy receive the lowest rating. While the median rating of each genre is relatively the same, Drama has the highest rating … off course ! people love drama.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y2_xVdo_XQrx9UVi41PJOw.png" /></figure><p><strong>But does receiving a good review make it a profitable movie ?</strong></p><p>Again, we plot movie rating and revenue and then split it by genre (Y axis = revenue and X axis = rating). It seems that different genre has different correlation but <strong>action </strong>and <strong>action/adventure</strong> has the strongest correlation between movie rating and total revenue. So, this is a big hint to the movie industry on how well each movie will perform based on the fans rating on IMDB. This is important because if we can accurately predict the revenue of each movie then marketing spending can be efficiently optimized e.g. if a Action Comedy movie receive a low rating at the first week then that shouldn’t worry the movie maker too much on the revenue as the data suggest that the correlation between both variable are relatively low in this genre.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MmvkewJtQBiflBR8tK-S7g.png" /></figure><p>Interestingly, I came across this <a href="http://variety.com/2017/film/news/rotten-tomatoes-scores-dont-impact-box-office-study-finds-1202554546/">article </a>saying that</p><blockquote>“ Yves Bergquist, director of the Data &amp; Analytics Project at USC’s Entertainment Technology Center, analyzed film data going back to 2000 and came to a conclusion quite counter to the conventional wisdom gaining steam in Hollywood: “<a href="http://variety.com/2017/film/news/star-wars-last-jedi-rotten-tomatoes-user-ratings-bots-skewed-1202647473/">Rotten Tomatoes</a> scores have never played a very big role in driving box office performance, either positively or negatively,” he wrote in a <a href="https://medium.com/@ybergquist/cognitive-hollywood-part-1-data-shows-box-office-economics-in-turmoil-411a4b22f858">blog post published on Medium</a>.”</blockquote><p>One take away is that rating from fans (IMDB) is probably more important than critics when analyzing the revenue of movie. (BUT note that sometime the majority of fans might agree with critics !)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*XjDjDlVuHJse-PTd_UUO5w.png" /></figure><h3><strong>3) Putting everything together, will Avenger Infinity War surpass Titanic ?</strong></h3><p>I did not write all the explanatory analysis here but if you want to do that you can play around with the data set and let me know if you find anything interesting. Here’s the summary of the data set that we will using.</p><ol><li><strong>Revenue</strong>: Total revenue from the box office.</li><li><strong>View</strong>: Total Youtube view.</li><li><strong>Like/Dislike/Comment</strong>: Percentage of each out of view.</li><li><strong>Genre:</strong> Genre of movie from the box office website.</li><li><strong>Distributor</strong></li><li><strong>Rating</strong></li><li><strong>Budget</strong></li><li><strong>Year</strong></li><li><strong>IMDB Rating</strong></li></ol><p>Here’s a peak at the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eUAzTsesfPI6Mci94QPtRQ.png" /></figure><p>I used scalable machine learning from H2O to run four different algorithms: <strong>GBM , Random Forest , Elastic Net and Deep learning</strong>. Here’s the RMSE result from 10 folds cross validation (the lower the better).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*WeU8jZar3yXK0aI1NxQBiA.png" /></figure><p>It seems that Deep Learning is over-fitting and Random Forest give the best result from the 10 folds cross validation method. That’s the range of RMSE is around $160 M to $250 M.</p><p>Here’s the variable importance from Random Forest. As you can see, the top three important variables are genre , Budget and total Youtube View.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*bxTFOD8l6IZUlGrN18t5mA.png" /></figure><p>OK….. So now if we make a prediction for <em>Avenger: Infinity War </em>what would be the result? Before we do that, I think it is important to mention the term “information leakage” here since you may notice that when we built the model we already have <strong>all </strong>the data. For example, movie rating is quite stable now comparing to the rating of Infinity War which we don’t know yet. The same for total view on Youtube which is quite stable for the movies in the training set but not for our target movie. One way to solve this problem is to add another layer of the model where we predict the <strong>“final” rating</strong> and <strong>“final” view</strong>, so that we can use it in the model. However, for simplicity, here we will assume a simple assumption that the rating of the movie will be relatively the same as the last two Avenger, the total view on Youtube will use the growth rate from the last Avenger movie and apply it to current view of Infinity War.</p><p>Actually this is a problem that many practitioners will experience at some point of time during their careers. If anyone has suggestion on how to deal with this problem, please leave it in the comment.</p><p>With that being said, here’s our inputs.</p><ol><li><strong>Revenue = ?</strong></li><li><strong>View = </strong>Apply last Avenger growth rate to current total view.</li><li><strong>Like/Dislike/Comment = </strong>Use current percentage</li><li><strong>Genre:</strong> Action / Adventure</li><li><strong>Distributor: </strong><a href="http://www.boxofficemojo.com/studio/chart/?studio=buenavista.htm">Buena Vista</a></li><li><strong>Rating: </strong>PG-13</li><li><strong>Budget: </strong>According to the news, it will be around $400 M</li><li><strong>Year: </strong>2018</li><li><strong>IMDB Rating: </strong>assume to be (8.1 + 7.4)/2 = 7.75</li></ol><p>So after putting everything together the 1 standard deviation predictive interval is<strong> </strong>at <strong>($1,522.5 M , $1,728.5 M)</strong>. So, according to our model here we are quite certain that <em>Marvel: Infinity War </em>will make more revenue than the first Avenger movie, but will it surpass Titanic ? Since Titanic made about $2,100 M, which is something in the 2.x standard deviation interval. So, it’s possible but it’s hard to say at the moment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*MTvnlydpy0lO6Otj9h0sLg.png" /></figure><p>However, after the movie is in the theater for a week we should have a better sense of what it will accomplish. For example, we could build the model which takes the <em>revenue after 1 week </em>as a new feature and do the prediction on the final revenue again. This model should give more accurate result as there’s more information at that point of time.</p><p>What’s next ?</p><ul><li>More variable like marketing spending and revenue by origin might improve the model.</li><li>Do NLP on the movie script seems to be a fun project to do and could give us more interesting insight e.g. <a href="http://www.vulture.com/2014/01/wolf-of-wall-street-counting-all-the-curse-words.html">all variation of f word is used 506 times over “The <strong>Wolf of Wall Street’s</strong>”</a></li></ul><p>Code in Python can be found here.</p><p><a href="https://github.com/dunkchawannut/python_movie_analysis">https://github.com/dunkchawannut/python_movie_analysis</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=633638c9ac24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Two ways to construct Ridge regression.]]></title>
            <link>https://medium.com/@chawannut157/two-other-ways-to-construct-ridge-regression-732edb620c4c?source=rss-c20c5daed60d------2</link>
            <guid isPermaLink="false">https://medium.com/p/732edb620c4c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Chawannut Prommin]]></dc:creator>
            <pubDate>Wed, 27 Dec 2017 01:50:07 GMT</pubDate>
            <atom:updated>2018-01-15T07:36:56.052Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*Xeb2WkUKrw6btpRhmAe0_Q.png" /></figure><p>Two ways to construct Ridge regression.</p><p>I guess you already know that Ridge regression is one type of regression where we penalize coefficients of the model by using L2 norm. As opposed to L1, L2 does not lead to sparsity but adding some bias to the model is mainly done to avoid over-fitting. Most resources talk about Ridge regression by adding extra term to the cost function. To get more intuition of Ridge regression, this post will concern with two ways where we can construct Ridge regression from both frequentist and Bayesian perspective.</p><ol><li><strong>Frequentist approach: start with normal regression.</strong></li></ol><p>In standard regression, we minimize the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/154/0*vJS4XGZPTAnm3RxQ." /></figure><p>which lead to the following solution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/145/0*JrW8_r6HGss0-JjK." /></figure><p>Now note that we will have a problem when the multiplication of the first two term is not invertible. One way to fix this problem is to add extra rows to the design matrix X. If we write out the new design matrix X in term of block matrix, this will be</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/121/0*_adLUyRGPeN3SZXB." /></figure><p>Intuitively speaking, we extend the original design matrix with diagonal matrix which has number of rows equal the total number of columns in the original design matrix (p is total number of feature in the original design matrix with the first column for the intercept. Hence, there are p+1 columns in the original design matrix)</p><p>Here is an example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/0*6jTP0hfzQprTiwkf." /><figcaption>1</figcaption></figure><p>We almost done here ! Since we only change the design matrix, the formula to find the best betas is still the same. We just do the math here and get</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/0*_5H8pH8NsDCtScP8." /></figure><p>and then the final solution is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/0*KiQ6UmFn7dieenFn." /></figure><p>So, by using this trick we manage to avoid non-invertible problem since the term inside the inverse here is always invertible (To be precise, it is positive definite and invertible.)</p><p><strong>2. Bayesian approach.</strong></p><p>One main different between frequentist and Bayesian is that frequentist believe that the “real” solution is fixed. That is we want to estimate betas which are fixed and unknown…..but wait! ….why do we have standard error in the regression model then if beta are fixed ?…. This is because the “true” model is fixed but the “sample” (or data) we get to find beta are random. As a result, each time we run regression with different sample (data), the estimated betas will be different.</p><p>Mathematically speaking, the “true” model is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/96/0*y40t6KhBSOitYQgt." /></figure><p>We treat beta as fixed and the error term as random. That is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/97/0*LSHHRJnEE3VlglL6." /></figure><p>While in the Bayesian approach, we make one more assumption on the coefficients to make it “random”. To do this, we assume it’s normally distributed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/109/0*gVa_RrwJ_HP57P_3." /></figure><p>The goal here will be finding the posterior distribution of Beta given the data (Y). For mathematical convenient, we will derive the following term instead (which can be shown to be equivalent of the posterior)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/75/0*6kxwK6p_tPoS41ou." /></figure><p>One nice way to derive this is to first consider the joint distribution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/78/0*DPIi6P6rZL_CujZd." /></figure><p>and then use the<a href="https://onlinecourses.science.psu.edu/stat505/node/43"> conditional Gaussian distribution</a> to find the posterior distribution.</p><p>I won’t go into detail here but doing it this way is a lot easier than the “completing the square” method which is quite tedious. One thing to keep in mind here is that the posterior is a distribution. So, in order to get the point estimate, we will use expectation of the posterior distribution. After some math, the expectation of the posterior distribution will be.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/0*VxB1ycDmPDQzpYpQ." /></figure><p>which is exactly the same as the first approach !</p><p>So we just show two non standard ways where you can get the ridge regression solution. Some might be wondering that can we do the same but for Lasso regression (L1)?……Yes we can !! by using Laplace distribution on the beta instead of normal distribution (and the math will me more convoluted.)</p><p>Hope this is useful !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=732edb620c4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>