3
1

More than 1 year has passed since last update.

AutoGluonでテーブルデータの分析やーる

Last updated at Posted at 2022-12-17

はじめに

これやっていきます

開発環境

  • Windows 10 PC
  • Python 3.9

導入

pip install autogluon

(※GPUで実行する場合)
pip install torch==1.12.0+cu113 torchvision==0.13.0+cu113 torchtext==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu113

from autogluon.tabular import TabularDataset, TabularPredictor
train_data = TabularDataset('https://autogluon.s3.amazonaws.com/datasets/Inc/train.csv')
test_data = TabularDataset('https://autogluon.s3.amazonaws.com/datasets/Inc/test.csv')
predictor = TabularPredictor(label='class').fit(train_data=train_data)
predictions = predictor.predict(test_data)

AutoGluon training complete, total runtime = 513.17s ... Best model: "WeightedEnsemble_L2"
TabularPredictor saved. To load, use: predictor = TabularPredictor.load("AutogluonModels/ag-20221024_125633")

AutogluonModels/ag-20221024_125633に.pklで保存される
image.png

from autogluon.multimodal import MultiModalPredictor
from datasets import load_dataset
train_data = load_dataset("glue", 'mrpc')['train'].to_pandas().drop('idx', axis=1)
test_data = load_dataset("glue", 'mrpc')['validation'].to_pandas().drop('idx', axis=1)
predictor = MultiModalPredictor(label='label').fit(train_data)
predictions = predictor.predict(test_data)
score = predictor.evaluate(test_data)

load_offloaded_weightsのエラー
RuntimeError: Failed to import transformers.models.gpt2.modeling_gpt2 because of the following error (look up to see its traceback):
cannot import name 'load_offloaded_weights' from 'accelerate.utils' (C:\Users\good_\anaconda3\envs\py39\lib\site-packages\accelerate\utils_init_.py)

pip install --upgrade accelerate
Successfully uninstalled accelerate-0.8.0
Successfully installed accelerate-0.13.2

datasetsが見つからないエラー
ModuleNotFoundError: No module named 'datasets'
pip install --upgrade mxnet

AttributeError: module 'numpy.random' has no attribute 'Generator'
pip install --upgrade numpy

Successfully uninstalled numpy-1.16.6
Successfully installed numpy-1.23.4

ImportError: cannot import name 'PROTOCOL_TLS' from 'urllib3.util.ssl_' (C:\Users\good_\anaconda3\envs\py39\lib\site-packages\urllib3\util\ssl_.py)
Successfully uninstalled urllib3-1.22
Successfully installed urllib3-1.26.12

pip install datasets
最初からこれでよかったんじゃw

RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1