AutoGluonでテーブルデータのAutoML
AutoGluonとは?
AutoGluonはAutoMLのフレームワークです。テーブル、時系列、マルチモーダルといった複数のデータの種類に対応しています。
今回はテーブルデータのAutoMLを試してみます。
インストール
!pip install autogluon
インポート
テーブルデータにはTabularPredictorを利用します。AutoGluonにはそれぞれデータの種類に応じたPredictorが実装されています。
from autogluon.tabular import TabularDataset, TabularPredictor
データセットの読み込み
data_url = 'https://raw.githubusercontent.com/mli/ag-docs/main/knot_theory/'
train_data = TabularDataset(f'{data_url}train.csv')
train_data.head()
![](https://assets.st-note.com/img/1710587208637-yQOeabautM.png?width=1200)
label = 'signature'
train_data[label].describe()
![](https://assets.st-note.com/img/1710587225360-SY8awm4IQt.png)
学習
TabularPredictorを利用して学習を行います。
predictor = TabularPredictor(label=label).fit(train_data)
学習を行うと以下のようなログが出力されます。
AutoGluonがどのように特徴量を抽出、選択し学習しているかを確認することができます。
![](https://assets.st-note.com/img/1710511026286-Ez5Bi8BXtQ.png?width=1200)
予測
predict()で予測を行います。
test_data = TabularDataset(f'{data_url}test.csv')
y_pred = predictor.predict(test_data.drop(columns=[label]))
y_pred.head()
評価
evaluate()で評価
predictor.evaluate(test_data, silent=True)
テストデータに対する各モデルの性能評価をleaderboard()で実施できます。
predictor.leaderboard(test_data)
![](https://assets.st-note.com/img/1710510672978-FSguDLKoEx.png?width=1200)