Scikit Learn を使用して、データフレーム内の各機能の重要性を見つけたいと考えています。
スコアとその横にある機能名を提供するWEKAソフトウェアを介してInfo Gainを使用する代わりに、Scikit Learnで使用しようとしています。
次の方法を実装したのですが、順位番号をスコアに置き換える方法がわかりません。
例えば:
見たくない:
- 特徴6
- 特徴4
...
ただし、私は次のことを好みます。
0.4 機能 6
0.233 機能 4
...
これが私の方法です:
def _rank_features(self, dataframe, targeted_class):
from sklearn.feature_selection import RFE
from sklearn.linear_model import LinearRegression
feature_names = list(dataframe.columns.values)
# use linear regression as the model
lr = LinearRegression()
# rank all features, i.e continue the elimination until the last one
rfe = RFE(lr, n_features_to_select=1)
rfe.fit(dataframe, targeted_class)
print "Features sorted by their rank:"
print sorted(zip(map(lambda x: round(x, 4), rfe.ranking_), feature_names))
誰かがランキングからスコアに変換する方法を知っていますか?