简体   繁体   English

XGBoost 错误:功能名称不同

[英]XGBoost error: feature names are different

XGBoost gives this error: XGBoost 给出了这个错误:

Error in predict.xgb.Booster(m, newdata = data.matrix(.newdata), ...) : 
Feature names stored in `object` and `newdata` are different!

But, all these checks I run show no issues:但是,我运行的所有这些检查都没有问题:

dim(df1)[2] == dim(df2)[2]
names(df1) == names(df2)
names(df1) %in% names(df2)
names(df1) %in% names(df2)

df1Types = sapply(df1, class)
df2Types = sapply(df2, class)
df1Types == df2Types

Ideas?想法?

The factor levels must be the same in both data frames.两个数据框中的因子水平必须相同。 In addition, the order of the factors must be the same as well.此外,因素的顺序也必须相同。

-This may become a problem if you sort the order of the factors by their frequency in a data load function because the two data frames loaded with the same function may have factors with different orders. - 如果您在数据加载 function 中按频率对因子的顺序进行排序,这可能会成为问题,因为加载相同 function 的两个数据帧可能具有不同顺序的因子。 The data may also have different factors depending on the data itself.根据数据本身的不同,数据也可能具有不同的因素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM