Identifikasi dan maknai pendorong churn

Machine Learning untuk Pemasaran dengan Python

Karolis Urbonas

Head of Analytics & Science, Amazon

Memplot aturan pohon keputusan

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 untuk Pemasaran dengan Python

Menafsirkan bagan pohon keputusan

Visualisasi pohon keputusan

Machine Learning untuk Pemasaran dengan Python

Koefisien regresi logistik

  • Regresi logistik menghasilkan koefisien beta
  • Dapat dimaknai sebagai perubahan log-odds churn untuk kenaikan fitur 1 unit

Model Regresi Logistik

Machine Learning untuk Pemasaran dengan Python

Mengambil koefisien regresi logistik

  • Koefisien dapat diambil dengan metode .coef_ pada instance Logistic Regression yang sudah di-fit
    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 untuk Pemasaran dengan Python

Transformasi koefisien regresi logistik

  • Log-odds sulit ditafsirkan
  • Solusi: hitung eksponen dari koefisien
  • Ini memberi perubahan pada odds untuk kenaikan fitur 1 unit
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 untuk Pemasaran dengan Python

Makna koefisien yang ditransformasikan

Koefisien Regresi Logistik

Machine Learning untuk Pemasaran dengan Python

Ayo berlatih!

Machine Learning untuk Pemasaran dengan Python

Preparing Video For Download...