# 予測モデルでの変数重要度はどのような計算をしていますか？

**URL:** <https://community-ja.exploratory.io/t/topic/898>\
**Category:** 質問\
**Created:** [2023 年 4 月 13 日午前 10:30 UTC](https://community-ja.exploratory.io/t/topic/898 "2023-04-13T10:30:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Takato\_Shiroto](https://community-ja.exploratory.io/user_avatar/community-ja.exploratory.io/takato_shiroto/32/23_2.png) [@Takato\_Shiroto](https://community-ja.exploratory.io/u/Takato_Shiroto)\
**Post date:** [2023 年 4 月 13 日午前 10:30 UTC](https://community-ja.exploratory.io/t/topic/898/1 "2023-04-13T10:30:49Z")

</div>

変数重要度については、下記のセミナーにて詳しく紹介しておりますので、そちらをご参考ください。

> **[セミナー #56 - 機械学習モデル - 変数重要度の仕組みと解釈](https://exploratory.io/note/kanaugust/56-Svv7VWV8tA)**
>
> Created by Kan Nishida

また、変数重要度の仕組みについては、以下のようになります。

- 1つの予測変数を除いて（厳密にはシャッフルして）モデルを作り、除かなかった場合に比べて予測精度がどれだけ悪くなるのかを計算する。
- これを全ての変数で繰り返す。
- どれだけ予測精度が悪くなるのかというスコアをもとに、それぞれの変数の相対的な重要度を評価する。

計算の概念の例：

- 変数Aが含まれる時の予測精度: 90
- 変数Aが含まれない時の予測精度: 50
- 変数Aの重要度 = 90 - 50 = 40

詳細は以下をご覧ください。

> **[変数重要度の仕組み](https://exploratory.io/note/exploratory/dLm5rwn5)**
>
> Created by Takato Shiroto

変数重要度の計算の際にはmmpfパッケージのpermutationImportanceを使用しています。

この変数重要度の計算の際には、線形回帰のように数値を目的とした予測モデルであれば、「平均二乗誤差」を利用しています。ロジスティック回帰のようにロジカル型を目的とした予測モデルでは、「誤分類率」を使用しています。

変数重要度の具体的な計算式に興味がある場合は、下記のページが参考になるかと思います。

> **[5.5 Permutation Feature Importance | Interpretable Machine Learning](https://hacarus.github.io/interpretable-ml-book-ja/feature-importance.html)**
>
> Machine learning algorithms usually operate as black boxes and it is unclear how they derived a certain decision. This book is a guide for practitioners to make machine learning decisions interpretable.
