<?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 PHATCHARAPON SOOKMEE on Medium]]></title>
        <description><![CDATA[Stories by PHATCHARAPON SOOKMEE on Medium]]></description>
        <link>https://medium.com/@phatcharapon_sookmee?source=rss-8883be75d490------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*OJ-dw7dKrn9x5ygQ.jpg</url>
            <title>Stories by PHATCHARAPON SOOKMEE on Medium</title>
            <link>https://medium.com/@phatcharapon_sookmee?source=rss-8883be75d490------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 15:28:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@phatcharapon_sookmee/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[Begin Machine Learning using Scikit-Learn Library]]></title>
            <link>https://medium.com/cscmu-undergrad-seminar/begin-machine-learning-using-scikit-learn-library-bb047401f706?source=rss-8883be75d490------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb047401f706</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[PHATCHARAPON SOOKMEE]]></dc:creator>
            <pubDate>Fri, 10 Apr 2020 12:18:11 GMT</pubDate>
            <atom:updated>2020-04-10T12:18:11.792Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>“ถ้าหากคิดว่าการเริ่มต้นทำ Machine Learning นั้นเป็นเรื่องที่ยากและไม่รู้จะเริ่มต้นยังไงดี บทความนี้จะมานำเสนอวิธีการที่จะสามารถทำ Machine Learning ได้ง่ายๆ ด้วย Scikit- Learn Library กันครับ”</em></blockquote><h4>Scikit-Learn เครื่องมือสำหรับพัฒนา Machine Leaning ด้วยภาษา Python ที่รวบรวม algorithmในการประมวลผลข้อมูลไว้มากมาย ทั้งแบบ unsupervised และ supervised learning ถือว่าเป็น Machine Learning Library ที่นิยมและใช้งานง่ายมากที่สุดในตอนนี้เลยก็ว่าได้</h4><p>ต่อไปเรามาเล่าถึงประวัติของการสร้าง Scikit-Learn Library กันสักนิดนะครับ</p><blockquote>สำหรับ Scikit-Learn Library นั้น ถูกพัฒนาขึ้นในปี 2007 โดยเป็นโครงการของ Google Summer of Code ของคุณ David Cournapeau ซึ่งต่อมาในปีเดียวกันเองคุณ Matthieu Brucher ก็ได้เริ่มโปรเจคนี้อีกที ซึ่งก็ถือเป็นส่วนหนึ่งของวิทยานิพนธ์ของเขาด้วย ต่อมาในปี 2010 คุณ Fabian Pedregosa คุณ Gael Varoquaux, คุณ Alexandre Gramfort และคุณ Vincent Michel จาก INRIA (Institut National de Recherche en Informatique et en Automatique หรือ National Institute for Research in Computer Science and Control) ได้เข้ามาเป็นผู้นำของโครงการและเปิดตัว Scikit-Learn Livrary ครั้งแรกต่อสาธารณชนตั้งแต่วันที่ 1 กุมภาพันธ์ 2010 นับตั้งแต่นั้นมาก็มีปล่อยให้ผู้ใช้ทั่วโลกได้ใช้งานกันและก่อให้เกิดการประยุกต์ใช้หลายงานในปัจจุบัน</blockquote><h4>Main Features of Scilit-Learn Library ประกอบด้วย</h4><ul><li><strong>Classification</strong> เป็นการทำงานในลักษณะของการจำแนก แยกประเภทคลาสของข้อมูล (label) ที่สอดคล้องกันเข้าด้วยกัน เช่น การจำแนกประเภทของดอก iris ในแต่ละสายพันธ์ เป็นต้น</li></ul><figure><img alt="ที่มา https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.mathworks.com%2Fhelp%2Fstats%2Fexamples%2Fclassification.html&amp;psi" src="https://cdn-images-1.medium.com/max/560/1*oyOewfR1M2J5fqYip5LSrw.png" /><figcaption>รูปที่ 1 แสดงการ Visualization ของกาทำ Iris classification</figcaption></figure><ul><li><strong>Regression </strong>มีลักษณะการทำงานโดยคลาสของข้อมูลจะอยู่ในรูปจำนวนจริง ไม่ได้แบ่งเป็นคลาสอย่างชัดเจนเหมือนการทำ classification จากนั้นก็ต้องคำนวณเพื่อหาแนวโน้มของข้อมูลและทำนายผลลัพธ์จากข้อมูลแนวโน้มที่ได้</li></ul><figure><img alt="ที่มา https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FRegression_analysis&amp;psig=AOvVaw0WsuQkrC8d58" src="https://cdn-images-1.medium.com/max/1024/1*87aMm1RRoaxS4Sy8Q-XMDg.png" /><figcaption>รูปที่ 2 เส้นสีแดงแสดงแนวโน้มการทำนายผลลัพธ์ของโมเดลที่ี่เกิดจากการคำนวณของ regression algorithm</figcaption></figure><ul><li><strong>Clustering </strong>เป็นอีกขั้นตอนของการทำ Machine Learning ในรูปแบบการจับกลุ่มให้กับข้อมูลที่ไม่มีคลาสของข้อมูลมาให้ โดยอาศัยการสุ่มหาการกระจุกตัวของข้อมูลที่มากสุดเพื่อกำหนดให้เป็นกลุ่มของข้อมูล 1 กลุ่ม เช่น การจัดกลุ่มข้อมูลของดอก iris โดยทำการปิดคลาสของข้อมูลไว้ เพื่อแยกดอก iris แต่ละสายพันธ์ออกจากกัน เป็นต้น</li><li><strong>Semi-Supervised Learning </strong>เป็นอีกหนึ่งเทคนิคที่น่าสนใจ หากว่าเกิดมีข้อมูลที่ต้องการทำ classification แต่ข้อมูลที่จะใช้ในการ train โมเดลนั้นมีน้อยมากนอกนั้นเป็นข้อมูลที่ไม่มีคลาสของข้อมูล ซึ่งมีปริมาณที่มากกว่าจึงเกิดปัญหา class imbalance ขึ้น การใช้วิธีนี้จะเป็นการนำข้อมูลในส่วนที่น้อย ๆ มาช่วยเพิ่มข้อมูลให้มีใช้ในการทำนายมากขึ้น โดยใช้ข้อมูลจากส่วนที่ไม่มีคลาสของข้อมูลนั่นเอง</li><li><strong>Feature Extraction</strong> เป็นการสกัดเอาข้อมูลที่มีความสำคัญต่อการใช้ train model เพื่อเพิ่มประสิทธิภาพของโมเดล และลดระยะเวลลาในการ train ข้อมูลทั้งหมด</li><li><strong>Dimensional Reduction</strong> เป็นขั้นตอนการลดมิติของข้อมูลจากมิติสูงๆ ไปยังมิติต่ำ ๆ โดยกำจัดข้อมูลฟีเจอร์ที่มีนัยสำคัญน้อยออกไป ในกรณีที่มีฟีเจอร์ของข้อมูลมาก ๆ จะมีเห็นผลได้ชัดเจน และสามารถทำให้ประมวลผลข้อมูลได้รวดเร็วมากขึ้น และลด space complexity อีกด้วย</li><li><strong>Evaluation Metrics</strong> เป็นการวัดประสิทธิภาพของโมเดล เพื่อทดสอบว่าโมเดลมีความสามารถในการทำนายผลลัพธ์ออกมามากน้อยเพียงใด ในตัว Scikit-Learn มีมาตรวัดหลากหลายตัวให้เลือกใช้วัดประสิทธิภาพของโมเดลที่แตกต่างกันออกไป</li></ul><h4>ประโยชน์ของ Scikit- Learn Library</h4><ul><li>เป็นเครื่องมือที่ง่ายและมีประสิทธิภาพสำหรับการวิเคราะห์ข้อมูลเชิงทำนาย</li><li>ทุกคนสามารถใช้งาน library นี้ได้ และสามารถประยุกต์ใช้้กับงานที่หลากหลายได้เช่นกัน</li><li>library สร้างขึ้นบน Numpy SciPy และ matplotlib ที่เรียกได้ว่าเป็นเคื่องมือที่ช่วยให้การเขียนโค้ด Machine Learning ทำได้สะดวกมากยิ่งขึ้น</li><li>ตัว library เป็น open source library สามารถใช้งานในเชิงพาณิชย์ได้อย่างถูกกฎหมาย เนื่องจากมี BSD license ที่อนุญาตให้บริษัท third party สามารถแจกจ่ายต่อได้ไม่ว่าวัตถุประสงค์ใดก็ตาม แต่ห้ามใส่ชื่อองค์กรที่ผลิต หรือชื่อผู้ร่วมพัฒนาเข้าไปในงานเพื่อใช้ในการโฆษณาส่งเสริมสินค้า</li></ul><h4>วิธีการติดตั้ง Scikit-Learn Library ลงบน Computer PC</h4><ul><li>อันดับแรกติดตั้ง Python version 64 bit โดยสามารถโหลดได้จาก <a href="https://www.python.org/">https://www.python.org</a></li><li>จากนั้นเปิด command line ขึ้นมาแล้วพิมพ์คำสั่งด้านล่าง เพื่อทำการติดตั้ง Scikit -Learn</li></ul><pre>$ pip install -U scikit-learn</pre><ul><li>เพื่อเป็นการตรวจสอบว่ามีการติดตั้ง Scikit-Learn Library ไว้ในเครื่องแล้ว สามารถพิมพ์คำสั่งด้านล่างเพื่อทำการตรวจสอบได้</li></ul><pre>$ python -m pip show scikit-learn</pre><ul><li>เพื่อตรวจสอบ Package ที่ถูกติดตั้งใน Scikit-Learn Library สามารถพิมพ์คำสั่งด้านล่างเพื่อทำการตรวจสอบได้</li></ul><pre>$ python -m pip freeze</pre><h4>ตัวอย่างการใช้งาน Scikit-Library เบื้องต้น</h4><blockquote>การใช้งาน Scikit-Learn Library ในการทำ machimne Learning สามารถใช้ได้ทั้ง Unsupervised Learning หรือการเรียนรู้แบบไม่มีผู้สอน และ Supervised Learning หรือการเรียนรู้แบบมีผู้สอน ทั้งนี้สามารถศึกษารายละเอียดเพิ่มเติมได้<a href="https://towardsdatascience.com/supervised-vs-unsupervised-learning-14f68e32ea8d">ที่นี่</a></blockquote><p>สำหรับการทำ<strong> Supervised Learning</strong> จะมีขั้นตอนการทำตาม step flow ด้านล่างนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*qJndL51MmacX5LPZF5pf4g.jpeg" /><figcaption>รูปที่ 3 แสดงขั้นตอนการทำงานของ Supervised Learning</figcaption></figure><ul><li>เริ่มจากข้อมูล Input จะถูกแบ่งออกเป็น training set และ test set แต่ละ set จะประกอบไปด้วย data โดยทั่วไปกำหนดให้เป็น X และ labels ซึ่งเป็นคลาสของ data ในแต่ละ record กำหนดให้เป็น y</li><li>นำ training data และ test data ซึ่งเป็นผลเฉลย เข้าไป train ใน model พร้อมกัน จากนั้นจะได้ model ที่ train มาเสร็จเรียบร้อย</li><li>นำ model ที่ผ่านการ train มาทดสอบหรือมาทำการทำนายกับข้อมูล test data ที่ไม่มีผลเฉลย จากนั้นนำผลที่ได้จากการทำนายของ model มาเทียบกับ test labels เพื่อวัดประสิทธิภาพการทำนายของ model</li></ul><p>สำหรับ <strong>Unsupervised Learning</strong> จะมีขั้นตอนดังนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*qf4EXauF7mRDedR3MjO-yQ.jpeg" /><figcaption>รูปที่ 4 แสดงขั้นตอนการทำงานของ Unsupervised Learning</figcaption></figure><ul><li>เริ่มจากข้อมูล input ที่ไม่มีผลเฉลยหรือไม่มี label จะถูกแบ่งออกเป็น 2 ชุด ได้แก่ Training Data และ Test Data</li><li>จากนั้นนำ Training Data เข้าไป train ในโมเดลของ unsupervised model ซึ่งส่วนมากจะเป็นการทำงานในลักษณะของจัดกลุ่มของข้อมูล</li><li>Model ที่ได้จากการ train จะนำมา predict กับ test data เพื่อทำนายผลลัพธ์ของข้อมูลในลำดับต่อไป</li></ul><h4>Scikit-Learn for Supervised Learning</h4><blockquote>ตัวอย่าง code ต่อไปนี้แสดงการทำงานของ supervised machine learning โดยทำการสร้างโมเดลเพื่อใช้ทำนายผลลัพธ์ ทั้งนี้จะทำการ classify ดอก iris ใน 3 สายพันธุ์ ซึ่ง Scikit-Learn Library จะมี iris dataset ไว้ให้เรียกใช้ด้วย</blockquote><pre>from sklearn import datasets</pre><pre>iris = datasets.load_iris() # request to load iris dataset.</pre><pre>X = iris.data # assign X variable to be data.</pre><pre>y = iris.target # assign y variable to bee target of data.</pre><pre>from sklearn.model_selection import train_test_split # for seprate data and target into training set and test set.</pre><pre>X_train,X_test,y_train,y_test = train_test_split(x,y,test_size=.5) # assign splited data into variables.</pre><p>ขั้นต่อไปก็จะทำการ Build model โดยในที่นี้จะสาธิตโดยใช้ K Nearest Neighbors (<em>k-</em>NN) model สำหรับใช้ learn training set ดังต่อไปนี้</p><pre>from sklearn.neighbors import KNeighborsClassifier</pre><pre>knn = KNeighborsClassifier(n_neighbors = 7) # load model into knn variable.</pre><pre>knn.fit(X_train,y_train) # training model with training set.</pre><pre>predictions = knn.predict(X_test) # make a preiction with using predict method for test How well the model predicted with the test set?</pre><pre>from sklearn.metrics import accuracy_score # importing evaluator for check with fit model.</pre><pre>print(accuracy_score(y_test,predictions)) # to show an accuracy.</pre><p>Output of Accuracy for <em>k-</em>NN model is 0.9467 %</p><h4>Scikit-Learn for Unsupervised Learning</h4><blockquote>ตัวอย่าง code ต่อไปนี้แสดงการทำ unsupervised Machine Learning หรือการเรียนรู้แบบไม่มีผู้สอน ไม่มีผลเฉลย โดยจะใช้ iris dataset เช่นเดิม แต่จะตัดผลเฉลย หรือ target ออกไป</blockquote><pre>from sklearn import decomposition</pre><pre>pca = decomposition.PCA(n_components=2) # Data Dimensional reduction for ease to predict.</pre><pre>pca.fit(iris.data)</pre><pre>X = pca.transform(iris.data) # New data after PCA operation.</pre><pre># Visualize X in scatter plot in รูปที่ 5.</pre><pre>import matplotlib.pyplot as plt</pre><pre>plt.scatter(X[:, 0], X[:, 1], c=iris.target)</pre><pre>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*T5vDyj7APEdfskcVxhPjhg.png" /><figcaption>รูปที่ 5 แสดงการกระจายตัวของข้อมูล หลังการทำ PCA</figcaption></figure><pre>from sklearn.cluster import KMeans # Clustering model for unsupervised learning.</pre><pre>km = KMeans(3) # set parameter number of cluster to 3.</pre><pre>km.fit(X)</pre><pre>print(km.cluster_centers_) # to show the center of each cluster that is calculated by model</pre><pre># to visualize center of cluster overplot on X data in รูปที่ 6.</pre><pre>plt.scatter(X[:, 0], X[:, 1], c=iris.target)</pre><pre>plt.scatter(km.cluster_centers_[:, 0], km.cluster_centers_[:, 1], marker=’o’, s=100)</pre><pre>plt.show()</pre><p>Output of center in each cluster</p><p>[[-2.64241546 0.19088505]<br> [ 0.66567601 -0.3316042 ]<br> [ 2.34652659 0.27393856]]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*zt9lSokoR4HFB_MkElp2Bw.png" /><figcaption>รูปที่ 6 แสดงศูนย์กลางของ cluster ที่ได้จาก model</figcaption></figure><blockquote>นอกจากนี้แล้วยังมี <strong>TensorFlow </strong>ซึ่งถือว่าเป็นเครื่องมือที่ได้รับความนิยมมากเช่นกันสำหรับการทำ Machine Learning โดยจะเน้นหนักไปที่การทำ Deep Learning เป็นหลัก ซึ่งพัฒนาขึ้นบนภาษา python เช่นกัน สามารถศึกษารายละเอียดเพิ่มเติมเกี่ยวกับ TensorFlow ได่<a href="https://medium.com/tensorflow">ที่นี่</a></blockquote><p>ที่มา:</p><ul><li><a href="https://scikit-learn.org/stable/index.html">https://scikit-learn.org/stable/index.html</a></li><li><a href="https://scikit-learn.org/stable/modules/clustering.html#k-means">https://scikit-learn.org/stable/modules/clustering.html#k-means</a></li><li><a href="https://www.slideshare.net/odsc/andreasmullermachine-learningwithscikitlearnod">https://www.slideshare.net/odsc/andreasmullermachine-learningwithscikitlearnod</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb047401f706" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cscmu-undergrad-seminar/begin-machine-learning-using-scikit-learn-library-bb047401f706">Begin Machine Learning using Scikit-Learn Library</a> was originally published in <a href="https://medium.com/cscmu-undergrad-seminar">CSCMU Undergrad Seminar</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>