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,
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.