This is a draft cheat sheet. It is a work in progress and is not finished yet.
Available Models / Parameters
names(getModelInfo()) # available models
modelLookup(model='gbm') # parameters
|
Cross validation
fitControl <- trainControl(
method = "cv",
number = 3)
|
Data preparation
# for xgboost
train_mm <- as.data.frame(model.matrix(log_SalePrice ~ .-1,
data=subset(train, select = -c(SalePrice, Id))))
label_train <- train$log_SalePrice
|
|
|
Parameter tuning
gbm.grid <- expand.grid(n.trees=c(2000, 5000),
shrinkage=c(0.01, 0.005),
n.minobsinnode = c(10,50),
interaction.depth=c(7,10))
|
Fit model
model_gbm<-train(x = train[,vars], y = train[,'log_SalePrice'],
method = 'gbm',
trControl = fitControl,
tuneGrid = gbm.grid)
|
Model evaluation
print(model_gbm)
plot(model_gbm)
model_gbm$bestTune
model_gbm$results
varImp(object = model_gbm)
predict(model_gbm, test_data)
|
|