This notebook is created using PyCaret 2.0. Last updated : 28-07-2020
# check version
from pycaret.utils import version
version()
from pycaret.datasets import get_data
data = get_data('insurance')
from pycaret.regression import *
reg1 = setup(data, target = 'charges', session_id=123, log_experiment=True, experiment_name='insurance1')
best_model = compare_models(fold=5)
lightgbm = create_model('lightgbm')
lgbm= []
import numpy as np
for i in np.arange(0.1,1,0.1):
lgbm.append(create_model('lightgbm', learning_rate=i, verbose=False))
print(len(lgbm))
from interpret.glassbox import ExplainableBoostingRegressor
ebm = ExplainableBoostingRegressor()
ebm = create_model(ebm, fold = 3)
from interpret import show
ebm_global = ebm.explain_global()
show(ebm_global)
tuned_lightgbm = tune_model(lightgbm, n_iter=50, optimize = 'MAE')
tuned_lightgbm
dt = create_model('dt')
bagged_dt = ensemble_model(dt, n_estimators=50)
boosted_dt = ensemble_model(dt, method = 'Boosting')
blender = blend_models()
stacker = stack_models(estimator_list = compare_models(n_select=5, fold = 5, whitelist = models(type='ensemble').index.tolist()))
plot_model(dt)
plot_model(dt, plot = 'error')
plot_model(dt, plot = 'feature')
evaluate_model(dt)
interpret_model(lightgbm)
interpret_model(lightgbm, plot = 'correlation')
interpret_model(lightgbm, plot = 'reason', observation = 12)
best = automl(optimize = 'MAE')
best
pred_holdouts = predict_model(lightgbm)
pred_holdouts.head()
new_data = data.copy()
new_data.drop(['charges'], axis=1, inplace=True)
predict_new = predict_model(best, data=new_data)
predict_new.head()
save_model(best, model_name='best-model')
loaded_bestmodel = load_model('best-model')
print(loaded_bestmodel)
from sklearn import set_config
set_config(display='diagram')
loaded_bestmodel[0]
from sklearn import set_config
set_config(display='text')
deploy_model(best, model_name = 'best-aws', authentication = {'bucket' : 'pycaret-test'})
X_train = get_config('X_train')
X_train.head()
get_config('seed')
from pycaret.regression import set_config
set_config('seed', 999)
get_config('seed')
get_system_logs()
get_logs()
!mlflow ui
Thank you. For more information / tutorials on PyCaret, please visit https://www.pycaret.org