Skip to content

Instantly share code, notes, and snippets.



Created Aug 1, 2020
What would you like to do?
# import libraries
import pandas as pd
import sys
# define command line parameters
data = sys.argv[1]
target = sys.argv[2]
# load data (replace this part with your own script)
from pycaret.datasets import get_data
input_data = get_data(data)
# init setup
from pycaret.classification import *
clf1 = setup(data = input_data, target = target, log_experiment = True)
# compare baseline models and select top5
top5 = compare_models(n_select = 5)
# tune top5 models
tuned_top5 = [tune_model(i) for i in top5]
# ensemble top5 tuned models
bagged_tuned_top5 = [ensemble_model(i, method = 'Bagging') for i in tuned_top5]
# blend top5 models
blender = blend_models(estimator_list = top5)
# stack top5 models
stacker = stack_models(estimator_list = top5[1:], meta_model = top5[0])
# select best model based on recall
best_model = automl(optimize = 'Recall')
# save model
save_model(best_model, 'c:/path-to-directory/final-model')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.