I created a pipeline for imputing nan values, SelectPercentile for feature selection and GridSearchCV to find best parameters. I am okey with mean absolute error X_test, y_test and I decided to use this best estimator which pipeline gives me on new dataset (production dataset). But I think for to use it on production it is better to fit all data (X_train + X_test) rather than only X_train which pipeline does. How can i achieve fitting all data using the pipeline results ?
regr = make_pipeline(SimpleImputer(missing_values=np.nan, strategy='median'),
SelectPercentile(f_regression),
GradientBoostingRegressor())
param_grid = {"selectpercentile__percentile": [50, 60, 70],
"gradientboostingregressor__max_depth": [1, 2, 3],
"gradientboostingregressor__subsample": [0.7,0.8],
"gradientboostingregressor__learning_rate": [0.005, 0.008, 0.012],
"gradientboostingregressor__n_estimators": [1000, 1500]}
grid = GridSearchCV(regr, param_grid, cv = 5)
grid.fit(X_train, y_train.values.ravel())
print("Best cross-validation score : {:.2f}".format(grid.best_score_))
print("Best parameters :", grid.best_params_)
best_model = gridsearch.best_estimator_
mean_absolute_error(y_test,grid.predict(X_test))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…