如何在 R 中为 xgboost 创建混淆矩阵

how to create a confusion matrix for xgboost in R

我已经在 R 中创建了我的 XGBoost 分类器,如下面的代码

#importing the dataset
XGBoostDataSet_Hr_Admin_8 <- read.csv("CompletedDataImputed_HR_Admin.csv")

#Use factor function to convert categorical data to numerical data
XGBoostDataSet_Hr_Admin_8$Salary = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Salary, levels =c('L','M', 'H', 'V'), labels =c(1,2,3,4)))
XGBoostDataSet_Hr_Admin_8$Rude_Behavior = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Rude_Behavior, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Feeling_undervalued =as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Feeling_undervalued, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Overall_satisfaction = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Overall_satisfaction, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Raises_frozen = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Raises_frozen, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Poor_Conditions = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Poor_Conditions, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Growth_not_available = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Growth_not_available, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Workplace_Conflict = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Workplace_Conflict, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Employee_Turnover = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Employee_Turnover, levels=c('Y', 'N'), labels =c(1,0)))

#split the data in train dataset and test dataset
library(caTools)
split = sample.split(XGBoostDataSet_Hr_Admin_8$Employee_Turnover,SplitRatio = 0.7)
training_set8 = subset(XGBoostDataSet_Hr_Admin_8, split==TRUE)
test_set8 = subset(XGBoostDataSet_Hr_Admin_8, split==FALSE)

#fitting XGBoost to the Training Test
library(xgboost)
classifier9 = xgboost(data = as.matrix(training_set8[-10]), label = training_set8$Employee_Turnover, nrounds = 10)

现在,我需要为 XGBoost 创建一个混淆矩阵。

我在网上搜索过,很遗憾没有找到解决方案。

谁能帮帮我。

提前致谢

您可以使用 caret::confusionMatrix() 函数,但您需要对输出进行一些处理。显然你需要一个真实结果的向量(测试数据集),来比较计算结果和真实结果:

library(xgboost)


#Use factor function to convert categorical data to numerical data
XGBoostDataSet_Hr_Admin_8$Salary = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Salary, levels =c('L','M', 'H', 'V'), labels =c(1,2,3,4)))
XGBoostDataSet_Hr_Admin_8$Rude_Behavior = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Rude_Behavior, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Feeling_undervalued =as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Feeling_undervalued, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Overall_satisfaction = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Overall_satisfaction, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Raises_frozen = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Raises_frozen, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Poor_Conditions = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Poor_Conditions, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Growth_not_available = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Growth_not_available, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Workplace_Conflict = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Workplace_Conflict, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Employee_Turnover = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Employee_Turnover, levels=c('Y', 'N'), labels =c(1,0)))

# here ifelse 0 1
XGBoostDataSet_Hr_Admin_8$Employee_Turnover = ifelse(XGBoostDataSet_Hr_Admin_8$Employee_Turnover == 1,0,1)

library(caTools)


split = sample.split(XGBoostDataSet_Hr_Admin_8$Employee_Turnover,SplitRatio = 0.7)
training_set8 = subset(XGBoostDataSet_Hr_Admin_8, split==TRUE)
test_set8 = subset(XGBoostDataSet_Hr_Admin_8, split==FALSE)

bst <- xgboost(data = as.matrix(training_set8[,-10]), label = training_set8$Employee_Turnover, max_depth = 2,
               eta = 0.5, nthread = 2, nrounds = 5, objective = "binary:logistic")  

# you've to do your prediction here
pred <- predict(bst, as.matrix(test_set8[,-10]))

# and transform them in a 0 1 variable, you can choose the value to get 1
pred <-  as.numeric(pred > 0.5)

library(caret)
confusionMatrix(factor(pred),factor(test_set8$Employee_Turnover))

Confusion Matrix and Statistics

          Reference
Prediction  0  1
         0 67  2
         1  0 16

               Accuracy : 0.9765          
                 95% CI : (0.9176, 0.9971)
    No Information Rate : 0.7882          
    P-Value [Acc > NIR] : 4.626e-07       

                  Kappa : 0.9265          

 Mcnemar's Test P-Value : 0.4795          

            Sensitivity : 1.0000          
            Specificity : 0.8889          
         Pos Pred Value : 0.9710          
         Neg Pred Value : 1.0000          
             Prevalence : 0.7882          
         Detection Rate : 0.7882          
   Detection Prevalence : 0.8118          
      Balanced Accuracy : 0.9444          

       'Positive' Class : 0   

以后提问的时候提供一些示例数据。

下面的代码使用 predict.xgb.Booster

中的示例创建了一个混淆矩阵
library("xgboost")
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test

bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
               eta = 0.5, nthread = 2, nrounds = 5, objective = "binary:logistic")
## Predict class probability for new data
pred <- predict(bst, test$data)
## Use arbitrary cutoff of 0.5 for classifier
table(test$label, as.numeric(pred > 0.5))
#        0    1
#  0   825   10
#  1     9  767

注意事项,您需要将您的training_set8$Employee_Turnover转换为0和1。希望你已经做到了,如果没有看到我下面的例子。

其次,需要说明,objective = "binary:logistic"做xgboost的时候,这个做分类。

所以从你拥有的开始:

library(caTools)
library(xgboost)
library(caret)
set.seed(12345)
# reproducible results

XGBoostDataSet_Hr_Admin_8 <- read.csv("CompletedDataImputed_HR_Admin.csv")

#Use factor function to convert categorical data to numerical data
XGBoostDataSet_Hr_Admin_8$Salary = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Salary, levels =c('L','M', 'H', 'V'), labels =c(1,2,3,4)))
XGBoostDataSet_Hr_Admin_8$Rude_Behavior = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Rude_Behavior, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Feeling_undervalued =as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Feeling_undervalued, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Overall_satisfaction = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Overall_satisfaction, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Raises_frozen = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Raises_frozen, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Poor_Conditions = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Poor_Conditions, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Growth_not_available = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Growth_not_available, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))
XGBoostDataSet_Hr_Admin_8$Workplace_Conflict = as.numeric(factor(XGBoostDataSet_Hr_Admin_8$Workplace_Conflict, levels=c('Y', 'M', 'N'), labels =c(1,2,3)))

对于这部分,我们将标签正确设置为 0 和 1

#set levels
lvl = c('N', 'Y')
# sorry I have to do it like this, it's too long for me to read
lb = as.character(XGBoostDataSet_Hr_Admin_8$Employee_Turnover)
lb = as.numeric(factor(lb,levels=lvl))-1
XGBoostDataSet_Hr_Admin_8$Employee_Turnover = lb

我们按照您的方式拆分为训练 + 测试:

#split the data in train dataset and test dataset
split = sample.split(XGBoostDataSet_Hr_Admin_8$Employee_Turnover,SplitRatio = 0.7)
training_set8 = subset(XGBoostDataSet_Hr_Admin_8, split==TRUE)
test_set8 = subset(XGBoostDataSet_Hr_Admin_8, split==FALSE)

合身:

#fitting XGBoost to the Training Test
classifier9 = xgboost(data = as.matrix(training_set8[-10]), 
label = training_set8$Employee_Turnover, nrounds = 10)

现在我们根据概率得到预测并转换

pred <- predict(classifier9, as.matrix(training_set8[-10]))
# we convert to predicted labels
pred_label <- lvl[as.numeric(pred>0.5)+1]
# we get the observed label, or iris$Species
actual_label <- lvl[as.numeric(training_set8$Employee_Turnover)+1]

最后一个混淆矩阵:

# confusion matrix
table(pred_label,actual_label)
          actual_label
pred_label   N   Y
         N  41   0
         Y   0 158

或使用插入符号:

confusionMatrix(factor(pred_label,levels=lvl),
factor(actual_label,levels=lvl))
    Confusion Matrix and Statistics

              Reference
    Prediction   N   Y
             N  41   0
             Y   0 158

这是实际数据(OP友情提供):

structure(list(Salary = structure(c(2L, 3L, 2L, 3L, 2L, 3L, 2L, 
2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 
3L, 2L, 3L, 2L, 2L, 3L, 1L, 2L, 2L, 3L, 3L, 2L, 3L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L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5, 10, 5, 
    5, 5, 5, 5, 5, 10, 5, 5, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 
    5, 10, 5, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 
    5, 5, 10, 7, 5, 5, 5, 5, 10, 10, 10, 5, 5, 5, 7, 10, 5, 5, 
    5, 7, 10, 5, 7, 5, 5, 10, 10, 10, 5, 5, 10, 5, 5, 5, 5, 5, 
    5, 5, 5, 10, 5, 5, 7, 7, 5, 10, 5, 5, 5, 5, 5, 7, 5, 10, 
    5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 5, 5, 5, 10, 5, 5, 
    5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 5, 5, 5, 5, 10, 5, 10, 5, 5, 
    5, 7, 5, 7, 10, 7, 10, 5, 10, 10, 5, 7, 5, 5, 10, 5, 5, 5, 
    10, 5, 7, 5, 5, 5, 5, 10, 3, 5, 5, 10, 10, 5, 5, 7, 10, 5, 
    5, 5, 5, 5, 5, 5, 10, 5, 7, 5, 5, 5, 5, 5, 7, 5, 7, 5, 5, 
    5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 7, 5, 5, 5, 10, 10, 5, 5, 5, 
    10, 5, 10, 10, 10, 10, 7, 5, 7, 5, 5, 10, 1, 10, 30, 1, 0.02, 
    5, 1, 11, 1, 3, 10, 1, 11, 1, 5, 10, 2.2, 18, 4, 10, 8, 1, 
    5, 9, 5, 4, 15, 15, 4, 10, 12, 1, 9, 3, 2.5, 5, 20, 30, 10, 
    5, 100, 10, 1, 1, 8, 1, 1, 2, 1, 5, 10, 1, 50, 50, 2, 3, 
    25, 1, 1), Rude_Behavior = structure(c(3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L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