<?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 Wongprnk. on Medium]]></title>
        <description><![CDATA[Stories by Wongprnk. on Medium]]></description>
        <link>https://medium.com/@focus8wp?source=rss-5e40de64e763------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Seo9IBpsFgSRCQC9YInKEg@2x.jpeg</url>
            <title>Stories by Wongprnk. on Medium</title>
            <link>https://medium.com/@focus8wp?source=rss-5e40de64e763------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 22:01:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@focus8wp/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[การพยากรณ์การยกเลิกบริการของลูกค้า : การวิเคราะห์และการสร้างโมเดลจากชุดข้อมูล Customer Churn…]]></title>
            <link>https://medium.com/@focus8wp/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%9E%E0%B8%A2%E0%B8%B2%E0%B8%81%E0%B8%A3%E0%B8%93%E0%B9%8C%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%A2%E0%B8%81%E0%B9%80%E0%B8%A5%E0%B8%B4%E0%B8%81%E0%B8%9A%E0%B8%A3%E0%B8%B4%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%82%E0%B8%AD%E0%B8%87%E0%B8%A5%E0%B8%B9%E0%B8%81%E0%B8%84%E0%B9%89%E0%B8%B2-%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%A7%E0%B8%B4%E0%B9%80%E0%B8%84%E0%B8%A3%E0%B8%B2%E0%B8%B0%E0%B8%AB%E0%B9%8C%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87%E0%B9%82%E0%B8%A1%E0%B9%80%E0%B8%94%E0%B8%A5%E0%B8%88%E0%B8%B2%E0%B8%81%E0%B8%8A%E0%B8%B8%E0%B8%94%E0%B8%82%E0%B9%89%E0%B8%AD%E0%B8%A1%E0%B8%B9%E0%B8%A5-customer-churn-f5250cb7624d?source=rss-5e40de64e763------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5250cb7624d</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Wongprnk.]]></dc:creator>
            <pubDate>Sat, 14 Dec 2024 01:22:26 GMT</pubDate>
            <atom:updated>2024-12-14T01:22:26.231Z</atom:updated>
            <content:encoded><![CDATA[<h4>การพยากรณ์การยกเลิกบริการของลูกค้า : การวิเคราะห์และการสร้างโมเดลจากชุดข้อมูล Customer Churn Dataset</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*haNlRq3BLBuvopKf88Psjg.png" /><figcaption>Customer Churn Dataset by Muhammad Shahid Azeem</figcaption></figure><p>ลองจินตนาการถึงระบบสมาชิกที่คุณใช้อยู่ในชีวิตประจำวัน ไม่ว่าจะเป็น Netflix, Spotify, หรือบริการส่งอาหารที่คุณชื่นชอบ เคยสงสัยไหมว่า ทำไมบางครั้งเพื่อนของคุณหรือแม้แต่คุณเอง เลือกที่จะเลิกใช้บริการเหล่านั้น?</p><p>สมมุติว่า “ถ้าคุณเป็นเจ้าของธุรกิจที่มีระบบสมาชิก และพบว่ามีลูกค้าสมัครบริการเพิ่มขึ้นทุกเดือน แต่รายได้กลับไม่เติบโตตามที่คาดไว้ คุณจะทำอย่างไร?” ปัญหานี้อาจมาจากการยกเลิกบริการของลูกค้า (Customer Churn) ซึ่งเป็นหัวข้อที่มีผลกระทบโดยตรงต่อการเติบโตของธุรกิจและความสำเร็จในระยะยาว</p><blockquote>บทความนี้มีจุดมุ่งหมายเพื่อเรียนรู้การสร้างโมเดลเพื่อพยากรณ์การยกเลิกบริการ พร้อมกับเสนอแนวทางลดอัตราการยกเลิกบริการผ่านข้อมูลที่วิเคราะห์ได้</blockquote><p>ที่มาของชุดข้อมูลที่ใช้ในบทความนี้คือ “<a href="https://www.kaggle.com/datasets/muhammadshahidazeem/customer-churn-dataset">Customer Churn Dataset</a>” จาก Kaggle ซึ่งรวบรวมข้อมูลเกี่ยวกับผู้ใช้บริการ เช่น อายุ, เพศ, ระยะเวลาการใช้งาน, ความถี่ในการใช้งาน, จำนวนการโทรขอความช่วยเหลือ, การชำระเงินล่าช้า, ประเภทการสมัครสมาชิก, ระยะเวลาของสัญญา, ยอดใช้จ่ายทั้งหมด และการใช้งานครั้งล่าสุด</p><h4>อธิบายข้อมูล การเตรียมข้อมูล</h4><pre>df  = pd.read_csv(&quot;customer_churn_dataset-training-master.csv&quot;,index_col=0)<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W6sEbaP4tJ6GtV_r8wylQw.png" /></figure><p>ข้อมูลในครั้งนี้เป็นข้อมูลแบบ Tabular มีขนาด 440833 rows × 11 columns</p><blockquote><strong><em>Categorical data</em></strong></blockquote><blockquote><strong>Age<em> </em></strong><strong>Gender</strong> <strong>Subscription Type </strong><strong>Contract Length </strong><strong>Churn</strong></blockquote><blockquote><strong><em>Numerical data</em></strong></blockquote><blockquote><strong>Tenure </strong><strong>Usage Frequency </strong><strong>Support Calls </strong><strong>Payment Delay </strong><strong>Total Spend</strong></blockquote><blockquote><strong>Last Interaction</strong></blockquote><h4>Data Cleaning</h4><p>เริ่มต้นการทำความสะอาดข้อมูลด้วยการจัดการกับค่าสูญหาย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-8NkhU1Nzo2J76QtK4P80w.png" /></figure><pre>df[df.isna().any(axis=1)]<br>df.dropna(inplace=True)</pre><p>จัดการกับค่าที่ซ้ำกัน(เก็บตัวแรกไว้)ด้วยคำสั่ง</p><pre>df.drop_duplicates(inplace=True,keep=&#39;first&#39;)</pre><blockquote>ค่าผิดปกติ (Outlier) คือค่าที่แตกต่างจากข้อมูลส่วนใหญ่ในชุดข้อมูลอย่างมาก</blockquote><p>วาดแผนภาพกล่องเพื่อหา ค่าผิดปกติ</p><pre>target = [&#39;Age&#39;, &#39;Gender&#39;, &#39;Tenure&#39;, &#39;Usage Frequency&#39;, &#39;Support Calls&#39;,<br>       &#39;Payment Delay&#39;, &#39;Subscription Type&#39;, &#39;Contract Length&#39;,<br>       &#39;Last Interaction&#39;]<br><br># Box plot for target variables<br>plt.figure(figsize=(12, 8))  # Adjust figure size if needed<br>pd.plotting.boxplot(df[target])<br>plt.title(&quot;Check Outliers for Target Variables&quot;)<br>plt.xlabel(&quot;Features&quot;)<br>plt.ylabel(&quot;Value&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*Glr1Y-PNj2z_lVRVR8qk6g.png" /><figcaption>Boxplot เพื่อหาค่าที่ผิดปกติ</figcaption></figure><p>ในข้อมูลชุดนี้เราไม่พบ ค่าที่ผิดปกติ ต่อไปเรามาเริ่มหา Insight ของข้อมูลกัน</p><p>เริ่มจากการดูความสัมพันธ์เชิงเส้นของชุดข้อมูล</p><pre>correlation = df.corr(method=&#39;pearson&#39;, numeric_only=True)<br>correlation</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*zPJhKKurkYolbeRMIyHvcQ.png" /><figcaption>Correlation ของแต่ละ Feature</figcaption></figure><p>จะเห็นได้ว่าการยกเลิกบริการของลูกค้าจะมีความสัมพันธ์เชิงเส้นกับ <strong><em>Support Calls </em></strong><strong><em>Total Spend </em></strong><strong><em>Payment Delay </em></strong><strong><em>Age</em></strong>ค่อนข้างสูงเราก็จะนำข้อมูลเหล่านี้มาสร้างกราฟกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBXjFe5K9tDhYBw7KixQTw.png" /><figcaption>Boxplot เพื่อแสดง Insight ของข้อมูลที่มีความสัมพันธ์กับการยกเลิกการใช้บริการ</figcaption></figure><blockquote><strong><em>0 ไม่ยกเลิกบริการ</em></strong></blockquote><blockquote><strong><em>1 ยกเลิกบริการ</em></strong></blockquote><p>จากการวิเคราะห์กราฟที่แสดงความสัมพันธ์ระหว่าง Churn กับปัจจัยต่าง ๆ พบ Insight ที่น่าสนใจได้ดังนี้:</p><ol><li><strong>จำนวนการติดต่อฝ่ายสนับสนุน (Support Calls)</strong><br>ผู้ใช้งานที่มีการติดต่อฝ่ายสนับสนุนบ่อยครั้งมีแนวโน้มที่จะเลิกใช้งาน (Churn) มากกว่าผู้ใช้งานที่ติดต่อในระดับต่ำ อาจสะท้อนถึงปัญหาที่ไม่ได้รับการแก้ไขหรือความไม่พอใจต่อบริการ</li><li><strong>ความล่าช้าในการชำระเงิน (Payment Delay)</strong><br>ผู้ที่มีการชำระเงินล่าช้ามักจะมีแนวโน้มเลิกใช้งานมากกว่า โดยเฉพาะกลุ่มที่มีความล่าช้าสูง ซึ่งอาจเป็นตัวบ่งชี้ถึงปัญหาทางการเงินหรือความไม่พอใจในบริการที่ได้รับ</li><li><strong>ค่าใช้จ่ายรวม (Total Spend)</strong><br>ผู้ที่เลิกใช้งาน มีค่าใช้จ่ายรวมต่ำกว่าผู้ที่ยังใช้งานต่อซึ่งอาจเกิดจากการที่ผู้ใช้งานเหล่านี้ไม่ได้เห็นความคุ้มค่าในบริการเมื่อเทียบกับค่าใช้จ่ายที่ต้องเสีย</li><li><strong>อายุของผู้ใช้งาน (Age)</strong><br>แม้ว่าอายุของผู้ใช้งานในทั้งสองกลุ่มจะมีการกระจายตัวใกล้เคียงกัน แต่กลุ่มที่เลิกใช้งานมักจะมีอายุเฉลี่ยสูงกว่าเล็กน้อย ซึ่งอาจเกี่ยวข้องกับลักษณะการใช้งานหรือความต้องการที่เปลี่ยนไปตามอายุ</li></ol><h4>เลือกโมเดลไหนในการทำงาน ??</h4><p>การพิจารณาความแม่นยำของโมเดลขึ้นอยู่กับตัวชี้วัดที่เหมาะสม เช่น <strong>Precision, Recall, F1-Score,<em> </em>Churn Prediction</strong></p><p><strong>RandomForestClassifier</strong></p><pre>from sklearn.ensemble import RandomForestClassifier<br><br>model = RandomForestClassifier(random_state=42)<br>model.fit(X_train, y_train)<br>y_pred = model.predict(X_test)<br>print(model.score(X_test, y_test))<br><br>classification_rep = classification_report(y_test, y_pred)<br>print(&quot;Classification Report:\n&quot;, classification_rep)<br><br>cm = confusion_matrix(y_test, y_pred)<br>disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=model.classes_)<br>disp.plot(cmap=plt.cm.Blues)<br>plt.title(&quot;Confusion Matrix for RandomForestClassifier&quot;)<br>plt.show()</pre><p>จากโมเดลนี้จะเห็นว่า ไม่ต้องปรับแต่ง hyperparameters ง่ายต่อการใช้งาน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*-VRIEjKvFaIhbxXFVDpi2g.png" /><figcaption>Classification Report แสดง Accuracy, Recall, Precision เพื่อวัดความแม่นยำของโมเดล</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*BxLc0-3aUUI1B40XWpyZSw.png" /><figcaption>Confusion Matrix ของ RandomForestClassifier</figcaption></figure><p>วิเคราะห์<strong> Confusion Matrix </strong>สำหรับ <strong>Churn Prediction</strong></p><ol><li><strong>True Positives (TP)</strong>: 56,035 ตัวอย่างที่โมเดลทำนายว่า <strong>ยกเลิกบริการ</strong> แล้วยกเลิกบริการจริง ๆ <strong>(Churn)</strong></li><li><strong>False Positives (FP)</strong>: 6,343 ตัวอย่างที่โมเดลทำนายว่า <strong>ยกเลิกบริการ</strong> แต่จริง ๆ แล้วไม่ยกเลิก <strong>(Non-Churn)</strong></li><li><strong>False Negatives (FN)</strong>: 64 ตัวอย่างที่โมเดลทำนายว่า <strong>ไม่ยกเลิกบริการ</strong> แต่จริง ๆ แล้วยกเลิก <strong>(Churn)</strong></li><li><strong>True Negatives (TN)</strong>: 38,600 ตัวอย่างที่โมเดลทำนายว่า <strong>ไม่ยกเลิกบริการ</strong> แล้วไม่ยกเลิกจริง ๆ <strong>(Non-Churn)</strong></li></ol><p><strong>MLPClassifier</strong></p><pre>from sklearn.neural_network import MLPClassifier<br><br>model = MLPClassifier(hidden_layer_sizes=(16,32,64,128),<br>                      activation=&#39;relu&#39;,<br>                      solver=&#39;adam&#39;,<br>                      alpha=0.01,<br>                      batch_size=&#39;auto&#39;,<br>                      learning_rate=&#39;adaptive&#39;,<br>                      learning_rate_init=0.01,<br>                      max_iter=150,<br>                      random_state=42,<br>                      verbose=True,<br>                     momentum=0.8)<br>model.fit(X_train, y_train)<br>y_pred = model.predict(X_test)<br><br>print(model.score(X_train, y_train))<br>print(model.score(X_test, y_test))<br><br>classification_rep = classification_report(y_test, y_pred)<br>print(&quot;Classification Report:\n&quot;, classification_rep)<br><br>cm = confusion_matrix(y_test, y_pred)<br>disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=model.classes_)<br>disp.plot(cmap=plt.cm.Blues)<br>plt.title(&quot;Confusion Matrix for MLPClassifier&quot;)<br>plt.show()</pre><p>จากโมเดลนี้จะเห็นว่า มีปรับแต่ง hyperparameters ที่อาจต้องใช้เวลาปรับแต่งมากกว่า</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*4z0APvfc3yZMcIVDCaJd5Q.png" /><figcaption>Classification Report แสดง Accuracy, Recall, Precision เพื่อวัดความแม่นยำของโมเดล</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*2qtORDMATXve5585OixoVA.png" /><figcaption>Confusion Matrix ของ MLPClassifier</figcaption></figure><p>วิเคราะห์<strong> Confusion Matrix </strong>สำหรับ <strong>Churn Prediction</strong></p><ol><li><strong>True Positives (TP)</strong>: 55,535 ตัวอย่างที่โมเดลทำนายว่า <strong>ยกเลิกบริการ</strong> แล้วยกเลิกบริการจริง ๆ <strong>(Churn)</strong></li><li><strong>False Positives (FP)</strong>: 6,330 ตัวอย่างที่โมเดลทำนายว่า <strong>ยกเลิกบริการ</strong> แต่จริง ๆ แล้วไม่ยกเลิก <strong>(Non-Churn)</strong></li><li><strong>False Negatives (FN)</strong>: 564 ตัวอย่างที่โมเดลทำนายว่า <strong>ไม่ยกเลิกบริการ</strong> แต่จริง ๆ แล้วยกเลิก <strong>(Churn)</strong></li><li><strong>True Negatives (TN)</strong>: 38,613 ตัวอย่างที่โมเดลทำนายว่า <strong>ไม่ยกเลิกบริการ</strong> แล้วไม่ยกเลิกจริง ๆ <strong>(Non-Churn)</strong></li></ol><p>จากการพิจารณาจาก หลายตัวชี้วัด <strong>Precision, Recall, F1-Scorec</strong> และ <strong>Churn Prediction</strong> เพื่อ การวัดความแม่นยำของโมเดล<strong> (Model Accuracy)</strong> ของการพยากรณ์</p><blockquote>เราเลือกใช้ <strong>RandomForestClassifier</strong> เนื่องจากโมเดลนี้ให้ <strong>F1-score</strong> สูงสุดในการระบุลูกค้าที่จะยกเลิกบริการ และ <strong>Precision </strong>กับ <strong>Recall </strong>โดยรวมแล้วก็สูงกว่า นอกจากนี้ การใช้งาน <strong>RandomForest</strong> ใช้เวลาประมวลผลน้อยกว่า <strong>Neural Network </strong>และไม่ต้องปรับแต่ง <strong>hyperparameters</strong> มากนัก จาก <strong>Churn Prediction</strong> ของการพยากรณ์ <strong>RandomForestClassifier </strong>มีความผิดพลาดโดยรวมที่น้อยกว่า <strong>MLPClassifier </strong>ทำให้เหมาะสมกับข้อมูลชุดนี้</blockquote><p>บทความนี้อธิบายถึงการวิเคราะห์ผลลัพธ์ของโมเดล <strong>Churn Prediction</strong> (การทำนายการยกเลิกบริการ) โดยเน้นที่การนำข้อมูลจาก True Positive (TP), False Positive (FP), True Negative (TN), และ False Negative (FN) มาคำนวณค่าสำคัญ เช่น <strong>Precision, Recall, </strong>และ <strong>F1-Score</strong> เพื่อวัดความแม่นยำของโมเดล และช่วยให้ธุรกิจสามารถปรับปรุงกลยุทธ์เพื่อรักษาลูกค้าได้อย่างมีประสิทธิภาพ</p><p><strong>แนวทางลดอัตราการยกเลิกบริการ (Churn Reduction)</strong></p><p><strong>1.วิเคราะห์กลุ่มลูกค้าที่มีแนวโน้มยกเลิกบริการ (High Churn Risk)</strong></p><p>ใช้โมเดล <strong>Churn Prediction</strong> เพื่อระบุลูกค้าที่มี<strong>ความเสี่ยงสูง</strong></p><p>ข้อมูลที่ควรวิเคราะห์:</p><ul><li>ระยะเวลาที่ลูกค้าใช้บริการ</li><li>ความถี่ในการใช้บริการ</li><li>ข้อมูลการร้องเรียนหรือความไม่พอใจ</li><li>ประวัติการชำระเงินหรือความล่าช้า</li></ul><p><strong>2.วิเคราะห์กลุ่มลูกค้า Non-Churn</strong></p><p>ศึกษาข้อมูลลูกค้าที่ใช้บริการต่อเนื่องเพื่อหา <strong>ปัจจัยความสำเร็จ</strong> เช่น</p><ul><li>ประเภทของบริการที่ลูกค้าชื่นชอบ</li><li>สิ่งที่ช่วยรักษาความพึงพอใจ</li></ul><p>ใช้ข้อมูลนี้ในการออกแบบ <strong>กลยุทธ์ดึงดูดลูกค้าใหม่</strong></p><blockquote><strong>สรุป : Confusion Matrix </strong>เป็นเครื่องมือสำคัญในการวิเคราะห์และพัฒนาโมเดล <strong>Churn Prediction</strong> ให้ตอบโจทย์เป้าหมายของธุรกิจในการลดการสูญเสียลูกค้า</blockquote><p>S0396 กานต์รวี ก่อเจริญ และ S0398 ณัฏฐสิทธิ์ วงษ์ปรางค์</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5250cb7624d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>