ระบุและตีความปัจจัยที่ขับเคลื่อนการเลิกใช้บริการ

Machine Learning สำหรับการตลาดด้วย Python

Karolis Urbonas

Head of Analytics & Science, Amazon

การพล็อตกฎของ decision tree

from sklearn import tree
import graphviz

exported = tree.export_graphviz( decision_tree=mytree, out_file=None, feature_names=cols, precision=1, class_names=['Not churn','Churn'], filled = True)
graph = graphviz.Source(exported) display(graph)
Machine Learning สำหรับการตลาดด้วย Python

การตีความแผนภาพ decision tree

การแสดงภาพ decision tree

Machine Learning สำหรับการตลาดด้วย Python

สัมประสิทธิ์ของ logistic regression

  • Logistic regression คืนค่าสัมประสิทธิ์ beta
  • ตีความได้ว่าเป็นการเปลี่ยนแปลงใน log-odds ของการเลิกใช้บริการเมื่อ feature เพิ่มขึ้น 1 หน่วย

โมเดล Logistic Regression

Machine Learning สำหรับการตลาดด้วย Python

การดึงสัมประสิทธิ์ของ logistic regression

  • ดึงสัมประสิทธิ์ได้ด้วยเมธอด .coef_ บน instance ของ Logistic Regression ที่ฝึกแล้ว
    logreg.coef_
    
array([[ 0.        ,  0.09784772,  0.        , -0.03935476, -0.82068131,
        -0.41231806, -0.14319622, -0.01746504, -0.41830733,  0.        ,
         0.        ,  0.07138468,  0.        ,  0.        ,  0.        ,
         0.        , -0.41424363, -0.59539021,  0.        ,  0.18846525,
         0.        , -0.90766135,  0.90151342,  0.        ]])
Machine Learning สำหรับการตลาดด้วย Python

การแปลงสัมประสิทธิ์ของ logistic regression

  • Log-odds ตีความได้ยาก
  • วิธีแก้ — คำนวณ exponent ของสัมประสิทธิ์
  • จะได้การเปลี่ยนแปลงใน odds เมื่อ feature เพิ่มขึ้น 1 หน่วย
coefficients = pd.concat([pd.DataFrame(train_X.columns),
               pd.DataFrame(np.transpose(logit.coef_))], 
               axis = 1)
coefficients.columns = ['Feature', 'Coefficient']

coefficients['Exp_Coefficient'] = np.exp(coefficients['Coefficient'])
coefficients = coefficients[coefficients['Coefficient']!=0] print(coefficients.sort_values(by=['Coefficient']))
Machine Learning สำหรับการตลาดด้วย Python

ความหมายของสัมประสิทธิ์ที่แปลงแล้ว

สัมประสิทธิ์ของ Logistic Regression

Machine Learning สำหรับการตลาดด้วย Python

มาฝึกกันเถอะ!

Machine Learning สำหรับการตลาดด้วย Python

Preparing Video For Download...