Identifikace a interpretace faktorů odchodu

Machine Learning for Marketing in Python

Karolis Urbonas

Head of Analytics & Science, Amazon

Vizualizace rozhodovacího stromu

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 for Marketing in Python

Interpretace grafu rozhodovacího stromu

Vizualizace rozhodovacího stromu

Machine Learning for Marketing in Python

Koeficienty logistické regrese

  • Logistická regrese vrací beta koeficienty
  • Lze je interpretovat jako změnu log-odds odchodu při nárůstu příznaku o 1 jednotku

Model logistické regrese

Machine Learning for Marketing in Python

Extrakce koeficientů logistické regrese

  • Koeficienty lze extrahovat metodou .coef_ na natrénované instanci logistické regrese
    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 for Marketing in Python

Transformace koeficientů logistické regrese

  • Log-odds je obtížné interpretovat
  • Řešení – vypočítejte exponent koeficientů
  • Tím získáme změnu šancí při nárůstu příznaku o 1 jednotku
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 for Marketing in Python

Význam transformovaných koeficientů

Koeficienty logistické regrese

Machine Learning for Marketing in Python

Pojďme si procvičit!

Machine Learning for Marketing in Python

Preparing Video For Download...