因為本地沒有網絡,所有相關的依賴包都是手動下載,再使用腳本一鍵安裝的。
在使用mlr包時,執行下面的代碼時,總是報各種依賴缺失,也不知道咋看FAIL信息。
# 建模與調參
# 查閱線性回歸、隨機森林、xgboost和KNN四種模型的相關代號
listLearners(obj = "regr") %>%filter_dt(class %like% "kknn|ranger|regr.lm|xgboost") %>%select_dt(class,name) -> models_df
listLearners.character(obj = "regr")里有警告:The following learners could not be constructed, probably because their packages are not installed:
classif.ada,classif.adaboostm1,classif.boosting,classif.bst,classif.clusterSVM,classif.cvglmnet,classif.dbnDNN,classif.dcSVM,classif.earth,classif.evtree,classif.fdausc.glm,classif.fdausc.kernel,classif.fdausc.knn,classif.fdausc.np,classif.FDboost,classif.fgam,classif.fnn,classif.gamboost,classif.gaterSVM,classif.glmboost,classif.glmnet,classif.h2o.deeplearning,classif.h2o.gbm,classif.h2o.glm,classif.h2o.randomForest,classif.IBk,classif.J48,classif.JRip,classif.LiblineaRL1L2SVC,classif.LiblineaRL1LogReg,classif.LiblineaRL2L1SVC,classif.LiblineaRL2LogReg,classif.LiblineaRL2SVC,classif.LiblineaRMultiClassSVC,classif.mda,classif.mlp,classif.neuralnet,classif.nnTrain,classif.OneR,classif.pamr,classif.PART,classif.penalized,classif.plr,classif.plsdaCaret,classif.rda,classif.rFerns,classif.rotationForest,classif.RRF,classif.saeDNN,classif.sda,classif.sparseLDA,cluster.Cobweb,cluster.EM,cluster [... truncated]
經過一系列排查,發現出現上述問題時的解決方法是:
找到警告中對應的安裝包的名稱,然后下載并進行安裝即可。
比如:classif.ada的包名為ada、classif.cvglmnet的包名為glmnet
1、輸入?learners
https://mlr.mlr-org.com/articles/tutorial/integrated_learners.html#classification-84-
?2、輸入待確認的類名,如:警告信息中的classIf.ada
然后從cran上下載即可。
https://cran.rstudio.com/bin/windows/contrib/4.4/
當然,也可以直接丟進AI工具,
3、下載并安裝相關依賴
missing_pkgs <- c("refund", "mda", "RSNNS", "pamr", "stepPlr", "sda", "sparseLDA","tgp", "brnn", "crs", "laGP"
)
install.packages(missing_pkgs)
4、注意SwarmSVM無法直接從?CRAN上下載
CRAN: Package SwarmSVM
?下載的tar.gz包解壓后,將SwarmSVM文件夾拷到R語言軟件安裝目錄下
C:\Program Files\R\R-4.4.3\library\