sklearn.pipeline.Pipeline,sklearn.pipeline.make_pipeline
Pipeline & make_pipeline
就是将预处理和模型合并到一起写
通过steps设定数据处理流,格式为(‘key’,’value’),key为自定义名,value为对应的处理类。通过list传入,前n-1个为transform函数,最后一个为模型,举例如下:12345678from sklearn.pipeline import Pipeline from sklearn.svm import SVC from sklearn.decomposition import PCA from sklearn.datasets import load_irispipe=Pipeline(steps=[('pca',PCA()),('svc',SVC())]) iris=load_iris() pipe.fit(iris.data,iris.target)pipe.predict(iris.data)
make_pipeline函数与Pipeline的区别就是不用写key了,如下:1p=make_pipeline(StandardScaler(),GaussianNB())
详细参考官网,及sklearn学习笔记3——pipeline