Пример кода для модели Random Forest. Язык программирования R. Библиотека "Caret"
library(caret)
#RF, max SP
cv_ctrl <- trainControl(method = "repeatedcv", repeats = 10,
summaryFunction = twoClassSummary,
classProbs = TRUE)
rf.grid <- data.frame(.mtry = c(8, 12, 16))
Random.forest <- train(EXPUL_all ~ .,
data = df,
method = "rf",
metric = "Spec",
tuneGrid = rf.grid,
trControl = cv_ctrl)
test$Random.forest <- predict(Random.forest, test)
test$Random.forest_acc <- ifelse(test$Random.forest==test$EXPUL_all, 1, 0)
sum(test$Random.forest_acc)/nrow(test)