簡體   English   中英

使用pdp包對xgboost進行分類的部分依賴圖

[英]partial dependency plot using pdp package for classification xgboost

我使用pdp包運行部分依賴關系,使用xgboost包進行線性回歸是完美的,沒有任何警告。 但是,當我更改為xgboost的分類(物流)標簽時。 我收到了有關部分依賴的警告消息,說部分依賴是基於線性的,如下所示。 請問是否必須以某種方式修改代碼以使用xgboost軟件包准確地提供分類對象,以便部分依賴項是正確的。 或者我可以忽略警告消息,它已經正確了。 我知道randomforest很簡單,沒有任何警告消息

# Load required packages
library(pdp)
library(xgboost)

# Simulate training data with ten million records
set.seed(101)
trn <- as.data.frame(mlbench::mlbench.friedman1(n = 1e+07, sd = 1))
trn=trn[sample(nrow(trn), 500), ]
trn$y=ifelse(trn$y>16,1,0)

# Fit an XGBoost classification(logistic) model
set.seed(102)
bst <- xgboost(data = data.matrix(subset(trn, select = -y)),
           label = trn$y,
           objective = "reg:logistic",
           nrounds = 100,
           max_depth = 2,
           eta = 0.1)
 #partial dependency plot

  pd <- partial(bst$handle,
            pred.var = c("x.1"), 
            grid.resolution = 10, 
            train = data.matrix(subset(trn, select = -y)),
            prob=TRUE,
            plot = FALSE,
            .progress = "text")

 Warning message:
 In superType.default(object) :
 `type` could not be determined; assuming `type = "regression"`

在這種情況下,您可以放心地忽略警告。 但是,它的確導致我發現了pdp軟件包中的一個小錯誤,我將很快對此進行修復。 感謝您的舉報!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM