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

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

    I also had this problem when i used pandas DataFrame (non-sparse representation).

    I converted training and testing data into numpy ndarray.

              `X_train = X_train.as_matrix()
               X_test = X_test.as_matrix()` 
    

    This how i got rid of that Error!

提交回复
热议问题