【问题标题】:I got this error 'DataFrame.dtypes for data must be int, float, bool or categorical' - xgboost XGBRFRegressor我收到此错误\'DataFrame.dtypes for data must be int, float, bool or categorical\' - xgboost XGBRFRegressor
【发布时间】:2022-11-08 00:45:09
【问题描述】:

我将把它训练为一个 xgboost 模型(XGBRFRegressor)。

但是发生了这种错误,我以前从未见过这样的错误。


ValueError: DataFrame.dtypes for data must be int, float, bool or category.  When
categorical type is supplied, DMatrix parameter `enable_categorical` must
be set to `True`. Invalid columns:


代码:

from xgboost import XGBRFRegressor
# creating object of XGBoost
model_xgb = XGBRFRegressor(max_depth=8, n_estimators = 10)
# Training model
model_xgb.fit(X_train, y_train)
# Predicting values
pred_xgb = model_xgb.predict(X_test)
# Evaluation metrics "Mean Squared Error"
mae_xgb = np.sqrt(mean_squared_error(y_test, pred_xgb))
print(mae_xgb)

我怎么解决这个问题?

【问题讨论】:

    标签: python python-3.x xgboost


    【解决方案1】:

    将你得到的字段转换为 int,然后检查失败的列是否与该字段相关。

    改造它

    【讨论】:

      猜你喜欢
      • 2022-08-17
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-08
      相关资源
      最近更新 更多