使用sklearn管道和功能联合

时间:2017-04-08 07:11:44

标签: python pandas scikit-learn

我似乎无法调试此问题。它说

from sklearn.pipeline import Pipeline, FeatureUnion
from Transformers import TextTransformer

a = TextTransformer('description', max_features=50)
b = TextTransformer('features', max_features=10)
pipeline = Pipeline([
    ('description', a ) # can pass in either a pipeline
    ])
pipeline2 = Pipeline([
    ('features', b) # can pass in either a pipeline
    ])
feat = FeatureUnion([
        ('dpipeline',pipeline),
        ('fpipeline', pipeline2),
    ])
pipe = Pipeline([
        ('featurize', feat),
        ('clf', SVC()),
    ])
pipe.fit(df,df['interest_level'])
pipe.predict(df)

错误:TypeError: expected string or buffer当我运行pipe.fit(df,df [' interest_level'])

为什么会这样?我尝试做的是拆分管道,然后将它们与功能联合联合起来。最终的管道将包含所有功能和最终估算。

0 个答案:

没有答案