Identificar e interpretar fatores de churn

Machine Learning para Marketing em Python

Karolis Urbonas

Head of Analytics & Science, Amazon

Plotando regras da árvore de decisão

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 para Marketing em Python

Interpretando o gráfico da árvore de decisão

Visualização de árvore de decisão

Machine Learning para Marketing em Python

Coeficientes da regressão logística

  • Regressão logística retorna coeficientes beta
  • Podem ser interpretados como a mudança no log-odds de churn associada a 1 unidade de aumento na feature

Modelo de Regressão Logística

Machine Learning para Marketing em Python

Extraindo coeficientes da regressão logística

  • Os coeficientes podem ser extraídos com o método .coef_ na instância ajustada de 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 para Marketing em Python

Transformando coeficientes da regressão logística

  • Log-odds é difícil de interpretar
  • Solução: calcular o expoente dos coeficientes
  • Isso dá a mudança nas odds associada a 1 unidade de aumento na feature
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 para Marketing em Python

Significado dos coeficientes transformados

Coeficientes da Regressão Logística

Machine Learning para Marketing em Python

Vamos praticar!

Machine Learning para Marketing em Python

Preparing Video For Download...