ValueError: feature_names mismatch: in xgboost in the predict() function

后端 未结 8 1848
悲哀的现实
悲哀的现实 2020-12-25 13:15

I have trained an XGBoostRegressor model. When I have to use this trained model for predicting for a new input, the predict() function throws a feature_names mismatch error,

8条回答
  •  鱼传尺愫
    2020-12-25 13:33

    Do this while creating the DMatrix for XGB:

    dtrain = xgb.DMatrix(np.asmatrix(X_train), label=y_train)
    dtest = xgb.DMatrix(np.asmatrix(X_test), label=y_test)
    

    Do not pass X_train and X_test directly.

提交回复
热议问题