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,
Try converting data into ndarray before passing it to fit/predict. For eg: if your train data is train_df and test data is test_df. Use below code:
train_x = train_df.values
test_x = test_df.values
Now fit the model:
xgb.fit(train_x,train_y)
Finally, predict:
pred = xgb.predict(test_x)
Hope this helps!