在 R 中使用 XGBoost 时出现此错误
Error in xgb.DMatrix(data, label = label, missing = missing) :
'data' has class 'character' and length 1791.
'data' accepts either a numeric matrix or a single filename.
下面是正在运行的代码
#importing the dataset
XGBoostDataSet_Hr_Admin <- read.csv("CompletedDataImputed_HR_Admin.csv")
#Use factor function to convert categorical data to numerical data
XGBoostDataSet_Hr_Admin$Salary = factor(XGBoostDataSet_Hr_Admin$Salary, levels =c('L','M', 'H', 'V'), labels =c(1,2,3,4))
#split the data in train dataset and test dataset
#fitting XGBoost to the Training Test
library(xgboost)
classifier = xgboost(data = as.matrix(training_set[-10]), label = training_set$Employee_Turnover, nrounds = 10)