我有以下管道:
sg = Pipeline([('tfidf', TfidfVectorizer()),
('normalize', Normalizer()),
('l1', LogisticRegression(penalty="l1", dual=False))])
在完成配件后,我想提取出相应的标记 到非零权重。
我该怎么做?
答案 0 :(得分:1)
features = pipeline.named_steps['tfidf'].get_feature_names()
print(features[pipeline.named_steps['l1'].coef_ != 0])
请参阅TfidfTransformer docs,LogisticRegression docs和unmerged improved pipeline docs here