Issue
I have data at two stages:
import numpy as np
data_pre = np.array([[1., 2., 203.],
[0.5, np.nan, 208.]])
data_post = np.array([[2., 2., 203.],
[0.5, 2., 208.]])
I also have two pre-existing fitted estimators:
from sklearn.preprocessing import Imputer
from sklearn.ensemble import GradientBoostingRegressor
imp = Imputer(missing_values=np.nan, strategy='mean', axis=1).fit(data_pre)
gbm = GradientBoostingRegressor().fit(data_post[:,:2], data_post[:,2])
I need to pass a fitted pipeline and data_pre
to another function.
def the_function_i_need(estimators):
"""
"""
return fitted pipeline
fitted_pipeline = the_function_i_need([imp, gbm])
sweet_output = static_function(fitted_pipeline, data_pre)
Is there a way to combine these two existing and fitted model objects into a fitted pipeline without refitting the models or am I out of luck?
Solution
...A few years later.
Use make_pipeline()
to concatenate scikit-learn estimators as:
new_model = make_pipeline(fitted_preprocessor,
fitted_model)
Answered By - Cristobal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.