我的SKLearn管道包含一个自定义处理,该处理“屈服”了返回值sample.process()。 管道中的下一个操作是TruncatedSVD,该操作由于似乎无法读取生成器对象而失败。
model = Pipeline([
('processor', Pipeline([
('processor', DocumentProcessor()),
('svd', TruncatedSVD())
])),
('selector', SelectKBest(score_func = chi2)),
('clf', None),
])
错误:
Expected 2D array, got scalar array instead:
array=<generator object DocumentProcessor.transform at 0x10ffcc5e8>.
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
我如何使TruncatedSVD接受生成器对象?