Feature Importance#
Note
Feature Importance はモデルの評価指標ではなく、特徴量ごとのモデルへの影響度を測るものである。
Feature Importance が何であるかはこちらで詳しく解説しているのでみておいてほしい。
'''
feature importance on original data
'''
if predictor.problem_type in {'binary', 'multiclass'}:
sampled_eval_data = stratified_sample(train_data, label, sampled_size=10000)
feature_importance = predictor.feature_importance(sampled_eval_data, subsample_size=None, num_shuffle_sets=3, time_limit=fi_time_limit)
del sampled_eval_data
else:
feature_importance = predictor.feature_importance(train_data, num_shuffle_sets=3, time_limit=fi_time_limit)
display(feature_importance)
このコードのアウトプットの一つに、Feature Importance を求めるのにかかった時間が表示される。まず、これにかかる時間は fi_time_limit
オプションで指定することができる。(デフォルト値は300秒。)以下の出力例では 222秒の時間を要したことがわかる。
INFO: Computing feature importance via permutation shuffling for 20 features using 4930 rows with 3 shuffle sets... Time limit: 300s...
INFO: 662.57s = Expected runtime (220.86s per shuffle set)
INFO: 222.44s = Actual runtime (Completed 3 of 3 shuffle sets)
この出力に続いて、Feature Importance の大きい順に特徴量が Bar Graph として表示される。

Fig. 41 Feature Importance の可視化#
続いて、それぞれの Feature Importance の全 Feature Importance に対する占有度を計算し、占有度の高い feature を積み上げていった Cumulative feature importance を出力する。0.95あたりまで積み上がれば、それらの feature で観測値を十分説明できるモデルが作れることになる。

Fig. 42 Cumulative feature importance の例。#