R 중급 회귀
Richie Cotton
Data Evangelist at DataCamp
| has_churned | time_since_first_purchase | time_since_last_purchase |
|---|---|---|
| 0 | 0.3993247 | -0.5158691 |
| 1 | -0.4297957 | 0.6780654 |
| 0 | 3.7383122 | 0.4082544 |
| 0 | 0.6032289 | -0.6990435 |
| ... | ... | ... |
| 이탈 여부 | 관계 지속 기간 | 최근 활동 시점 |
glm(response ~ explanatory, data = dataset, family = binomial)
glm(response ~ explanatory1 + explanatory2, data = dataset, family = binomial)
glm(response ~ explanatory1 * explanatory2, data = dataset, family = binomial)
explanatory_data <- expand_grid(
explanatory1 = some_values,
explanatory2 = some_values
)
prediction_data <- explanatory_data %>%
mutate(
has_churned = predict(mdl, explanatory_data, type = "response")
)
| 실제: 거짓 | 실제: 참 | |
|---|---|---|
| 예측: 거짓 | 정확 | 거짓 음성 |
| 예측: 참 | 거짓 양성 | 정확 |
actual_response <- dataset$response
predicted_response <- round(fitted(mdl))
outcomes <- table(predicted_response, actual_response)
confusion <- conf_mat(outcomes)
autoplot(confusion)
summary(confusion, event_level = "second")
0.5 미만은 한 색, 0.5 초과는 다른 색으로 구분합니다.scale_color_gradient2(midpoint = 0.5)
R 중급 회귀