尝试get_params()
在您的最终管道对象上运行,而不仅仅是估算器。这样,它将为网格参数生成所有可用的管道项唯一键。
sorted(pipeline.get_params().keys())
['classifier','classifier__bootstrap','classifier__class_weight','classifier__criterion','classifier__max_depth',
'classifier__max_features',
'classifier__max_leaf_nodes', 'classifier__min_impurity_split', 'classifier__min_samples_leaf', 'classifier__min_samples_split', 'classifier__min_weight_fraction_leaf', 'classifier__n_estimators', 'classifier__n_jobs', 'classifier__oob_score', 'classifier__random_state', 'classifier__verbose', 'classifier__warm_start', 'steps', 'tfidf ','tfidf__analyzer','tfidf__binary','tfidf__decode_error','tfidf__dtype','tfidf__encoding','tfidf__input','tfidf__lowercase','tfidf__max_df','tfidf__max_features','tfidf__min_df','tfidf__ngram_range','tfidf__ngram_range', 'tfidf__预处理器','tfidf__smooth_idf','tfidf__stop_words','tfidf__strip_accents','tfidf__sublinear_tf','tfidf__token_pattern','tfidf__tokenizer','tfidf__use_idf','tfidf__vocabulary']
当您使用make_pipeline()
Piplines 的简短语法时,这特别有用,您不必为管道项的标签而烦恼:
pipeline = make_pipeline(TfidfVectorizer(), RandomForestClassifier())
sorted(pipeline.get_params().keys())
['randomforestclassifier','randomforestclassifier__bootstrap','randomforestclassifier__class_weight','randomforestclassifier__criterion','randomforestclassifier__max_depth',
'randomforestclassifier__max_features',
'randomforestclassifier__max_leaf_nodes', 'randomforestclassifier__min_impurity_split', 'randomforestclassifier__min_samples_leaf', 'randomforestclassifier__min_samples_split', 'randomforestclassifier__min_weight_fraction_leaf', 'randomforestclassifier__n_estimators', 'randomforestclassifier__n_jobs', 'randomforestclassifier__oob_score', 'randomforestclassifier__random_state', 'randomforestclassifier__verbose', 'randomforestclassifier__warm_start', 'steps', 'tfidfvectorizer ','tfidfvectorizer__analyzer','tfidfvectorizer__binary','tfidfvectorizer__decode_error','tfidfvectorizer__dtype','tfidfvectorizer__encoding','tfidfvectorizer__input','tfidfvectorizer__lowercase', 'tfidfvectorizer__max_df', 'tfidfvectorizer__max_features', 'tfidfvectorizer__min_df', 'tfidfvectorizer__ngram_range', 'tfidfvectorizer__norm', 'tfidfvectorizer__preprocessor', 'tfidfvectorizer__smooth_idf', 'tfidfvectorizer__stop_words', 'tfidfvectorizer__strip_accents', 'tfidfvectorizer__sublinear_tf', 'tfidfvectorizer__token_pattern', 'tfidfvectorizer__tokenizer', ' tfidfvectorizer__use_idf', 'tfidfvectorizer__vocabulary']tfidfvectorizer__stop_words','tfidfvectorizer__strip_accents','tfidfvectorizer__sublinear_tf','tfidfvectorizer__token_pattern','tfidfvectorizer__tokenizer','tfidfvectorizer__use_idf','tfidfvectorizer__vocabulary']tfidfvectorizer__stop_words','tfidfvectorizer__strip_accents','tfidfvectorizer__sublinear_tf','tfidfvectorizer__token_pattern','tfidfvectorizer__tokenizer','tfidfvectorizer__use_idf','tfidfvectorizer__vocabulary']