形状不匹配 XGBoost 回归器

Shape Mismatch XGBoost Regressor

我已经针对与我打算预测的测试数据具有不同形状的数据训练了 XGBoost 回归器模型。有没有办法解决这个问题或可以容忍功能不匹配的模型?

在分类特征的一次热编码过程中,输入的训练数据和测试数据不匹配。

best_xgb = xgb.XGBRegressor(base_score=0.5, booster='gbtree', colsample_bylevel=1,
             colsample_bynode=1, colsample_bytree=1, enable_categorical=False,
             gamma=0, gpu_id=-1, importance_type=None,
             interaction_constraints='', learning_rate=0.05, max_delta_step=0,
             max_depth=6, min_child_weight=10,monotone_constraints='()', n_estimators=400, n_jobs=4,
             num_parallel_tree=1, predictor='auto', random_state=0, reg_alpha=0,
             reg_lambda=1, scale_pos_weight=1, subsample=1, tree_method='exact',
             validate_parameters=1, verbosity=None)

best_xgb.fit(X, y)

best_xgb.predict(test_data)

我收到以下错误: Shape Mismatch Error

请检查 249-235=14 个特征在测试数据中的位置。
或者适合相同的数据
best_xgb.fit(X[test_data.columns], y)