0
Map object is not subscriptable error を参照して、私は機能名を得るためにモーゼスの答えを使用しました。これは、 "Map object is subscriptable"というエラーを生成します。コードは以下の通りです。私はpython 3.xを使用していますスコアで選択した機能を取得するにはどうすればよいですか?
top_ranked_features = sorted(enumerate(ch2.scores_),key=lambda x:x[1], reverse=True)[:1000]
top_ranked_features_indices = map(list,zip(*top_ranked_features))[0]
for feature_pvalue in zip(np.asarray(train_vectorizer.get_feature_names())[top_ranked_features_indices],ch2.pvalues_[top_ranked_features_indices]):
print(feature_pvalue).
エラーは2行目のコードです。 Pythonの3.xでは
OUTPUT
('00 8b 4d fc', 3.4028916591534005e-61)
('51 00 22 05', 3.4028916591534005e-61)
('00 74 00 61', 8.3973527363656966e-61)
ありがとうございました。出来た。 – banu
@banu同じ投稿に余分な質問を追加すると混乱が生じるだけです。あたかもエラーと適切な出力が得られたかのように見えます。 2番目の質問を削除してください。新しい投稿で新しい質問をするか、既存のソリューションを検索することができます。 – Eran
ご指導ありがとうございます。 – banu