【问题标题】:There is error in xgboost model . What is the meaning of this errorxgboost 模型有错误。这个错误是什么意思
【发布时间】:2021-05-03 22:04:36
【问题描述】:

特点

X = df[df.columns.drop("month_5_still_here")]

目标

y = df["month_5_still_here"]

将数据拆分为训练集和测试集

x_train, x_test, y_train, y_test = train_test_split(X,
                                                    y,
                                                    test_size = 0.5,
                                                    random_state = 12)

实例化 XGBClassifier:xg_cl

xg_cl = xgb.XGBClassifier(n_estimators = 10, objective = "binary:logistic")

使分类器适合训练集

xg_cl.fit(x_train, y_train)

预测测试集的标签:preds

y_pred = xg_cl.predict(x_test)

比较实际值和预测值

pd.DataFrame({"Actual": y_test, "Predicted": y_pred})
XGBoostError: [16:42:58] c:\users\administrator\workspace\xgboost-win64_release_1.4.0\src\data\array_interface.h:139: Check failed: typestr.size() == 3 (2 vs. 3) : `typestr' should be of format <endian><type><size of type in bytes>.

【问题讨论】:

  • 请正确格式化您的代码(阅读formatting help,显示complete error message,并在问题本身(不仅仅是标题)中提出您的问题,格式正确(问题应以@结尾987654331@).
  • 你能分享你的 xgboost 版本吗?

标签: python pandas xgboost


【解决方案1】:

我不知道你的数据集是什么样的,所以我不得不猜测一下。

  1. 也许 Python 会进行一些转换,例如 float 到 Int?

  2. 您的目标没有相同数量的行。

  3. 您的一个目标可能有一个额外的列

  4. 你的目标维度不一样。

您应该尝试调试它并观察代码的每一步。在调试期间检查所有数据框。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 2011-03-01
    相关资源
    最近更新 更多