Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter3:特徴量の名前と重要度を出力している部分について #5

Open
kawase621 opened this issue Dec 28, 2024 · 1 comment

Comments

@kawase621
Copy link

Chapter3で重要度の高い順に特徴量の名前と重要度を出力している部分に誤りがあるように思います。

for feat  in range(Features):
    print(
        "Feature: {}Importance: {:.5f}"\
          .format(MalwareDataset.columns[2+Index[feat]].ljust(30),
                  FI[Index[feat]])
          )

「Index」という変数は、以下のようなフローでできていると思います。
①SelectFromModelを使って重要度の大きい特徴量のみに削減した変数「X」でExtraTreeClassifierを学習(fit)。
②ExtraTreeClassifierの特徴量の重要度をリスト形式で出力(FI)。
③FIから重要度の高い順にインデックスを作成(Index)。
つまり、FIの次元、すなわち特徴量の個数は削減後のものという認識です。

一方で、MalwareDatasetは削減前の特徴量を持ったままです。

よって、削減前の要素数を持つMalwareDatasetに対して、削減後のインデックスを使って「MalwareDataset.colums[2+Index[feat]]」のように特徴量の名前を取得しようとしているので、間違った結果になるはずです。

@nenaiko-dareda
Copy link
Collaborator

知らせてくださり、ありがとうございます!

確認した上で修正させていただきます!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants