Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save inoccu/2c74ee32d9ad5693699c28e185892e2a to your computer and use it in GitHub Desktop.
Save inoccu/2c74ee32d9ad5693699c28e185892e2a to your computer and use it in GitHub Desktop.

Notebookの基礎

import this

Pycaretのインストール

!pip install pycaret

データセットの読み込み

import pandas as pd

df = pd.read_csv('autos_titled_clean.csv')
df.head()

トレーニングデータとテストデータに分割

data = df.sample(frac=0.8, random_state=111)
data_unseen = df.drop(data.index)
data.reset_index(inplace=True, drop=True)
data_unseen.reset_index(inplace=True, drop=True)
print('Data for Modeling: ' + str(data.shape))
print('Unseen Data For Predictions: ' + str(data_unseen.shape))

Pycaret用にデータをセットアップ

from pycaret.regression import *
reg01 = setup(data=data, target='price')

アルゴリズムを選択

best_model = compare_models()

モデルの作成

model = create_model('ridge')

ハイパーパラメータのチューニング

tuned = tune_model(model)

モデルの評価

evaluate_model(tuned)

モデルのファイナライズ

final = finalize_model(tuned)
print(final)

予測の実行と精度評価

unseen_predictions = predict_model(final, data=data_unseen)
unseen_predictions.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment