変数の重要度

Rで学ぶ特徴量エンジニアリング

Jorge Zazueta

Research Professor. Head of the Modeling Group at the School of Economics, UASLP

予測変数を追加する

より完全なモデルは多くの変数を含みます。

lr_model <- logistic_reg()
lr_recipe <- 
  recipe(class~ sponsor_code +
         contract_value_band +
         category_code, 
         data = grants_train) %>%
  step_lencode_glm(sponsor_code,
                   contract_value_band,
                   category_code, 
                   outcome = vars(class))

より納得できる結果が得られます。

lr_aug %>% class_evaluate(truth = class,
               estimate = .pred_class,
               .pred_successful)
# A tibble: 2 × 3
  .metric  .estimator .estimate
  <chr>    <chr>          <dbl>
1 accuracy binary         0.890
2 roc_auc  binary         0.951
Rで学ぶ特徴量エンジニアリング

どの変数が重要か?

vip() パッケージで重要度順に並べた特徴量を可視化できます。

lr_fit %>%
  extract_fit_parsnip() %>%
  vip(aesthetics = 
      list(fill = "steelblue"))

変数重要度チャート

変数重要度の棒グラフ。

Rで学ぶ特徴量エンジニアリング

変数重要度と特徴量エンジニアリング

変数重要度は、ドメイン知識に基づく特徴量エンジニアリングを見直す強力なフィードバック手段になります。

変数重要度と特徴量エンジニアリングのワークフロー。

Rで学ぶ特徴量エンジニアリング

練習しましょう!

Rで学ぶ特徴量エンジニアリング

Preparing Video For Download...