R による Supervised Learning:回帰
Nina Zumel and John Mount
Win-Vector, LLC
$$ y \sim b0 + s1(x1) + s2(x2) + .... $$

gam(formula, family, data)
family:
大規模データに適している
anx ~ s(hassles)
s() は変数を非線形として指定するs() は連続変数に使用する
| モデル | RMSE(交差検証) | $R^2$(訓練) |
|---|---|---|
| 線形 ($hassles$) | 7.69 | 0.53 |
| 2次 ($hassles^2$) | 6.89 | 0.63 |
| 3次 ($hassles^3$) | 6.70 | 0.65 |
model <- gam(
anx ~ s(hassles),
data = hassleframe,
family = gaussian
)
summary(model)
...
R-sq.(adj) = 0.619 Deviance explained = 64.1%
GCV = 49.132 Scale est. = 45.153 n = 40
plot(model)

$y$ の値: predict(model, type = "terms")
predict(model, newdata = hassleframe, type = "response")

適切な変換が既知の場合が理想的だが、未知の場合にGAMが有効
| モデル | RMSE(交差検証) | $R^2$(訓練) |
|---|---|---|
| 線形 ($hassles$) | 7.69 | 0.53 |
| 2次 ($hassles^2$) | 6.89 | 0.63 |
| 3次 ($hassles^3$) | 6.70 | 0.65 |
| GAM | 7.06 | 0.64 |
R による Supervised Learning:回帰