形状不匹配XGBoost回归器



我已经在与我打算预测的测试数据形状不同的数据上训练了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)

我得到以下错误:形状不匹配错误

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

最新更新