# Gluon Train

このノートブックは、[AutoGluon](https://auto.gluon.ai/stable/index.html)を使用して予測モデルを構築し、データ処理、特徴エンジニアリング、モデル選択、アンサンブル、ハイパーパラメータチューニングを自動化します。

AutoGluonは、スタックアンサンブルを使用して複数のMLモデルを組み合わせます。サポートされているモデルには以下が含まれます:

* ニューラルネットワーク (MXNet、FastAI)
* 勾配ブースティングモデル (LightGBM、CatBoost、XGBoost)
* ランダムフォレスト
* エクストリームランダマイズドツリー
* k近傍法


## ワークフロー例

サンプルワークフローは[Treasure Boxes](https://github.com/treasure-data/treasure-boxes/blob/automl/machine-learning-box/automl/ml_experiment.dig)にあります。


```
+gluon_train:
  ml_train>:
    notebook: gluon_train
    model_name: gluon_model
    input_table: ml_dataset.bank_marketing
    target_column: loan
    time_limit: 3 * 60 # soft time limit in seconds
```

## パラメータ

| パラメータ名 | コンソール名 | 説明 | デフォルト |
|  --- | --- | --- | --- |
| docker.task_mem | Docker Task Mem | タスクメモリサイズ。利用可能: 64g、128g（デフォルト）、256g、384g、512g（ティアに依存）。 | 128g |
| input_table | Input Table | EDAに使用されるTDテーブル（dbname.table_name形式）。 | - |
| target_column | Target Column | ラベルとして使用される列名。 | - |
| model_name | Model Name | 予測モデル名。 | - |
| problem_type | Problem Type | binary、multiclass、regression、quantileのいずれか。指定されていない場合は推論されます。 | None |
| oversampling_threshold | Oversampling Threshold | SMOTE オーバーサンプリングを実行するための少数クラスの閾値率（バイナリのみ）。0で無効化。 | 0.001 |
| proba_calibration | Proba Calibration | オーバーサンプリング後に確率キャリブレーションを実行します。 | True |
| eval_metric | Eval Metric | 指定されていない場合は自動的に選択されます。 | None |
| ignore_columns | Ignore Columns | 無視する列。 | time |
| time_limit | Time Limit | 秒単位のソフト学習制限時間（最大24時間）。AutoGluonへのヒント。 | 60 * 60 |
| sampling_threshold | Sampling Threshold | サンプリングに使用される閾値。実行されたノートブックを参照してください。 | 10_000_000 |
| export_leaderboard | Export Leaderboard | 指定された場合、リーダーボードをTDテーブルとしてエクスポートします。 | None |
| export_feature_importance | Export Feature Importance | 指定された場合、特徴量重要度をTDテーブルとしてエクスポートします。 | None |
| exclude_models | Exclude Model | 無視するモデル。 | KNN |
| hide_table_contents | Hide Table Contents | テーブルの内容表示を抑制します。 | False |
| share_model | Share Model | アカウント内で学習済みモデルを共有します。 | False |
| refit_full | Refit Full | 全データでモデルを再学習します。選択肢: best、false、default。 | default |


使用可能なeval_metric値:

* Binary & Multiclass: accuracy、balanced_accuracy、f1、f1_macro、f1_micro、f1_weighted、average_precision、precision、precision_macro、precision_micro、precision_weighted、recall、recall_macro、recall_micro、recall_weighted、log_loss（マルチクラスのデフォルト）、pac_score
* Binary のみ: roc_auc（バイナリのデフォルト）、roc_auc_ovo_macro
* Regression: root_mean_squared_error（デフォルト）、mean_squared_error、mean_absolute_error、median_absolute_error、r2
* Quantile Regression: pinball_loss（デフォルト）


詳細については、[AutoGluonドキュメント](https://auto.gluon.ai/0.3.1/api/autogluon.predictor.md?highlight=eval_metric#module-0)を参照してください。