pycaret.time_series.create_model#
- pycaret.time_series.create_model(estimator: str | Any, fold: int | Any | None = None, round: int = 4, cross_validation: bool = True, fit_kwargs: dict | None = None, engine: str | None = None, verbose: bool = True, **kwargs)[source]#
This function trains and evaluates the performance of a given estimator using cross validation. The output of this function is a score grid with CV scores by fold. Metrics evaluated during CV can be accessed using the
get_metricsfunction. Custom metrics can be added or removed usingadd_metricandremove_metricfunction. All the available models can be accessed using themodelsfunction.Example
>>> from pycaret.datasets import get_data >>> airline = get_data('airline') >>> from pycaret.time_series import * >>> exp_name = setup(data = airline, fh = 12) >>> naive = create_model('naive')
- estimator: str or sktime compatible object
ID of an estimator available in model library or pass an untrained model object consistent with scikit-learn API. Estimators available in the model library (ID - Name):
NOTE: The available estimators depend on multiple factors such as what libraries have been installed and the setup of the experiment. As such, some of these may not be available for your experiment. To see the list of available models, please run setup() first, then models().
‘naive’ - Naive Forecaster
‘grand_means’ - Grand Means Forecaster
‘snaive’ - Seasonal Naive Forecaster (disabled when seasonal_period = 1)
‘polytrend’ - Polynomial Trend Forecaster
‘arima’ - ARIMA family of models (ARIMA, SARIMA, SARIMAX)
‘auto_arima’ - Auto ARIMA
‘exp_smooth’ - Exponential Smoothing
‘stlf’ - STL Forecaster
‘croston’ - Croston Forecaster
‘ets’ - ETS
‘theta’ - Theta Forecaster
‘tbats’ - TBATS
‘bats’ - BATS
‘prophet’ - Prophet Forecaster
‘lr_cds_dt’ - Linear w/ Cond. Deseasonalize & Detrending
‘en_cds_dt’ - Elastic Net w/ Cond. Deseasonalize & Detrending
‘ridge_cds_dt’ - Ridge w/ Cond. Deseasonalize & Detrending
‘lasso_cds_dt’ - Lasso w/ Cond. Deseasonalize & Detrending
‘llar_cds_dt’ - Lasso Least Angular Regressor w/ Cond. Deseasonalize & Detrending
‘br_cds_dt’ - Bayesian Ridge w/ Cond. Deseasonalize & Deseasonalize & Detrending
‘huber_cds_dt’ - Huber w/ Cond. Deseasonalize & Detrending
‘omp_cds_dt’ - Orthogonal Matching Pursuit w/ Cond. Deseasonalize & Detrending
‘knn_cds_dt’ - K Neighbors w/ Cond. Deseasonalize & Detrending
‘dt_cds_dt’ - Decision Tree w/ Cond. Deseasonalize & Detrending
‘rf_cds_dt’ - Random Forest w/ Cond. Deseasonalize & Detrending
‘et_cds_dt’ - Extra Trees w/ Cond. Deseasonalize & Detrending
‘gbr_cds_dt’ - Gradient Boosting w/ Cond. Deseasonalize & Detrending
‘ada_cds_dt’ - AdaBoost w/ Cond. Deseasonalize & Detrending
‘lightgbm_cds_dt’ - Light Gradient Boosting w/ Cond. Deseasonalize & Detrending
‘catboost_cds_dt’ - CatBoost w/ Cond. Deseasonalize & Detrending
- fold: int or scikit-learn compatible CV generator, default = None
Controls cross-validation. If None, the CV generator in the
fold_strategyparameter of thesetupfunction is used. When an integer is passed, it is interpreted as the ‘n_splits’ parameter of the CV generator in thesetupfunction.- round: int, default = 4
Number of decimal places the metrics in the score grid will be rounded to.
- cross_validation: bool, default = True
When set to False, metrics are evaluated on holdout set.
foldparam is ignored when cross_validation is set to False.- fit_kwargs: dict, default = {} (empty dict)
Dictionary of arguments passed to the fit method of the model.
- engine: Optional[str] = None
The engine to use for the model, e.g. for auto_arima, users can switch between “pmdarima” and “statsforecast” by specifying engine=”statsforecast”.
- verbose: bool, default = True
Score grid is not printed when verbose is set to False.
- **kwargs:
Additional keyword arguments to pass to the estimator.
- Returns:
Trained Model
Warning
Models are not logged on the
MLFlowserver whencross_validationparam is set to False.