library(caret)

Список доступных методов

model_list <- names(getModelInfo()) head(model_list)

Создание данных

set.seed(123) x <- as.data.frame(matrix(rnorm(50*5), ncol=5)) colnames(x) <- paste0(“Var”, 1:5) y <- factor(rep(c(“A”, “B”), 25))

Построение графиков

featurePlot(x = x, y = y, plot = “density”, scales = list(x = list(relation=“free”), y = list(relation=“free”))) featurePlot(x = x, y = y, plot = “box”) featurePlot(x = x, y = y, plot = “pairs”, auto.key = list(columns = 2))

library(FSelectorRcpp)

data(iris)

Метод gain ratio

weights <- information_gain(Species ~ ., data = iris, type = “gainratio”) print(weights)

Метод information gain

weights_info <- information_gain(Species ~ ., data = iris, type = “infogain”) print(weights_info)

Метод chi-squared

weights_chi <- chi.squared(Species ~ ., data = iris) print(weights_chi)

library(arules) data(iris)

sepal_length <- iris$Sepal.Length

Методы дискретизации

methods <- c(“interval”, “frequency”, “cluster”, “fixed”) results <- list()

for (method in methods) { if (method == “fixed”) { disc <- discretize(sepal_length, method = method, breaks = c(-Inf, 5, 6, Inf)) } else { disc <- discretize(sepal_length, method = method, breaks = 3) } results[[method]] <- table(disc) }

results

library(Boruta) data(Ozone, package = “mlbench”)

Удаление NA

Ozone <- na.omit(Ozone)

Запуск Boruta

set.seed(123) boruta_result <- Boruta(V4 ~ ., data = Ozone, doTrace = 2) print(boruta_result)

Визуализация

plot(boruta_result, las = 2, cex.axis = 0.7)

Boxplot важных признаков

confirmed <- getSelectedAttributes(boruta_result, withTentative = FALSE) boxplot(Ozone[, confirmed])