This notebook is created using PyCaret 2.0. Last updated : 21-08-2020
# check version
from pycaret.utils import version
version()
from pycaret.datasets import get_data
index = get_data('index')
data = get_data('juice')
from pycaret.classification import *
clf1 = setup(data, target = 'Purchase', session_id=123, log_experiment=True, experiment_name='juice1')
best_model = compare_models()
lr = create_model('lr')
dt = create_model('dt')
rf = create_model('rf', fold = 5)
models()
models(type='ensemble').index.tolist()
ensembled_models = compare_models(whitelist = models(type='ensemble').index.tolist(), fold = 3)
tuned_lr = tune_model(lr)
tuned_rf = tune_model(rf)
bagged_dt = ensemble_model(dt)
boosted_dt = ensemble_model(dt, method = 'Boosting')
blender = blend_models(estimator_list = [boosted_dt, bagged_dt], method = 'soft')
stacker = stack_models(estimator_list = [boosted_dt,bagged_dt,tuned_rf], meta_model=rf)
plot_model(rf)
plot_model(rf, plot = 'confusion_matrix')
plot_model(rf, plot = 'boundary')
evaluate_model(rf)
catboost = create_model('catboost', cross_validation=False)
interpret_model(catboost)
interpret_model(catboost, plot = 'correlation')
interpret_model(catboost, plot = 'reason', observation = 12)
best = automl(optimize = 'Recall')
best
pred_holdouts = predict_model(lr)
pred_holdouts.head()
new_data = data.copy()
new_data.drop(['Purchase'], axis=1, inplace=True)
predict_new = predict_model(lr, data=new_data)
predict_new.head()
save_model(lr, 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(lr, model_name = 'best-aws', authentication = {'bucket' : 'pycaret-test'})
X_train = get_config('X_train')
X_train.head()
get_config('seed')
from pycaret.classification import set_config
set_config('seed', 999)
get_config('seed')
get_system_logs()
!mlflow ui
# to generate csv file with experiment logs
get_logs()
Thank you. For more information / tutorials on PyCaret, please visit https://www.pycaret.org