knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = TRUE)
library(caret)
## Warning: пакет 'caret' был собран под R версии 4.5.2
## Загрузка требуемого пакета: ggplot2
## Загрузка требуемого пакета: lattice
library(FSelectorRcpp)
## Warning: пакет 'FSelectorRcpp' был собран под R версии 4.5.2
library(arules)
## Warning: пакет 'arules' был собран под R версии 4.5.2
## Загрузка требуемого пакета: Matrix
##
## Присоединяю пакет: 'arules'
## Следующий объект скрыт от 'package:FSelectorRcpp':
##
## discretize
## Следующие объекты скрыты от 'package:base':
##
## abbreviate, write
library(Boruta)
## Warning: пакет 'Boruta' был собран под R версии 4.5.2
library(mlbench)
## Warning: пакет 'mlbench' был собран под R версии 4.5.2
names(getModelInfo())
## [1] "ada" "AdaBag" "AdaBoost.M1"
## [4] "adaboost" "amdai" "ANFIS"
## [7] "avNNet" "awnb" "awtan"
## [10] "bag" "bagEarth" "bagEarthGCV"
## [13] "bagFDA" "bagFDAGCV" "bam"
## [16] "bartMachine" "bayesglm" "binda"
## [19] "blackboost" "blasso" "blassoAveraged"
## [22] "bridge" "brnn" "BstLm"
## [25] "bstSm" "bstTree" "C5.0"
## [28] "C5.0Cost" "C5.0Rules" "C5.0Tree"
## [31] "cforest" "chaid" "CSimca"
## [34] "ctree" "ctree2" "cubist"
## [37] "dda" "deepboost" "DENFIS"
## [40] "dnn" "dwdLinear" "dwdPoly"
## [43] "dwdRadial" "earth" "elm"
## [46] "enet" "evtree" "extraTrees"
## [49] "fda" "FH.GBML" "FIR.DM"
## [52] "foba" "FRBCS.CHI" "FRBCS.W"
## [55] "FS.HGD" "gam" "gamboost"
## [58] "gamLoess" "gamSpline" "gaussprLinear"
## [61] "gaussprPoly" "gaussprRadial" "gbm_h2o"
## [64] "gbm" "gcvEarth" "GFS.FR.MOGUL"
## [67] "GFS.LT.RS" "GFS.THRIFT" "glm.nb"
## [70] "glm" "glmboost" "glmnet_h2o"
## [73] "glmnet" "glmStepAIC" "gpls"
## [76] "hda" "hdda" "hdrda"
## [79] "HYFIS" "icr" "J48"
## [82] "JRip" "kernelpls" "kknn"
## [85] "knn" "krlsPoly" "krlsRadial"
## [88] "lars" "lars2" "lasso"
## [91] "lda" "lda2" "leapBackward"
## [94] "leapForward" "leapSeq" "Linda"
## [97] "lm" "lmStepAIC" "LMT"
## [100] "loclda" "logicBag" "LogitBoost"
## [103] "logreg" "lssvmLinear" "lssvmPoly"
## [106] "lssvmRadial" "lvq" "M5"
## [109] "M5Rules" "manb" "mda"
## [112] "Mlda" "mlp" "mlpKerasDecay"
## [115] "mlpKerasDecayCost" "mlpKerasDropout" "mlpKerasDropoutCost"
## [118] "mlpML" "mlpSGD" "mlpWeightDecay"
## [121] "mlpWeightDecayML" "monmlp" "msaenet"
## [124] "multinom" "mxnet" "mxnetAdam"
## [127] "naive_bayes" "nb" "nbDiscrete"
## [130] "nbSearch" "neuralnet" "nnet"
## [133] "nnls" "nodeHarvest" "null"
## [136] "OneR" "ordinalNet" "ordinalRF"
## [139] "ORFlog" "ORFpls" "ORFridge"
## [142] "ORFsvm" "ownn" "pam"
## [145] "parRF" "PART" "partDSA"
## [148] "pcaNNet" "pcr" "pda"
## [151] "pda2" "penalized" "PenalizedLDA"
## [154] "plr" "pls" "plsRglm"
## [157] "polr" "ppr" "pre"
## [160] "PRIM" "protoclass" "qda"
## [163] "QdaCov" "qrf" "qrnn"
## [166] "randomGLM" "ranger" "rbf"
## [169] "rbfDDA" "Rborist" "rda"
## [172] "regLogistic" "relaxo" "rf"
## [175] "rFerns" "RFlda" "rfRules"
## [178] "ridge" "rlda" "rlm"
## [181] "rmda" "rocc" "rotationForest"
## [184] "rotationForestCp" "rpart" "rpart1SE"
## [187] "rpart2" "rpartCost" "rpartScore"
## [190] "rqlasso" "rqnc" "RRF"
## [193] "RRFglobal" "rrlda" "RSimca"
## [196] "rvmLinear" "rvmPoly" "rvmRadial"
## [199] "SBC" "sda" "sdwd"
## [202] "simpls" "SLAVE" "slda"
## [205] "smda" "snn" "sparseLDA"
## [208] "spikeslab" "spls" "stepLDA"
## [211] "stepQDA" "superpc" "svmBoundrangeString"
## [214] "svmExpoString" "svmLinear" "svmLinear2"
## [217] "svmLinear3" "svmLinearWeights" "svmLinearWeights2"
## [220] "svmPoly" "svmRadial" "svmRadialCost"
## [223] "svmRadialSigma" "svmRadialWeights" "svmSpectrumString"
## [226] "tan" "tanSearch" "treebag"
## [229] "vbmpRadial" "vglmAdjCat" "vglmContRatio"
## [232] "vglmCumulative" "widekernelpls" "WM"
## [235] "wsrf" "xgbDART" "xgbLinear"
## [238] "xgbTree" "xyf"
set.seed(123)
x <- matrix(rnorm(50 * 5), ncol = 5)
y <- factor(rep(c("A", "B"), 25))
jpeg("feature_pairs.jpg")
featurePlot(x = x, y = y, plot = "pairs")
dev.off()
## png
## 2
jpeg("feature_box.jpg")
featurePlot(x = x, y = y, plot = "box")
dev.off()
## png
## 2
jpeg("featurePlot_density.jpg", width = 800, height = 600)
featurePlot(x = x, y = y, plot = "density")
dev.off()
## png
## 2
data(iris)
weights <- information_gain(Species ~ ., iris)
weights
## attributes importance
## 1 Sepal.Length 0.4521286
## 2 Sepal.Width 0.2672750
## 3 Petal.Length 0.9402853
## 4 Petal.Width 0.9554360
iris_interval <- discretize(iris$Sepal.Length, method = "interval")
iris_frequency <- discretize(iris$Sepal.Length, method = "frequency")
iris_cluster <- discretize(iris$Sepal.Length, method = "cluster")
iris_fixed <- discretize(
iris$Sepal.Length,
method = "fixed",
breaks = c(0, 2, 4, 7)
)
summary(iris_interval)
## [4.3,5.5) [5.5,6.7) [6.7,7.9]
## 52 70 28
summary(iris_frequency)
## [4.3,5.4) [5.4,6.3) [6.3,7.9]
## 46 53 51
summary(iris_cluster)
## [4.3,5.42) [5.42,6.39) [6.39,7.9]
## 52 56 42
summary(iris_fixed)
## [0,2) [2,4) [4,7] NA's
## 0 0 138 12
data(Ozone)
Ozone_clean <- na.omit(Ozone)
boruta_model <- Boruta(V4 ~ ., data = Ozone_clean, doTrace = 0)
print(boruta_model)
## Boruta performed 33 iterations in 1.494151 secs.
## 9 attributes confirmed important: V1, V10, V11, V12, V13 and 4 more;
## 3 attributes confirmed unimportant: V2, V3, V6;
plot(boruta_model, las = 2, cex.axis = 0.7)

boruta_results <- attStats(boruta_model)
boruta_results
## meanImp medianImp minImp maxImp normHits decision
## V1 9.329245 9.284575 7.8059871 10.9224608 1.0000000 Confirmed
## V2 1.306499 1.308398 -0.5508258 3.1967642 0.1515152 Rejected
## V3 -1.196355 -1.037432 -3.5382041 0.6560767 0.0000000 Rejected
## V5 9.188471 9.196656 7.7807720 10.7713888 1.0000000 Confirmed
## V6 1.242236 1.050930 -1.0513264 3.3759073 0.2121212 Rejected
## V7 11.575730 11.721367 10.0402729 13.6221998 1.0000000 Confirmed
## V8 17.084855 17.143278 15.1418722 18.7996508 1.0000000 Confirmed
## V9 19.570309 19.509317 17.3230613 20.8999602 1.0000000 Confirmed
## V10 9.977722 9.792059 8.9544025 12.2093774 1.0000000 Confirmed
## V11 11.925061 12.035495 9.4711368 13.1652560 1.0000000 Confirmed
## V12 14.672414 14.581768 13.7639763 16.2010240 1.0000000 Confirmed
## V13 9.535653 9.383268 8.4448471 10.6412577 1.0000000 Confirmed