이탈 요인 식별 및 해석

Python으로 배우는 마케팅용 Machine Learning

Karolis Urbonas

Head of Analytics & Science, Amazon

의사결정나무 규칙 시각화

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)
Python으로 배우는 마케팅용 Machine Learning

의사결정나무 차트 해석

의사결정나무 시각화

Python으로 배우는 마케팅용 Machine Learning

로지스틱 회귀 계수

  • 로지스틱 회귀는 베타 계수를 반환합니다
  • 특징이 1 단위 증가할 때 이탈의 로그 오즈 변화로 해석합니다

로지스틱 회귀 모델

Python으로 배우는 마케팅용 Machine Learning

로지스틱 회귀 계수 추출

  • 적합된 LogisticRegression 인스턴스의 .coef_로 계수를 추출할 수 있습니다
    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.        ]])
Python으로 배우는 마케팅용 Machine Learning

로지스틱 회귀 계수 변환

  • 로그 오즈는 해석이 어렵습니다
  • 해결: 계수의 지수를 계산합니다
  • 그러면 특징이 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']))
Python으로 배우는 마케팅용 Machine Learning

변환된 계수의 의미

로지스틱 회귀 계수

Python으로 배우는 마케팅용 Machine Learning

실습해 봅시다!

Python으로 배우는 마케팅용 Machine Learning

Preparing Video For Download...