모델 가정 검증 및 예측

R로 배우는 Machine Learning 기반 마케팅 분석

Verena Pflieger

Data Scientist at INWT Statistics

비례 위험 가정 검정

testCPH1 <- cox.zph(fitCPH1)
print(testCPH1)
                              rho   chisq        p
gender=Male               0.0317   1.884 1.70e-01
SeniorCitizen=Yes         0.0587   6.507 1.07e-02
Partner=Yes               0.0752  10.116 1.47e-03
Dependents=Yes            0.0131   0.314 5.75e-01
StreamMov=NoIntServ      -0.0448   3.588 5.82e-02
StreamMov=Yes             0.0827  12.174 4.85e-04
PaperlessBilling=Yes      0.0180   0.611 4.34e-01
PayMeth=CreditCard(auto)  0.0253   1.198 2.74e-01
PayMeth=ElektCheck       -0.0427   3.427 6.41e-02
PayMeth=MailedCheck      -0.0851  13.069 3.00e-04
MonthlyCharges            0.1268  25.778 3.83e-07
GLOBAL                        NA 217.172 0.00e+00
R로 배우는 Machine Learning 기반 마케팅 분석

Partner의 비례 위험

plot(testCPH1, var = "Partner")

R로 배우는 Machine Learning 기반 마케팅 분석

MonthlyCharges의 비례 위험

plot(testCPH1, var = "MonthlyCharges")

R로 배우는 Machine Learning 기반 마케팅 분석

검정에 관한 일반적 유의사항

  • cox.zph() 검정은 보수적임
  • 관측 수에 민감함
  • 위반의 심각도는 경우마다 다름
R로 배우는 Machine Learning 기반 마케팅 분석

비례 위험 가정 위반 시 대처 방법

  • 층화 분석
fitCPH2 <- cph(Surv(tenure, churn) ~ MonthlyCharges +
                 SeniorCitizen + Partner + Dependents + 
                 StreamMov + Contract,
               stratum = "gender = Male",
               data = dataSurv, x = TRUE, y = TRUE, surv = TRUE)

  • Time-dependent coefficients
R로 배우는 Machine Learning 기반 마케팅 분석

모델 검증

validate(fitCPH1, 
         method = "crossvalidation", 
         B = 10, pr = FALSE)
      index.orig training   test optimism index.corrected  n
R2        0.2277   0.2279 0.2277   0.0002          0.2276 10
                            ...
R로 배우는 Machine Learning 기반 마케팅 분석

특정 시점의 이탈하지 않을 확률

oneNewData <- data.frame(gender = "Female",
                             SeniorCitizen = "Yes",
                             Partner = "No",
                             Dependents = "Yes",
                             StreamMov = "Yes",
                             PaperlessBilling = "Yes",
                             PayMeth = "BankTrans(auto)",
                             MonthlyCharges = 37.12)
str(survest(fitCPH1, newdata = oneNewData, times = 3))
List of 5
 $ time   : num 3
 $ surv   : num 0.905
 $ std.err: num 0.0136
 $ lower  : num 0.881
 $ upper  : num 0.93
R로 배우는 Machine Learning 기반 마케팅 분석

신규 고객의 생존 곡선

plot(survfit(fitCPH1, newdata = oneNewData))

R로 배우는 Machine Learning 기반 마케팅 분석

이탈까지의 예상 시간 예측

print(survfit(fitCPH1, newdata = oneNewData))
Call: survfit(formula = fitCPH1, newdata = oneNewData)

      n  events  median 0.95LCL 0.95UCL 
   5311    1869      65      53      72 
R로 배우는 Machine Learning 기반 마케팅 분석

학습 내용 정리

생존 분석에서 배운 내용
학습 내용 고객 재직 기간 시각화
이벤트 발생 시간 모델링 및 영향 요인 추출
모델 검증 방법
예측 방법
모델에서 배운 내용
학습 내용 고령 시민일 경우 이탈 확률이 23% 증가함
월 요금 1단위 증가 시 이탈 위험이 약 1% 감소함
R로 배우는 Machine Learning 기반 마케팅 분석

이제 여러분 차례입니다!

R로 배우는 Machine Learning 기반 마케팅 분석

Preparing Video For Download...