New Function

This is a new function introduced in PyCaret 2.0x. 


This function returns the best model out of all models created in the current active environment based on metric defined in optimize parameter. Run this code at the end of  your script.

This function is only available in pycaret.classification and pycaret.regression modules.




# loading dataset 
from pycaret.datasets import get_data 
data = get_data('diabetes') 

# initializing setup 
from pycaret.classification import *
clf1 = setup(data, target = 'Class variable') 

# compare all baseline models and select top 5
top5 = compare_models(n_select = 5) 

# tune top 5 base models
tuned_top5 = [tune_model(i) for i in top5]

# ensemble top 5 tuned models
bagged_top5 = [ensemble_model(i) for i in tuned_top5]

# blend top 5 base models 
blender = blend_models(estimator_list = top5) 

# select best model 
best = automl(optimize = 'Recall')



No output. Best performing model returned.

Try this next