Tuesday, August 28, 2018

Scikit-learn 5. Hands-on python scikit-learn: using pipelines.

Pipeline is a way to shorten the code and make it simpler.

>>> from sklearn.model_selection import train_test_split
>>> from sklearn.ensemble import RandomForestRegressor
>>> from sklearn.preprocessing import Imputer
>>> from sklearn.pipeline import make_pipeline
>>>
>>> test_pipeline = make_pipeline(Imputer(), RandomForestRegressor())
>>> # as you see imputation is done automatically
>>> test_pipeline.fit(train_X,train_y) 
>>> predictions = test_pipeline.predict(test_X)

No comments:

Post a Comment