您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

从Scikit(Python)中的管道检索中间特征

5b51 2022/1/14 8:23:30 python 字数 1620 阅读 587 来源 www.jb51.cc/python

我使用的管道非常类似于 in this example: >>> text_clf = Pipeline([('vect', CountVectorizer()), ... ('tfidf', TfidfTransformer()), ... ('clf', MultinomialNB()), ... ]) 我使用

概述

>>> text_clf = Pipeline([('vect',CountVectorizer()),...                      ('tfidf',TfidfTransformer()),...                      ('clf',MultinomialNB()),... ])

我使用gridsearchcv在参数网格上找到最佳估算器.

但是,我想从CountVectorizer()获取get_feature_names()方法的训练集的列名.如果没有在管道外实现CountVectorizer(),这可能吗?

text_clf = Pipeline([('vect',('tfidf',('clf',MultinomialNB())]
print text_clf.get_params()['vect']

收益率(对我来说)

CountVectorizer(analyzer=u'word',binary=False,decode_error=u'strict',dtype=<type 'numpy.int64'>,encoding=u'utf-8',input=u'content',lowercase=True,max_df=1.0,max_features=None,min_df=1,ngram_range=(1,1),preprocessor=None,stop_words=None,strip_accents=None,token_pattern=u'(?u)\\b\\w\\w+\\b',tokenizer=None,vocabulary=None)

我没有将管道安装到此示例中的任何数据,因此此时调用get_feature_names()将返回错误.

总结

以上是编程之家为你收集整理的从Scikit(Python)中的管道检索中间特征全部内容,希望文章能够帮你解决从Scikit(Python)中的管道检索中间特征所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶