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

后端 未结 8 1827
悲哀的现实
悲哀的现实 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:30

    From what I could find, the predict function does not take the DataFrame (or a sparse matrix) as input. It is one of the bugs which can be found here https://github.com/dmlc/xgboost/issues/1238

    In order to get around this issue, use as_matrix() function in case of a DataFrame or toarray() in case of a sparse matrix.

    This is the only workaround till the bug is fixed or the feature is implemented in a different manner.

提交回复
热议问题