GAM pro učení nelineárních transformací

Supervised Learning in R: Regression

Nina Zumel and John Mount

Win-Vector, LLC

Zobecněné aditivní modely (GAM)

$$ y \sim b0 + s1(x1) + s2(x2) + .... $$

Supervised Learning in R: Regression

Učení nelineárních vztahů

Supervised Learning in R: Regression

gam() v balíčku mgcv

gam(formula, family, data)

family:

  • gaussian (výchozí): „klasická" regrese
  • binomial: pravděpodobnosti
  • poisson/quasipoisson: počty

Nejvhodnější pro větší datasety

Supervised Learning in R: Regression

Funkce s()

anx ~ s(hassles)
  • s() označuje proměnnou jako nelineární
  • Používejte s() u spojitých proměnných
    • S více než přibližně 10 jedinečnými hodnotami
Supervised Learning in R: Regression

Znovu: data hassles

Supervised Learning in R: Regression

Znovu: data hassles

Model RMSE (kříž. val.) $R^2$ (trénink)
Lineární ($hassles$) 7,69 0,53
Kvadratický ($hassles^2$) 6,89 0,63
Kubický ($hassles^3$) 6,70 0,65
Supervised Learning in R: Regression

GAM pro data hassles

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
Supervised Learning in R: Regression

Zkoumání transformací

plot(model)

$y$ hodnoty: predict(model, type = "terms")

Supervised Learning in R: Regression

Predikce pomocí modelu

predict(model, newdata = hassleframe, type = "response")

Supervised Learning in R: Regression

Porovnání výkonu mimo vzorek

Znalost správné transformace je ideální, ale GAM je užitečný, pokud transformace není známa

Model RMSE (kříž. val.) $R^2$ (trénink)
Lineární ($hassles$) 7,69 0,53
Kvadratický ($hassles^2$) 6,89 0,63
Kubický ($hassles^3$) 6,70 0,65
GAM 7,06 0,64
  • Malý dataset $\rightarrow$ GAM s větším šumem
Supervised Learning in R: Regression

Pojďme si procvičit!

Supervised Learning in R: Regression

Preparing Video For Download...