R로 하는 Supervised Learning: 회귀
Nina Zumel and John Mount
Win-Vector, LLC
glm(formula, data, family)
poisson 또는 quasipoissonglm(formula, data, family)
poisson 또는 quasipoissonmean(y) = var(y)를 가정var(y)가 mean(y)와 크게 다를 경우 - 준포아송 사용
bikesJan %>%
summarize(mean = mean(cnt), var = var(cnt))
mean var
1 130.5587 14351.25
var(cnt) >> mean(cnt) 이므로 $\rightarrow$ 준포아송 사용
fmla <- cnt ~ hr + holiday + workingday +
weathersit + temp + atemp + hum + windspeed
model <- glm(fmla, data = bikesJan, family = quasipoisson)
$$ pseudo R^2 = 1 - \frac{deviance}{null.deviance} $$
glance(model) %>%
summarize(pseudoR2 = 1 - deviance/null.deviance)
pseudoR2
1 0.7654358
predict(model, newdata = bikesFeb, type = "response")

카운트 모델은 RMSE로 평가할 수 있습니다
bikesFeb %>%
mutate(residual = cnt - pred) %>%
summarize(rmse = sqrt(mean(residual^2)))
rmse
1 69.32869
sd(bikesFeb$cnt)
134.2865

R로 하는 Supervised Learning: 회귀