Boas-vindas ao curso

Machine Learning com caret em R

Max Kuhn

Software Engineer at RStudio and creator of caret

Supervised Learning

  • Pacote R caret
  • Automatiza supervised learning (também chamado de modelagem preditiva)
  • Variável-alvo

Uma flor e uma fatura marcada "past due".

Machine Learning com caret em R

Supervised Learning

  • Dois tipos de modelos preditivos
    • Classificação ⇒ Qualitativo
    • Regressão ⇒ Quantitativo
  • Use métricas para avaliar modelos
    • Mensuráveis
    • Objetivas
  • Root Mean Squared Error (RMSE) para regressão
Machine Learning com caret em R

Avaliando o desempenho do modelo

  • Comum calcular RMSE in-sample
    • Otimista demais
    • Leva a overfitting
  • Melhor calcular erro out-of-sample (no estilo do caret)
    • Simula uso real
    • Ajuda a evitar overfitting
Machine Learning com caret em R

Erro in-sample

# Fit a model to the mtcars data
data(mtcars)
model <- lm(mpg ~ hp, mtcars[1:20, ])
# Predict in-sample
predicted <- predict(
  model, mtcars[1:20, ], type = "response"
)
# Calculate RMSE
actual <- mtcars[1:20, "mpg"]
sqrt(mean((predicted - actual) ^ 2))
3.172132
Machine Learning com caret em R

Vamos praticar!

Machine Learning com caret em R

Preparing Video For Download...