I'm trying to train multi-output XGBoost regression model using the continuation training, but I get this error:
TypeError: ('Unknown type:', MultiOutputRegressor(estimator=XGBRegressor(base_score=None, booster=None)
My code is as follows:
params = {
'n_estimators':2000,
'learning_rate':0.001,
'max_depth':6,
'min_child_weight': 1,
'eta':.3,
'subsample': 1,
'colsample_bytree': 1,
'objective':'reg:squarederror',}
path = os.path.join('.', "xgb_model_direct.pkl")
for i, (x_batch, y_batch, _, _, _, _) in enumerate(pca_train_ds):
# transform X: (batch_size, num_components, input_horizon_steps) -->
# (batch_size, num_components*input_horizon_steps)
x_batch = x_batch.numpy().reshape(x_batch.shape[0], -1)
# transform Y: (batch_size, num_components) -->
#(batch_size , num_components)
y_batch = y_batch.numpy().reshape(y_batch.shape[0], -1)
# define model
model = xgb.XGBRegressor(**params)
# define the direct multioutput wrapper model
wrapper = MultiOutputRegressor(model)
if i==0:
wrapper.fit(x_batch, y_batch)
# save model to file
joblib.dump(wrapper, path)
else:
# load model from file
loaded_model = joblib.load(path)
wrapper.fit(x_batch, y_batch, xgb_model=loaded_model)