pycaret.regression.automl#
- pycaret.regression.automl(optimize: str = 'R2', use_holdout: bool = False, turbo: bool = True, return_train_score: bool = False) Any[source]#
This function returns the best model out of all trained models in current session based on the
optimizeparameter. Metrics evaluated can be accessed using theget_metricsfunction.Example
>>> from pycaret.datasets import get_data >>> boston = get_data('boston') >>> from pycaret.regression import * >>> exp_name = setup(data = boston, target = 'medv') >>> top3 = compare_models(n_select = 3) >>> tuned_top3 = [tune_model(i) for i in top3] >>> blender = blend_models(tuned_top3) >>> stacker = stack_models(tuned_top3) >>> best_mae_model = automl(optimize = 'MAE')
- optimize: str, default = ‘R2’
Metric to use for model selection. It also accepts custom metrics added using the
add_metricfunction.- use_holdout: bool, default = False
When set to True, metrics are evaluated on holdout set instead of CV.
- turbo: bool, default = True
When set to True and use_holdout is False, only models created with default fold parameter will be considered. If set to False, models created with a non-default fold parameter will be scored again using default fold settings, so that they can be compared.
- return_train_score: bool, default = False
If False, returns the CV Validation scores only. If True, returns the CV training scores along with the CV validation scores. This is useful when the user wants to do bias-variance tradeoff. A high CV training score with a low corresponding CV validation score indicates overfitting.
- Returns:
Trained Model