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)
weights <- information_gain(Species ~ ., data = iris, type = “gainratio”) print(weights)
weights_info <- information_gain(Species ~ ., data = iris, type = “infogain”) print(weights_info)
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”)
Ozone <- na.omit(Ozone)
set.seed(123) boruta_result <- Boruta(V4 ~ ., data = Ozone, doTrace = 2) print(boruta_result)
plot(boruta_result, las = 2, cex.axis = 0.7)
confirmed <- getSelectedAttributes(boruta_result, withTentative = FALSE) boxplot(Ozone[, confirmed])