Работа с пакетами CARET и BORUTA на языке R
x <- matrix(rnorm(50*5),ncol=5)
y <- factor(rep(c(“A”, “B”), 25))
Сохранить полученные графики в *.jpg файлы. Сделать выводы.
С использование функций из пакета Fselector [2] определить важность признаков для решения задачи классификации. Использовать набор data(iris). Сделать выводы.
С использованием функции discretize() из пакета arules выполните преобразование непрерывной переменной в категориальную [3] различными методами: «interval» (равная ширина интервала), «frequency» (равная частота), «cluster» (кластеризация) и «fixed» (категории задают границы интервалов). Используйте набор данных iris. Сделайте выводы
Установите пакет Boruta и проведите выбор признаков для набора данных data(“Ozone”) [4, 5, 6]. Построить график boxplot, сделать выводы.
R version 4.4.2 (2024-10-31 ucrt) – “Pile of Leaves” Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64
R – это свободное ПО, и оно поставляется безо всяких гарантий. Вы вольны распространять его при соблюдении некоторых условий. Введите ‘license()’ для получения более подробной информации.
R – это проект, в котором сотрудничает множество разработчиков. Введите ‘contributors()’ для получения дополнительной информации и ‘citation()’ для ознакомления с правилами упоминания R и его пакетов в публикациях.
Введите ‘demo()’ для запуска демонстрационных программ, ‘help()’ – для получения справки, ‘help.start()’ – для доступа к справке через браузер. Введите ‘q()’, чтобы выйти из R.
[Загружено ранее сохраненное рабочее пространство]
install.packages(“caret”) Устанавливаю пакет в ‘C:/Users/amita/AppData/Local/R/win-library/4.4’ (потому что ‘lib’ не определено) — Пожалуйста, выберите зеркало CRAN для использования в этой сессии — устанавливаю также зависимости ‘listenv’, ‘parallelly’, ‘future’, ‘globals’, ‘shape’, ‘future.apply’, ‘numDeriv’, ‘progressr’, ‘SQUAREM’, ‘diagram’, ‘lava’, ‘tzdb’, ‘cpp11’, ‘prodlim’, ‘timechange’, ‘proxy’, ‘iterators’, ‘Rcpp’, ‘data.table’, ‘dplyr’, ‘clock’, ‘generics’, ‘gower’, ‘hardhat’, ‘ipred’, ‘lubridate’, ‘purrr’, ‘sparsevctrs’, ‘tidyr’, ‘tidyselect’, ‘timeDate’, ‘e1071’, ‘foreach’, ‘ModelMetrics’, ‘plyr’, ‘pROC’, ‘recipes’, ‘reshape2’
В наличии есть бинарная версия, но исходники новее: binary source needs_compilation recipes 1.1.0 1.1.1 FALSE
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/listenv_0.9.1.zip’ Content type ‘application/zip’ length 110138 bytes (107 KB) downloaded 107 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/parallelly_1.42.0.zip’ Content type ‘application/zip’ length 569159 bytes (555 KB) downloaded 555 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/future_1.34.0.zip’ Content type ‘application/zip’ length 692912 bytes (676 KB) downloaded 676 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/globals_0.16.3.zip’ Content type ‘application/zip’ length 109926 bytes (107 KB) downloaded 107 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/shape_1.4.6.1.zip’ Content type ‘application/zip’ length 753988 bytes (736 KB) downloaded 736 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/future.apply_1.11.3.zip’ Content type ‘application/zip’ length 160777 bytes (157 KB) downloaded 157 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/numDeriv_2016.8-1.1.zip’ Content type ‘application/zip’ length 117304 bytes (114 KB) downloaded 114 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/progressr_0.15.1.zip’ Content type ‘application/zip’ length 403673 bytes (394 KB) downloaded 394 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/SQUAREM_2021.1.zip’ Content type ‘application/zip’ length 183502 bytes (179 KB) downloaded 179 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/diagram_1.6.5.zip’ Content type ‘application/zip’ length 688009 bytes (671 KB) downloaded 671 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/lava_1.8.1.zip’ Content type ‘application/zip’ length 2514223 bytes (2.4 MB) downloaded 2.4 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/tzdb_0.4.0.zip’ Content type ‘application/zip’ length 1016625 bytes (992 KB) downloaded 992 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/cpp11_0.5.1.zip’ Content type ‘application/zip’ length 310642 bytes (303 KB) downloaded 303 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/prodlim_2024.06.25.zip’ Content type ‘application/zip’ length 425312 bytes (415 KB) downloaded 415 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/timechange_0.3.0.zip’ Content type ‘application/zip’ length 516681 bytes (504 KB) downloaded 504 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/proxy_0.4-27.zip’ Content type ‘application/zip’ length 181357 bytes (177 KB) downloaded 177 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/iterators_1.0.14.zip’ Content type ‘application/zip’ length 353865 bytes (345 KB) downloaded 345 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/Rcpp_1.0.14.zip’ Content type ‘application/zip’ length 2901283 bytes (2.8 MB) downloaded 2.8 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/data.table_1.16.4.zip’ Content type ‘application/zip’ length 2669183 bytes (2.5 MB) downloaded 2.5 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/dplyr_1.1.4.zip’ Content type ‘application/zip’ length 1590089 bytes (1.5 MB) downloaded 1.5 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/clock_0.7.2.zip’ Content type ‘application/zip’ length 2225356 bytes (2.1 MB) downloaded 2.1 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/generics_0.1.3.zip’ Content type ‘application/zip’ length 83445 bytes (81 KB) downloaded 81 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/gower_1.0.2.zip’ Content type ‘application/zip’ length 326588 bytes (318 KB) downloaded 318 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/hardhat_1.4.1.zip’ Content type ‘application/zip’ length 875518 bytes (854 KB) downloaded 854 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/ipred_0.9-15.zip’ Content type ‘application/zip’ length 393300 bytes (384 KB) downloaded 384 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/lubridate_1.9.4.zip’ Content type ‘application/zip’ length 989890 bytes (966 KB) downloaded 966 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/purrr_1.0.4.zip’ Content type ‘application/zip’ length 550970 bytes (538 KB) downloaded 538 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/sparsevctrs_0.2.0.zip’ Content type ‘application/zip’ length 172863 bytes (168 KB) downloaded 168 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/tidyr_1.3.1.zip’ Content type ‘application/zip’ length 1273495 bytes (1.2 MB) downloaded 1.2 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/tidyselect_1.2.1.zip’ Content type ‘application/zip’ length 229143 bytes (223 KB) downloaded 223 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/timeDate_4041.110.zip’ Content type ‘application/zip’ length 1406591 bytes (1.3 MB) downloaded 1.3 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/e1071_1.7-16.zip’ Content type ‘application/zip’ length 674379 bytes (658 KB) downloaded 658 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/foreach_1.5.2.zip’ Content type ‘application/zip’ length 149923 bytes (146 KB) downloaded 146 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/ModelMetrics_1.2.2.2.zip’ Content type ‘application/zip’ length 480818 bytes (469 KB) downloaded 469 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/plyr_1.8.9.zip’ Content type ‘application/zip’ length 1114159 bytes (1.1 MB) downloaded 1.1 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/pROC_1.18.5.zip’ Content type ‘application/zip’ length 1168557 bytes (1.1 MB) downloaded 1.1 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/reshape2_1.4.4.zip’ Content type ‘application/zip’ length 442791 bytes (432 KB) downloaded 432 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/caret_7.0-1.zip’ Content type ‘application/zip’ length 3602831 bytes (3.4 MB) downloaded 3.4 MB
пакет ‘listenv’ успешно распакован, MD5-суммы проверены пакет ‘parallelly’ успешно распакован, MD5-суммы проверены пакет ‘future’ успешно распакован, MD5-суммы проверены пакет ‘globals’ успешно распакован, MD5-суммы проверены пакет ‘shape’ успешно распакован, MD5-суммы проверены пакет ‘future.apply’ успешно распакован, MD5-суммы проверены пакет ‘numDeriv’ успешно распакован, MD5-суммы проверены пакет ‘progressr’ успешно распакован, MD5-суммы проверены пакет ‘SQUAREM’ успешно распакован, MD5-суммы проверены пакет ‘diagram’ успешно распакован, MD5-суммы проверены пакет ‘lava’ успешно распакован, MD5-суммы проверены пакет ‘tzdb’ успешно распакован, MD5-суммы проверены пакет ‘cpp11’ успешно распакован, MD5-суммы проверены пакет ‘prodlim’ успешно распакован, MD5-суммы проверены пакет ‘timechange’ успешно распакован, MD5-суммы проверены пакет ‘proxy’ успешно распакован, MD5-суммы проверены пакет ‘iterators’ успешно распакован, MD5-суммы проверены пакет ‘Rcpp’ успешно распакован, MD5-суммы проверены пакет ‘data.table’ успешно распакован, MD5-суммы проверены пакет ‘dplyr’ успешно распакован, MD5-суммы проверены пакет ‘clock’ успешно распакован, MD5-суммы проверены пакет ‘generics’ успешно распакован, MD5-суммы проверены пакет ‘gower’ успешно распакован, MD5-суммы проверены пакет ‘hardhat’ успешно распакован, MD5-суммы проверены пакет ‘ipred’ успешно распакован, MD5-суммы проверены пакет ‘lubridate’ успешно распакован, MD5-суммы проверены пакет ‘purrr’ успешно распакован, MD5-суммы проверены пакет ‘sparsevctrs’ успешно распакован, MD5-суммы проверены пакет ‘tidyr’ успешно распакован, MD5-суммы проверены пакет ‘tidyselect’ успешно распакован, MD5-суммы проверены пакет ‘timeDate’ успешно распакован, MD5-суммы проверены пакет ‘e1071’ успешно распакован, MD5-суммы проверены пакет ‘foreach’ успешно распакован, MD5-суммы проверены пакет ‘ModelMetrics’ успешно распакован, MD5-суммы проверены пакет ‘plyr’ успешно распакован, MD5-суммы проверены пакет ‘pROC’ успешно распакован, MD5-суммы проверены пакет ‘reshape2’ успешно распакован, MD5-суммы проверены пакет ‘caret’ успешно распакован, MD5-суммы проверены
Скачанные бинарные пакеты находятся в C:76gl_packages устанавливаю пакет ‘recipes’ из исходников
пробую URL ‘https://mirror.truenetwork.ru/CRAN/src/contrib/recipes_1.1.1.tar.gz’ Content type ‘application/octet-stream’ length 862112 bytes (841 KB) downloaded 841 KB
Скачанные исходники пакетов находятся в ’C:76gl_packages’ > д
Ошибка: объект ‘д’ не найден > library(caret) Загрузка требуемого
пакета: ggplot2 Загрузка требуемого пакета: lattice > methods <-
names(getModelInfo()) > print(methods) [1] “ada” “AdaBag”
“AdaBoost.M1” “adaboost” “amdai” “ANFIS” “avNNet”
[8] “awnb” “awtan” “bag” “bagEarth” “bagEarthGCV” “bagFDA”
“bagFDAGCV”
[15] “bam” “bartMachine” “bayesglm” “binda” “blackboost” “blasso”
“blassoAveraged”
[22] “bridge” “brnn” “BstLm” “bstSm” “bstTree” “C5.0” “C5.0Cost”
[29] “C5.0Rules” “C5.0Tree” “cforest” “chaid” “CSimca” “ctree”
“ctree2”
[36] “cubist” “dda” “deepboost” “DENFIS” “dnn” “dwdLinear”
“dwdPoly”
[43] “dwdRadial” “earth” “elm” “enet” “evtree” “extraTrees” “fda”
[50] “FH.GBML” “FIR.DM” “foba” “FRBCS.CHI” “FRBCS.W” “FS.HGD”
“gam”
[57] “gamboost” “gamLoess” “gamSpline” “gaussprLinear” “gaussprPoly”
“gaussprRadial” “gbm_h2o”
[64] “gbm” “gcvEarth” “GFS.FR.MOGUL” “GFS.LT.RS” “GFS.THRIFT” “glm.nb”
“glm”
[71] “glmboost” “glmnet_h2o” “glmnet” “glmStepAIC” “gpls” “hda”
“hdda”
[78] “hdrda” “HYFIS” “icr” “J48” “JRip” “kernelpls” “kknn”
[85] “knn” “krlsPoly” “krlsRadial” “lars” “lars2” “lasso” “lda”
[92] “lda2” “leapBackward” “leapForward” “leapSeq” “Linda” “lm”
“lmStepAIC”
[99] “LMT” “loclda” “logicBag” “LogitBoost” “logreg” “lssvmLinear”
“lssvmPoly”
[106] “lssvmRadial” “lvq” “M5” “M5Rules” “manb” “mda” “Mlda”
[113] “mlp” “mlpKerasDecay” “mlpKerasDecayCost” “mlpKerasDropout”
“mlpKerasDropoutCost” “mlpML” “mlpSGD”
[120] “mlpWeightDecay” “mlpWeightDecayML” “monmlp” “msaenet” “multinom”
“mxnet” “mxnetAdam”
[127] “naive_bayes” “nb” “nbDiscrete” “nbSearch” “neuralnet” “nnet”
“nnls”
[134] “nodeHarvest” “null” “OneR” “ordinalNet” “ordinalRF” “ORFlog”
“ORFpls”
[141] “ORFridge” “ORFsvm” “ownn” “pam” “parRF” “PART” “partDSA”
[148] “pcaNNet” “pcr” “pda” “pda2” “penalized” “PenalizedLDA”
“plr”
[155] “pls” “plsRglm” “polr” “ppr” “pre” “PRIM” “protoclass”
[162] “qda” “QdaCov” “qrf” “qrnn” “randomGLM” “ranger” “rbf”
[169] “rbfDDA” “Rborist” “rda” “regLogistic” “relaxo” “rf”
“rFerns”
[176] “RFlda” “rfRules” “ridge” “rlda” “rlm” “rmda” “rocc”
[183] “rotationForest” “rotationForestCp” “rpart” “rpart1SE” “rpart2”
“rpartCost” “rpartScore”
[190] “rqlasso” “rqnc” “RRF” “RRFglobal” “rrlda” “RSimca”
“rvmLinear”
[197] “rvmPoly” “rvmRadial” “SBC” “sda” “sdwd” “simpls” “SLAVE”
[204] “slda” “smda” “snn” “sparseLDA” “spikeslab” “spls” “stepLDA”
[211] “stepQDA” “superpc” “svmBoundrangeString” “svmExpoString”
“svmLinear” “svmLinear2” “svmLinear3”
[218] “svmLinearWeights” “svmLinearWeights2” “svmPoly” “svmRadial”
“svmRadialCost” “svmRadialSigma” “svmRadialWeights”
[225] “svmSpectrumString” “tan” “tanSearch” “treebag” “vbmpRadial”
“vglmAdjCat” “vglmContRatio”
[232] “vglmCumulative” “widekernelpls” “WM” “wsrf” “xgbDART” “xgbLinear”
“xgbTree”
[239] “xyf”
> set.seed(123) > x <- matrix(rnorm(50 * 5), ncol = 5) > y
<- factor(rep(c(“A”, “B”), each = 25)) > set.seed(123)x <-
matrix(rnorm(50 * 5), ncol = 5) Ошибка: неожиданный символ в
“set.seed(123)x” > set.seed(123) x <- matrix(rnorm(50 * 5), ncol =
5) Ошибка: неожиданный символ в “set.seed(123) x” > set.seed(123)
> x <- matrix(rnorm(50 * 5), ncol = 5) > y <-
factor(rep(c(“A”, “B”), each = 25)) > jpeg(“feature_plot1.jpg”) >
featurePlot(x, y, plot = “pairs”) > dev.off() null device 1 > >
jpeg(“feature_plot2.jpg”) > featurePlot(x, y, plot = “density”) >
dev.off() null device 1 > > jpeg(“feature_plot3.jpg”) >
featurePlot(x, y, plot = “box”) > dev.off() null device 1 >
set.seed(123) > x <- matrix(rnorm(50 * 5), ncol = 5) > y <-
factor(rep(c(“A”, “B”), each = 25)) > jpeg(“feature_plot1.jpg”) >
featurePlot(x, y, plot = “pairs”) > dev.off() null device 1 >
set.seed(123) > x <- matrix(rnorm(50 * 5), ncol = 5) > y <-
factor(rep(c(“A”, “B”), each = 25)) > jpeg(“feature_plot1.jpg”) >
featurePlot(x, y, plot = “pairs”) > dev.off() null device 1 >
getwd() [1] “C:/Users/amita/OneDrive/Документы” >
setwd(“C:/политех/ад2”) > jpeg(“feature_plot1.jpg”) >
featurePlot(x, y, plot = “pairs”) > dev.off() null device 1 >
getwd() [1] “C:/политех/ад2” > jpeg(“feature_plot2.jpg”) >
featurePlot(x, y, plot = “density”) > dev.off() null device 1 >
> jpeg(“feature_plot3.jpg”) > featurePlot(x, y, plot = “box”) >
dev.off() null device 1 > install.packages(“FSelector”) Устанавливаю
пакет в ‘C:/Users/amita/AppData/Local/R/win-library/4.4’ (потому что
‘lib’ не определено) устанавливаю также зависимости ‘RWekajars’,
‘rJava’, ‘entropy’, ‘randomForest’, ‘RWeka’
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/RWekajars_3.9.3-2.zip’ Content type ‘application/zip’ length 10032953 bytes (9.6 MB) downloaded 9.6 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/rJava_1.0-11.zip’ Content type ‘application/zip’ length 835913 bytes (816 KB) downloaded 816 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/entropy_1.3.1.zip’ Content type ‘application/zip’ length 92701 bytes (90 KB) downloaded 90 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/randomForest_4.7-1.2.zip’ Content type ‘application/zip’ length 225986 bytes (220 KB) downloaded 220 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/RWeka_0.4-46.zip’ Content type ‘application/zip’ length 539257 bytes (526 KB) downloaded 526 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/FSelector_0.34.zip’ Content type ‘application/zip’ length 96154 bytes (93 KB) downloaded 93 KB
пакет ‘RWekajars’ успешно распакован, MD5-суммы проверены пакет ‘rJava’ успешно распакован, MD5-суммы проверены пакет ‘entropy’ успешно распакован, MD5-суммы проверены пакет ‘randomForest’ успешно распакован, MD5-суммы проверены пакет ‘RWeka’ успешно распакован, MD5-суммы проверены пакет ‘FSelector’ успешно распакован, MD5-суммы проверены
Скачанные бинарные пакеты находятся в C:76gl_packages > library(FSelector) > data(iris) > weights <- information.gain(Species ~ ., data = iris) > print(weights) attr_importance Sepal.Length 0.4521286 Sepal.Width 0.2672750 Petal.Length 0.9402853 Petal.Width 0.9554360 > sorted_weights <- weights[order(-weights$attr_importance),] > print(sorted_weights) [1] 0.9554360 0.9402853 0.4521286 0.2672750 > install.packages(“arules”) Устанавливаю пакет в ‘C:/Users/amita/AppData/Local/R/win-library/4.4’ (потому что ‘lib’ не определено) пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/arules_1.7-9.zip’ Content type ‘application/zip’ length 2630106 bytes (2.5 MB) downloaded 2.5 MB
пакет ‘arules’ успешно распакован, MD5-суммы проверены
Скачанные бинарные пакеты находятся в C:76gl_packages > library(arules) Загрузка требуемого пакета: Matrix
Присоединяю пакет: ‘arules’
Следующие объекты скрыты от ‘package:base’:
abbreviate, write
data(iris) iris_interval <- discretize(iris[, 1:4], method = “interval”, categories = 3) Ошибка в cut.default(x, breaks = breaks, labels = labels, include.lowest = include.lowest, : ‘x’ должен быть числом Вдобавок: Предупреждение: В discretize(iris[, 1:4], method = “interval”, categories = 3) : Parameter categories is deprecated. Use breaks instead! Also, the default method is now frequency! print(head(iris_interval)) Ошибка в h(simpleError(msg, call)) : ошибка при оценке аргумента ‘x’ при выборе метода для функции ‘print’: ошибка при оценке аргумента ‘x’ при выборе метода для функции ‘head’: объект ‘iris_interval’ не найден
iris_interval <- discretize(iris[, 1:4], method = “interval”, breaks = 3) Ошибка в cut.default(x, breaks = breaks, labels = labels, include.lowest = include.lowest, : ‘x’ должен быть числом print(head(iris_interval)) Ошибка в h(simpleError(msg, call)) : ошибка при оценке аргумента ‘x’ при выборе метода для функции ‘print’: ошибка при оценке аргумента ‘x’ при выборе метода для функции ‘head’: объект ‘iris_interval’ не найден iris_interval <- lapply(iris[, 1:4], function(x) discretize(x, method = “interval”, breaks = 3)) iris_interval <- as.data.frame(iris_interval) print(head(iris_interval)) Sepal.Length Sepal.Width Petal.Length Petal.Width 1 [4.3,5.5) [2.8,3.6) [1,2.97) [0.1,0.9) 2 [4.3,5.5) [2.8,3.6) [1,2.97) [0.1,0.9) 3 [4.3,5.5) [2.8,3.6) [1,2.97) [0.1,0.9) 4 [4.3,5.5) [2.8,3.6) [1,2.97) [0.1,0.9) 5 [4.3,5.5) [2.8,3.6) [1,2.97) [0.1,0.9) 6 [4.3,5.5) [3.6,4.4] [1,2.97) [0.1,0.9) iris_frequency <- lapply(iris[, 1:4], function(x) discretize(x, method = “frequency”, breaks = 3)) iris_frequency <- as.data.frame(iris_frequency) print(head(iris_frequency)) Sepal.Length Sepal.Width Petal.Length Petal.Width 1 [4.3,5.4) [3.2,4.4] [1,2.63) [0.1,0.867) 2 [4.3,5.4) [2.9,3.2) [1,2.63) [0.1,0.867) 3 [4.3,5.4) [3.2,4.4] [1,2.63) [0.1,0.867) 4 [4.3,5.4) [2.9,3.2) [1,2.63) [0.1,0.867) 5 [4.3,5.4) [3.2,4.4] [1,2.63) [0.1,0.867) 6 [5.4,6.3) [3.2,4.4] [1,2.63) [0.1,0.867) iris_cluster <- lapply(iris[, 1:4], function(x) discretize(x, method = “cluster”, breaks = 3)) iris_cluster <- as.data.frame(iris_cluster) print(head(iris_cluster)) Sepal.Length Sepal.Width Petal.Length Petal.Width 1 [4.3,5.42) [3.28,4.4] [1,2.95) [0.1,0.792) 2 [4.3,5.42) [2.69,3.28) [1,2.95) [0.1,0.792) 3 [4.3,5.42) [2.69,3.28) [1,2.95) [0.1,0.792) 4 [4.3,5.42) [2.69,3.28) [1,2.95) [0.1,0.792) 5 [4.3,5.42) [3.28,4.4] [1,2.95) [0.1,0.792) 6 [4.3,5.42) [3.28,4.4] [1,2.95) [0.1,0.792) breaks <- list(Sepal.Length = c(-Inf, 5, 6, Inf), + Sepal.Width = c(-Inf, 3, 4, Inf), + Petal.Length = c(-Inf, 1.5, 5, Inf), + Petal.Width = c(-Inf, 0.5, 1.5, Inf))
iris_fixed <- lapply(iris[, 1:4], function(x) discretize(x, method = “fixed”, breaks = breaks)) Ошибка в sort.int(as.double(breaks)) : объект ‘list’ не может быть преобразован в тип ‘double’ iris_fixed <- as.data.frame(iris_fixed) Ошибка: объект ‘iris_fixed’ не найден print(head(iris_fixed)) Ошибка в h(simpleError(msg, call)) : ошибка при оценке аргумента ‘x’ при выборе метода для функции ‘print’: ошибка при оценке аргумента ‘x’ при выборе метода для функции ‘head’: объект ‘iris_fixed’ не найден breaks <- list(Sepal.Length = c(-Inf, 5, 6, Inf), + Sepal.Width = c(-Inf, 3, 4, Inf), + Petal.Length = c(-Inf, 1.5, 5, Inf), + Petal.Width = c(-Inf, 0.5, 1.5, Inf)) iris_fixed <- lapply(names(breaks), function(col_name) { + discretize(iris[[col_name]], method = “fixed”, breaks = breaks[[col_name]]) + }) iris_fixed <- as.data.frame(iris_fixed) names(iris_fixed) <- names(breaks) # Переименуем колонки print(head(iris_fixed)) Sepal.Length Sepal.Width Petal.Length Petal.Width 1 [5,6) [3,4) [-Inf,1.5) [-Inf,0.5) 2 [-Inf,5) [3,4) [-Inf,1.5) [-Inf,0.5) 3 [-Inf,5) [3,4) [-Inf,1.5) [-Inf,0.5) 4 [-Inf,5) [3,4) [1.5,5) [-Inf,0.5) 5 [5,6) [3,4) [-Inf,1.5) [-Inf,0.5) 6 [5,6) [3,4) [1.5,5) [-Inf,0.5) install.packages(“Boruta”) Устанавливаю пакет в ‘C:/Users/amita/AppData/Local/R/win-library/4.4’ (потому что ‘lib’ не определено) устанавливаю также зависимости ‘RcppEigen’, ‘ranger’
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/RcppEigen_0.3.4.0.2.zip’ Content type ‘application/zip’ length 2592479 bytes (2.5 MB) downloaded 2.5 MB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/ranger_0.17.0.zip’ Content type ‘application/zip’ length 799370 bytes (780 KB) downloaded 780 KB
пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/Boruta_8.0.0.zip’ Content type ‘application/zip’ length 457837 bytes (447 KB) downloaded 447 KB
пакет ‘RcppEigen’ успешно распакован, MD5-суммы проверены пакет ‘ranger’ успешно распакован, MD5-суммы проверены пакет ‘Boruta’ успешно распакован, MD5-суммы проверены
Скачанные бинарные пакеты находятся в C:76gl_packages > library(Boruta) > > data(“Ozone”, package = “datasets”) Предупреждение: В data(“Ozone”, package = “datasets”) : данные ‘Ozone’ не найдены > Ozone <- na.omit(Ozone) Ошибка: объект ‘Ozone’ не найден > install.packages(“ggplot2”) Предупреждение: пакет ‘‘ggplot2’’ сейчас используется и не будет установлен > install.packages(“reshape2”) Устанавливаю пакет в ‘C:/Users/amita/AppData/Local/R/win-library/4.4’ (потому что ‘lib’ не определено) пробую URL ‘https://mirror.truenetwork.ru/CRAN/bin/windows/contrib/4.4/reshape2_1.4.4.zip’ Content type ‘application/zip’ length 442791 bytes (432 KB) downloaded 432 KB
пакет ‘reshape2’ успешно распакован, MD5-суммы проверены Предупреждение: не могу удалить прежнюю установку пакета ‘reshape2’ Предупреждение: восстановлен ‘reshape2’
Скачанные бинарные пакеты находятся в C:76gl_packages Предупреждение:
В file.copy(savedcopy, lib, recursive = TRUE) : проблема с копированием
C:-library\4.4\00LOCK2.dll в C:-library\4.42.dll: Permission denied >
library(Boruta) > library(ggplot2) > library(reshape2) > Ozone
<- read.csv(“ozone_data.csv”) Ошибка в file(file, “rt”) : не могу
открыть соединение Вдобавок: Предупреждение: В file(file, “rt”) : не
могу открыть файл ‘ozone_data.csv’: No such file or directory >
install.packages(“ggplot2”) Предупреждение: пакет ‘‘ggplot2’’ сейчас
используется и не будет установлен > install.packages(“reshape2”)
Предупреждение: пакет ‘‘reshape2’’ сейчас используется и не будет
установлен >
> getwd() [1] “C:/политех/ад2” >
> list.files() [1] “feature_plot1.jpg” “feature_plot2.jpg”
“feature_plot3.jpg” > Ozone <- read.csv(“ozone_data.csv”) Ошибка в
file(file, “rt”) : не могу открыть соединение Вдобавок: Предупреждение:
В file(file, “rt”) : не могу открыть файл ‘ozone_data.csv’: No such file
or directory >
> ozone_data <- data.frame( + Month = c(“January”, “February”,
“March”, “April”, “May”), + Ozone = c(23, 45, 67, 89, 34) + ozone_data
<- data.frame( Ошибка: неожиданный символ в: ” Ozone = c(23, 45, 67,
89, 34) ozone_data” > Month = c(“January”, “February”, “March”,
“April”, “May”), Ошибка: неожиданный ‘,’ в ” Month = c(“January”,
“February”, “March”, “April”, “May”),” > Ozone = c(23, 45, 67, 89,
34) > ozone_data <- data.frame( + Month = c(“January”, “February”,
“March”, “April”, “May”), + Ozone = c(23, 45, 67, 89, 34) + ) >
write.csv(ozone_data, file = “ozone_data.csv”, row.names = FALSE) >
list.files() [1] “feature_plot1.jpg” “feature_plot2.jpg”
“feature_plot3.jpg” “ozone_data.csv”
> Ozone <- read.csv(“ozone_data.csv”) > str(Ozone)
‘data.frame’: 5 obs. of 2 variables: $ Month: chr “January” “February”
“March” “April” … $ Ozone: int 23 45 67 89 34 > Ozone <-
na.omit(Ozone) > Ozone\(Ozone <-
as.factor(ifelse(Ozone\)Ozone > 30, “High”, “Low”)) >
Ozone_features <- Ozone[, -which(names(Ozone) == “Ozone”)] >
set.seed(123) > boruta_result <- Boruta(Ozone ~ ., data = Ozone,
doTrace = 2) 1. run of importance source… 2. run of importance source…
3. run of importance source… 4. run of importance source… 5. run of
importance source… 6. run of importance source… 7. run of importance
source… After 7 iterations, +0.12 secs: rejected 1 attribute: Month; no
more attributes left.
Предупреждения: 1: В addShadowsAndGetImp(decReg, runs) : getImp
result contains NA(s) or NaN(s); replacing with 0(s), yet this is
suspicious. 2: В addShadowsAndGetImp(decReg, runs) : getImp result
contains NA(s) or NaN(s); replacing with 0(s), yet this is suspicious.
3: В addShadowsAndGetImp(decReg, runs) : getImp result contains NA(s) or
NaN(s); replacing with 0(s), yet this is suspicious. 4: В
addShadowsAndGetImp(decReg, runs) : getImp result contains NA(s) or
NaN(s); replacing with 0(s), yet this is suspicious. 5: В
addShadowsAndGetImp(decReg, runs) : getImp result contains NA(s) or
NaN(s); replacing with 0(s), yet this is suspicious. 6: В
addShadowsAndGetImp(decReg, runs) : getImp result contains NA(s) or
NaN(s); replacing with 0(s), yet this is suspicious. 7: В
addShadowsAndGetImp(decReg, runs) : getImp result contains NA(s) or
NaN(s); replacing with 0(s), yet this is suspicious. >
print(boruta_result) Boruta performed 7 iterations in 0.1172152 secs. No
attributes deemed important. 1 attributes confirmed unimportant: Month;
> selected_features <- getSelectedAttributes(boruta_result,
withTentative = F) > print(selected_features) character(0) >
Ozone_melted <- melt(Ozone[, c(selected_features, “Ozone”)], id.vars
= “Ozone”) > > ggplot(Ozone_melted, aes(x = Ozone, y = value)) + +
geom_boxplot() + + facet_wrap(~ variable, scales = “free”) + +
labs(title = “Boxplot for Selected Features”, x = “Ozone Level”, y =
“Value”) + + theme_minimal() Error in combine_vars(): ! At
least one layer must contain all faceting variables:
variable ✖ Plot is missing variable ✖ Layer 1
is missing variable Run rlang::last_trace() to
see where the error occurred. > library(ggplot2) >
library(reshape2) > Ozone_melted <- data.frame(Ozone = Ozone\(Ozone)
> Ozone_melted\)Ozone_Level <- Ozone\(Ozone
> ggplot(Ozone_melted, aes(x = Ozone_Level, y = Ozone)) +
+ geom_boxplot() +
+ labs(title = "Boxplot for Ozone Levels", x = "Ozone
Level", y = "Value") +
+ theme_minimal()
> Ozone_melted <- data.frame(Ozone = Ozone\)Ozone, Month =
Ozone$Month) > ggplot(Ozone_melted, aes(x = Month, y = Ozone)) + +
geom_boxplot() + + labs(title = “Boxplot for Ozone Levels by Month”, x =
“Month”, y = “Ozone Level”) + + theme_minimal() >
ggplot(Ozone_melted, aes(y = Ozone)) + + geom_boxplot() + + labs(title =
“Boxplot for Ozone Levels”, y = “Ozone Level”) + + theme_minimal() >
library(ggplot2) >
> head(Ozone_melted) Ozone Month 1 Low January 2 High February 3 High
March 4 High April 5 High May >
> print(ggplot(Ozone_melted, aes(x = Month, y = Ozone)) +
geom_boxplot()) >
> ggsave(“boxplot.png”, plot = last_plot()) Saving 6.85 x 6.84 in
image