BoxCoxEndogTransformer(lmbda2=0.4, neg_action="raise", floor=1e-12), ), ("arima", AutoARIMA(out_of_sample_size=60, max_p=4, max_q=4, max_d=4)), ] ) pipeline_arima = GroupedPmdarima(model_template=pipeline_obj).fit( df=training_data, group_key_columns=group_key_columns, y_col="y", datetime_col="ds", silence_warnings=True, ) # Save to local directory save_dir = "/tmp/group_pmdarima/pipeline.gpmd" pipeline_arima.save(save_dir) # Load from saved model loaded_model = GroupedPmdarima.load(save_dir) print("\nPipeline AutoARIMA results:\n", "-" * 40) get_and_print_model_metrics_params(loaded_model) print("\nPredictions:\n", "-" * 40) prediction = loaded_model.predict( n_periods=30, alpha=0.2, predict_col="predictions", return_conf_int=True ) print(prediction.to_string()) print("\nCross validation metric results:\n", "-" * 40) cross_validator = RollingForecastCV(h=30, step=365, initial=730)
training_data = generated_data.df group_key_columns = generated_data.key_columns # Build a GroupedPmdarima model by specifying an ARIMA model arima_obj = ARIMA(order=(2, 1, 3), out_of_sample_size=60) base_arima = GroupedPmdarima(model_template=arima_obj).fit( df=training_data, group_key_columns=group_key_columns, y_col="y", datetime_col="ds", silence_warnings=True, ) # Save to local directory save_dir = "/tmp/group_pmdarima/arima.gpmd" base_arima.save(save_dir) # Load from saved model loaded_model = GroupedPmdarima.load(save_dir) print("\nARIMA results:\n", "-" * 40) get_and_print_model_metrics_params(loaded_model) prediction = loaded_model.predict( n_periods=30, alpha=0.02, predict_col="forecast", return_conf_int=True ) print("\nPredictions:\n", "-" * 40) print(prediction.to_string()) print("\nCross validation metric results:\n", "-" * 40) cross_validator = SlidingWindowForecastCV(h=90, step=365, window_size=730)
test="kpss", max_d=4, ) grouped_model = GroupedPmdarima(model_template=pipeline).fit( df=training_data, group_key_columns=group_key_columns, y_col="y", datetime_col="ds", ndiffs=ndiff, silence_warnings=True, ) # Save to local directory save_dir = "/tmp/group_pmdarima/pipeline_override.gpmd" grouped_model.save(save_dir) # Load from saved model loaded_model = GroupedPmdarima.load(save_dir) print("\nAutoARIMA results:\n", "-" * 40) get_and_print_model_metrics_params(loaded_model) print("\nPredictions:\n", "-" * 40) prediction = loaded_model.predict( n_periods=30, alpha=0.1, predict_col="forecasted_values", return_conf_int=True ) print(prediction.to_string()) cv_evaluator = SlidingWindowForecastCV(h=90, step=120, window_size=180) cross_validation = loaded_model.cross_validate(