diff --git a/nixtlats/client.py b/nixtlats/client.py index 35f489ef..c42bbcce 100644 --- a/nixtlats/client.py +++ b/nixtlats/client.py @@ -12,8 +12,15 @@ from .core.jsonable_encoder import jsonable_encoder from .errors.unprocessable_entity_error import UnprocessableEntityError from .types.http_validation_error import HttpValidationError +from .types.multi_series_anomaly_model import MultiSeriesAnomalyModel +from .types.multi_series_cross_validation_finetune_loss import MultiSeriesCrossValidationFinetuneLoss +from .types.multi_series_cross_validation_model import MultiSeriesCrossValidationModel +from .types.multi_series_forecast_finetune_loss import MultiSeriesForecastFinetuneLoss +from .types.multi_series_forecast_model import MultiSeriesForecastModel from .types.multi_series_input import MultiSeriesInput +from .types.multi_series_insample_forecast_model import MultiSeriesInsampleForecastModel from .types.single_series_forecast import SingleSeriesForecast +from .types.single_series_insample_forecast_model import SingleSeriesInsampleForecastModel # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -54,7 +61,7 @@ def timegpt(self, *, request: SingleSeriesForecast) -> typing.Any: def timegpt_historic( self, *, - model: typing.Optional[str] = OMIT, + model: typing.Optional[SingleSeriesInsampleForecastModel] = OMIT, freq: typing.Optional[str] = OMIT, level: typing.Optional[typing.List[typing.Any]] = OMIT, y: typing.Optional[typing.Any] = OMIT, @@ -65,7 +72,7 @@ def timegpt_historic( Based on the provided data, this endpoint predicts time series data for the in-sample period (historical period). It takes a JSON as an input, including information like the series frequency and the historical data. (See below for a full description of the parameters.) The response contains the predicted values for the historical period. Usually useful for anomaly detection. Get your token for private beta at https://dashboard.nixtla.io. Parameters: - - model: typing.Optional[str]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + - model: typing.Optional[SingleSeriesInsampleForecastModel]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. - freq: typing.Optional[str]. The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available. @@ -110,7 +117,7 @@ def timegpt_historic( def timegpt_multi_series( self, *, - model: typing.Optional[str] = OMIT, + model: typing.Optional[MultiSeriesForecastModel] = OMIT, freq: typing.Optional[str] = OMIT, level: typing.Optional[typing.List[typing.Any]] = OMIT, fh: typing.Optional[int] = OMIT, @@ -118,12 +125,13 @@ def timegpt_multi_series( x: typing.Optional[MultiSeriesInput] = OMIT, clean_ex_first: typing.Optional[bool] = OMIT, finetune_steps: typing.Optional[int] = OMIT, + finetune_loss: typing.Optional[MultiSeriesForecastFinetuneLoss] = OMIT, ) -> typing.Any: """ Based on the provided data, this endpoint predicts the future values of multiple time series at once. It takes a JSON as an input containing information like the series frequency and historical data. (See below for a full description of the parameters.) The response contains the predicted values for each series based on the input arguments. Get your token for private beta at https://dashboard.nixtla.io. Parameters: - - model: typing.Optional[str]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + - model: typing.Optional[MultiSeriesForecastModel]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. - freq: typing.Optional[str]. The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available. @@ -138,6 +146,8 @@ def timegpt_multi_series( - clean_ex_first: typing.Optional[bool]. A boolean flag that indicates whether the API should preprocess (clean) the exogenous signal before applying the large time model. If True, the exogenous signal is cleaned; if False, the exogenous variables are applied after the large time model. - finetune_steps: typing.Optional[int]. The number of tuning steps used to train the large time model on the data. Set this value to 0 for zero-shot inference, i.e., to make predictions without any further model tuning. + + - finetune_loss: typing.Optional[MultiSeriesForecastFinetuneLoss]. The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers. """ _request: typing.Dict[str, typing.Any] = {} if model is not OMIT: @@ -156,6 +166,8 @@ def timegpt_multi_series( _request["clean_ex_first"] = clean_ex_first if finetune_steps is not OMIT: _request["finetune_steps"] = finetune_steps + if finetune_loss is not OMIT: + _request["finetune_loss"] = finetune_loss _response = self._client_wrapper.httpx_client.request( "POST", urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "timegpt_multi_series"), @@ -176,7 +188,7 @@ def timegpt_multi_series( def timegpt_multi_series_historic( self, *, - model: typing.Optional[str] = OMIT, + model: typing.Optional[MultiSeriesInsampleForecastModel] = OMIT, freq: typing.Optional[str] = OMIT, level: typing.Optional[typing.List[typing.Any]] = OMIT, y: typing.Optional[typing.Any] = OMIT, @@ -187,7 +199,7 @@ def timegpt_multi_series_historic( Based on the provided data, this endpoint predicts the in-sample period (historical period) values of multiple time series at once. It takes a JSON as an input containing information like the series frequency and historical data. (See below for a full description of the parameters.) The response contains the predicted values for the historical period. Usually useful for anomaly detection. Get your token for private beta at https://dashboard.nixtla.io. Parameters: - - model: typing.Optional[str]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + - model: typing.Optional[MultiSeriesInsampleForecastModel]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. - freq: typing.Optional[str]. The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available. @@ -232,7 +244,7 @@ def timegpt_multi_series_historic( def timegpt_multi_series_anomalies( self, *, - model: typing.Optional[str] = OMIT, + model: typing.Optional[MultiSeriesAnomalyModel] = OMIT, freq: typing.Optional[str] = OMIT, level: typing.Optional[typing.List[typing.Any]] = OMIT, y: typing.Optional[typing.Any] = OMIT, @@ -243,7 +255,7 @@ def timegpt_multi_series_anomalies( Based on the provided data, this endpoint detects the anomalies in the historical perdiod of multiple time series at once. It takes a JSON as an input containing information like the series frequency and historical data. (See below for a full description of the parameters.) The response contains a flag indicating if the date has a anomaly and also provides the prediction interval used to define if an observation is an anomaly.Get your token for private beta at https://dashboard.nixtla.io. Parameters: - - model: typing.Optional[str]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + - model: typing.Optional[MultiSeriesAnomalyModel]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. - freq: typing.Optional[str]. The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available. @@ -288,7 +300,7 @@ def timegpt_multi_series_anomalies( def timegpt_multi_series_cross_validation( self, *, - model: typing.Optional[str] = OMIT, + model: typing.Optional[MultiSeriesCrossValidationModel] = OMIT, freq: typing.Optional[str] = OMIT, level: typing.Optional[typing.List[typing.Any]] = OMIT, fh: typing.Optional[int] = OMIT, @@ -297,13 +309,14 @@ def timegpt_multi_series_cross_validation( n_windows: typing.Optional[int] = OMIT, step_size: typing.Optional[int] = OMIT, finetune_steps: typing.Optional[int] = OMIT, + finetune_loss: typing.Optional[MultiSeriesCrossValidationFinetuneLoss] = OMIT, clean_ex_first: typing.Optional[bool] = OMIT, ) -> typing.Any: """ Perform Cross Validation for multiple series Parameters: - - model: typing.Optional[str]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + - model: typing.Optional[MultiSeriesCrossValidationModel]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. - freq: typing.Optional[str]. The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available. @@ -321,6 +334,8 @@ def timegpt_multi_series_cross_validation( - finetune_steps: typing.Optional[int]. The number of tuning steps used to train the large time model on the data. Set this value to 0 for zero-shot inference, i.e., to make predictions without any further model tuning. + - finetune_loss: typing.Optional[MultiSeriesCrossValidationFinetuneLoss]. The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers. + - clean_ex_first: typing.Optional[bool]. A boolean flag that indicates whether the API should preprocess (clean) the exogenous signal before applying the large time model. If True, the exogenous signal is cleaned; if False, the exogenous variables are applied after the large time model. """ _request: typing.Dict[str, typing.Any] = {} @@ -342,6 +357,8 @@ def timegpt_multi_series_cross_validation( _request["step_size"] = step_size if finetune_steps is not OMIT: _request["finetune_steps"] = finetune_steps + if finetune_loss is not OMIT: + _request["finetune_loss"] = finetune_loss if clean_ex_first is not OMIT: _request["clean_ex_first"] = clean_ex_first _response = self._client_wrapper.httpx_client.request( @@ -471,7 +488,7 @@ async def timegpt(self, *, request: SingleSeriesForecast) -> typing.Any: async def timegpt_historic( self, *, - model: typing.Optional[str] = OMIT, + model: typing.Optional[SingleSeriesInsampleForecastModel] = OMIT, freq: typing.Optional[str] = OMIT, level: typing.Optional[typing.List[typing.Any]] = OMIT, y: typing.Optional[typing.Any] = OMIT, @@ -482,7 +499,7 @@ async def timegpt_historic( Based on the provided data, this endpoint predicts time series data for the in-sample period (historical period). It takes a JSON as an input, including information like the series frequency and the historical data. (See below for a full description of the parameters.) The response contains the predicted values for the historical period. Usually useful for anomaly detection. Get your token for private beta at https://dashboard.nixtla.io. Parameters: - - model: typing.Optional[str]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + - model: typing.Optional[SingleSeriesInsampleForecastModel]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. - freq: typing.Optional[str]. The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available. @@ -527,7 +544,7 @@ async def timegpt_historic( async def timegpt_multi_series( self, *, - model: typing.Optional[str] = OMIT, + model: typing.Optional[MultiSeriesForecastModel] = OMIT, freq: typing.Optional[str] = OMIT, level: typing.Optional[typing.List[typing.Any]] = OMIT, fh: typing.Optional[int] = OMIT, @@ -535,12 +552,13 @@ async def timegpt_multi_series( x: typing.Optional[MultiSeriesInput] = OMIT, clean_ex_first: typing.Optional[bool] = OMIT, finetune_steps: typing.Optional[int] = OMIT, + finetune_loss: typing.Optional[MultiSeriesForecastFinetuneLoss] = OMIT, ) -> typing.Any: """ Based on the provided data, this endpoint predicts the future values of multiple time series at once. It takes a JSON as an input containing information like the series frequency and historical data. (See below for a full description of the parameters.) The response contains the predicted values for each series based on the input arguments. Get your token for private beta at https://dashboard.nixtla.io. Parameters: - - model: typing.Optional[str]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + - model: typing.Optional[MultiSeriesForecastModel]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. - freq: typing.Optional[str]. The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available. @@ -555,6 +573,8 @@ async def timegpt_multi_series( - clean_ex_first: typing.Optional[bool]. A boolean flag that indicates whether the API should preprocess (clean) the exogenous signal before applying the large time model. If True, the exogenous signal is cleaned; if False, the exogenous variables are applied after the large time model. - finetune_steps: typing.Optional[int]. The number of tuning steps used to train the large time model on the data. Set this value to 0 for zero-shot inference, i.e., to make predictions without any further model tuning. + + - finetune_loss: typing.Optional[MultiSeriesForecastFinetuneLoss]. The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers. """ _request: typing.Dict[str, typing.Any] = {} if model is not OMIT: @@ -573,6 +593,8 @@ async def timegpt_multi_series( _request["clean_ex_first"] = clean_ex_first if finetune_steps is not OMIT: _request["finetune_steps"] = finetune_steps + if finetune_loss is not OMIT: + _request["finetune_loss"] = finetune_loss _response = await self._client_wrapper.httpx_client.request( "POST", urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "timegpt_multi_series"), @@ -593,7 +615,7 @@ async def timegpt_multi_series( async def timegpt_multi_series_historic( self, *, - model: typing.Optional[str] = OMIT, + model: typing.Optional[MultiSeriesInsampleForecastModel] = OMIT, freq: typing.Optional[str] = OMIT, level: typing.Optional[typing.List[typing.Any]] = OMIT, y: typing.Optional[typing.Any] = OMIT, @@ -604,7 +626,7 @@ async def timegpt_multi_series_historic( Based on the provided data, this endpoint predicts the in-sample period (historical period) values of multiple time series at once. It takes a JSON as an input containing information like the series frequency and historical data. (See below for a full description of the parameters.) The response contains the predicted values for the historical period. Usually useful for anomaly detection. Get your token for private beta at https://dashboard.nixtla.io. Parameters: - - model: typing.Optional[str]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + - model: typing.Optional[MultiSeriesInsampleForecastModel]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. - freq: typing.Optional[str]. The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available. @@ -649,7 +671,7 @@ async def timegpt_multi_series_historic( async def timegpt_multi_series_anomalies( self, *, - model: typing.Optional[str] = OMIT, + model: typing.Optional[MultiSeriesAnomalyModel] = OMIT, freq: typing.Optional[str] = OMIT, level: typing.Optional[typing.List[typing.Any]] = OMIT, y: typing.Optional[typing.Any] = OMIT, @@ -660,7 +682,7 @@ async def timegpt_multi_series_anomalies( Based on the provided data, this endpoint detects the anomalies in the historical perdiod of multiple time series at once. It takes a JSON as an input containing information like the series frequency and historical data. (See below for a full description of the parameters.) The response contains a flag indicating if the date has a anomaly and also provides the prediction interval used to define if an observation is an anomaly.Get your token for private beta at https://dashboard.nixtla.io. Parameters: - - model: typing.Optional[str]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + - model: typing.Optional[MultiSeriesAnomalyModel]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. - freq: typing.Optional[str]. The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available. @@ -705,7 +727,7 @@ async def timegpt_multi_series_anomalies( async def timegpt_multi_series_cross_validation( self, *, - model: typing.Optional[str] = OMIT, + model: typing.Optional[MultiSeriesCrossValidationModel] = OMIT, freq: typing.Optional[str] = OMIT, level: typing.Optional[typing.List[typing.Any]] = OMIT, fh: typing.Optional[int] = OMIT, @@ -714,13 +736,14 @@ async def timegpt_multi_series_cross_validation( n_windows: typing.Optional[int] = OMIT, step_size: typing.Optional[int] = OMIT, finetune_steps: typing.Optional[int] = OMIT, + finetune_loss: typing.Optional[MultiSeriesCrossValidationFinetuneLoss] = OMIT, clean_ex_first: typing.Optional[bool] = OMIT, ) -> typing.Any: """ Perform Cross Validation for multiple series Parameters: - - model: typing.Optional[str]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + - model: typing.Optional[MultiSeriesCrossValidationModel]. Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. - freq: typing.Optional[str]. The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available. @@ -738,6 +761,8 @@ async def timegpt_multi_series_cross_validation( - finetune_steps: typing.Optional[int]. The number of tuning steps used to train the large time model on the data. Set this value to 0 for zero-shot inference, i.e., to make predictions without any further model tuning. + - finetune_loss: typing.Optional[MultiSeriesCrossValidationFinetuneLoss]. The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers. + - clean_ex_first: typing.Optional[bool]. A boolean flag that indicates whether the API should preprocess (clean) the exogenous signal before applying the large time model. If True, the exogenous signal is cleaned; if False, the exogenous variables are applied after the large time model. """ _request: typing.Dict[str, typing.Any] = {} @@ -759,6 +784,8 @@ async def timegpt_multi_series_cross_validation( _request["step_size"] = step_size if finetune_steps is not OMIT: _request["finetune_steps"] = finetune_steps + if finetune_loss is not OMIT: + _request["finetune_loss"] = finetune_loss if clean_ex_first is not OMIT: _request["clean_ex_first"] = clean_ex_first _response = await self._client_wrapper.httpx_client.request( diff --git a/nixtlats/types/__init__.py b/nixtlats/types/__init__.py index c5bc217d..964acf53 100644 --- a/nixtlats/types/__init__.py +++ b/nixtlats/types/__init__.py @@ -1,15 +1,33 @@ # This file was auto-generated by Fern from our API Definition. from .http_validation_error import HttpValidationError +from .multi_series_anomaly_model import MultiSeriesAnomalyModel +from .multi_series_cross_validation_finetune_loss import MultiSeriesCrossValidationFinetuneLoss +from .multi_series_cross_validation_model import MultiSeriesCrossValidationModel +from .multi_series_forecast_finetune_loss import MultiSeriesForecastFinetuneLoss +from .multi_series_forecast_model import MultiSeriesForecastModel from .multi_series_input import MultiSeriesInput +from .multi_series_insample_forecast_model import MultiSeriesInsampleForecastModel from .single_series_forecast import SingleSeriesForecast +from .single_series_forecast_finetune_loss import SingleSeriesForecastFinetuneLoss +from .single_series_forecast_model import SingleSeriesForecastModel +from .single_series_insample_forecast_model import SingleSeriesInsampleForecastModel from .validation_error import ValidationError from .validation_error_loc_item import ValidationErrorLocItem __all__ = [ "HttpValidationError", + "MultiSeriesAnomalyModel", + "MultiSeriesCrossValidationFinetuneLoss", + "MultiSeriesCrossValidationModel", + "MultiSeriesForecastFinetuneLoss", + "MultiSeriesForecastModel", "MultiSeriesInput", + "MultiSeriesInsampleForecastModel", "SingleSeriesForecast", + "SingleSeriesForecastFinetuneLoss", + "SingleSeriesForecastModel", + "SingleSeriesInsampleForecastModel", "ValidationError", "ValidationErrorLocItem", ] diff --git a/nixtlats/types/multi_series_anomaly_model.py b/nixtlats/types/multi_series_anomaly_model.py new file mode 100644 index 00000000..9d1c2202 --- /dev/null +++ b/nixtlats/types/multi_series_anomaly_model.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class MultiSeriesAnomalyModel(str, enum.Enum): + """ + Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + """ + + TIMEGPT_1 = "timegpt-1" + TIMEGPT_1_LONG_HORIZON = "timegpt-1-long-horizon" + + def visit( + self, timegpt_1: typing.Callable[[], T_Result], timegpt_1_long_horizon: typing.Callable[[], T_Result] + ) -> T_Result: + if self is MultiSeriesAnomalyModel.TIMEGPT_1: + return timegpt_1() + if self is MultiSeriesAnomalyModel.TIMEGPT_1_LONG_HORIZON: + return timegpt_1_long_horizon() diff --git a/nixtlats/types/multi_series_cross_validation_finetune_loss.py b/nixtlats/types/multi_series_cross_validation_finetune_loss.py new file mode 100644 index 00000000..b4a08b2a --- /dev/null +++ b/nixtlats/types/multi_series_cross_validation_finetune_loss.py @@ -0,0 +1,41 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class MultiSeriesCrossValidationFinetuneLoss(str, enum.Enum): + """ + The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers. + """ + + DEFAULT = "default" + MAE = "mae" + MSE = "mse" + RMSE = "rmse" + MAPE = "mape" + SMAPE = "smape" + + def visit( + self, + default: typing.Callable[[], T_Result], + mae: typing.Callable[[], T_Result], + mse: typing.Callable[[], T_Result], + rmse: typing.Callable[[], T_Result], + mape: typing.Callable[[], T_Result], + smape: typing.Callable[[], T_Result], + ) -> T_Result: + if self is MultiSeriesCrossValidationFinetuneLoss.DEFAULT: + return default() + if self is MultiSeriesCrossValidationFinetuneLoss.MAE: + return mae() + if self is MultiSeriesCrossValidationFinetuneLoss.MSE: + return mse() + if self is MultiSeriesCrossValidationFinetuneLoss.RMSE: + return rmse() + if self is MultiSeriesCrossValidationFinetuneLoss.MAPE: + return mape() + if self is MultiSeriesCrossValidationFinetuneLoss.SMAPE: + return smape() diff --git a/nixtlats/types/multi_series_cross_validation_model.py b/nixtlats/types/multi_series_cross_validation_model.py new file mode 100644 index 00000000..38b9c1a9 --- /dev/null +++ b/nixtlats/types/multi_series_cross_validation_model.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class MultiSeriesCrossValidationModel(str, enum.Enum): + """ + Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + """ + + TIMEGPT_1 = "timegpt-1" + TIMEGPT_1_LONG_HORIZON = "timegpt-1-long-horizon" + + def visit( + self, timegpt_1: typing.Callable[[], T_Result], timegpt_1_long_horizon: typing.Callable[[], T_Result] + ) -> T_Result: + if self is MultiSeriesCrossValidationModel.TIMEGPT_1: + return timegpt_1() + if self is MultiSeriesCrossValidationModel.TIMEGPT_1_LONG_HORIZON: + return timegpt_1_long_horizon() diff --git a/nixtlats/types/multi_series_forecast_finetune_loss.py b/nixtlats/types/multi_series_forecast_finetune_loss.py new file mode 100644 index 00000000..f1665bd9 --- /dev/null +++ b/nixtlats/types/multi_series_forecast_finetune_loss.py @@ -0,0 +1,41 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class MultiSeriesForecastFinetuneLoss(str, enum.Enum): + """ + The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers. + """ + + DEFAULT = "default" + MAE = "mae" + MSE = "mse" + RMSE = "rmse" + MAPE = "mape" + SMAPE = "smape" + + def visit( + self, + default: typing.Callable[[], T_Result], + mae: typing.Callable[[], T_Result], + mse: typing.Callable[[], T_Result], + rmse: typing.Callable[[], T_Result], + mape: typing.Callable[[], T_Result], + smape: typing.Callable[[], T_Result], + ) -> T_Result: + if self is MultiSeriesForecastFinetuneLoss.DEFAULT: + return default() + if self is MultiSeriesForecastFinetuneLoss.MAE: + return mae() + if self is MultiSeriesForecastFinetuneLoss.MSE: + return mse() + if self is MultiSeriesForecastFinetuneLoss.RMSE: + return rmse() + if self is MultiSeriesForecastFinetuneLoss.MAPE: + return mape() + if self is MultiSeriesForecastFinetuneLoss.SMAPE: + return smape() diff --git a/nixtlats/types/multi_series_forecast_model.py b/nixtlats/types/multi_series_forecast_model.py new file mode 100644 index 00000000..1d7010c4 --- /dev/null +++ b/nixtlats/types/multi_series_forecast_model.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class MultiSeriesForecastModel(str, enum.Enum): + """ + Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + """ + + TIMEGPT_1 = "timegpt-1" + TIMEGPT_1_LONG_HORIZON = "timegpt-1-long-horizon" + + def visit( + self, timegpt_1: typing.Callable[[], T_Result], timegpt_1_long_horizon: typing.Callable[[], T_Result] + ) -> T_Result: + if self is MultiSeriesForecastModel.TIMEGPT_1: + return timegpt_1() + if self is MultiSeriesForecastModel.TIMEGPT_1_LONG_HORIZON: + return timegpt_1_long_horizon() diff --git a/nixtlats/types/multi_series_insample_forecast_model.py b/nixtlats/types/multi_series_insample_forecast_model.py new file mode 100644 index 00000000..792ba1c4 --- /dev/null +++ b/nixtlats/types/multi_series_insample_forecast_model.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class MultiSeriesInsampleForecastModel(str, enum.Enum): + """ + Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + """ + + TIMEGPT_1 = "timegpt-1" + TIMEGPT_1_LONG_HORIZON = "timegpt-1-long-horizon" + + def visit( + self, timegpt_1: typing.Callable[[], T_Result], timegpt_1_long_horizon: typing.Callable[[], T_Result] + ) -> T_Result: + if self is MultiSeriesInsampleForecastModel.TIMEGPT_1: + return timegpt_1() + if self is MultiSeriesInsampleForecastModel.TIMEGPT_1_LONG_HORIZON: + return timegpt_1_long_horizon() diff --git a/nixtlats/types/single_series_forecast.py b/nixtlats/types/single_series_forecast.py index e506cac2..bc3cf082 100644 --- a/nixtlats/types/single_series_forecast.py +++ b/nixtlats/types/single_series_forecast.py @@ -6,10 +6,12 @@ import pydantic from ..core.datetime_utils import serialize_datetime +from .single_series_forecast_finetune_loss import SingleSeriesForecastFinetuneLoss +from .single_series_forecast_model import SingleSeriesForecastModel class SingleSeriesForecast(pydantic.BaseModel): - model: typing.Optional[str] = pydantic.Field( + model: typing.Optional[SingleSeriesForecastModel] = pydantic.Field( description="Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data." ) freq: typing.Optional[str] = pydantic.Field( @@ -31,6 +33,9 @@ class SingleSeriesForecast(pydantic.BaseModel): finetune_steps: typing.Optional[int] = pydantic.Field( description="The number of tuning steps used to train the large time model on the data. Set this value to 0 for zero-shot inference, i.e., to make predictions without any further model tuning." ) + finetune_loss: typing.Optional[SingleSeriesForecastFinetuneLoss] = pydantic.Field( + description="The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers." + ) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/nixtlats/types/single_series_forecast_finetune_loss.py b/nixtlats/types/single_series_forecast_finetune_loss.py new file mode 100644 index 00000000..06fb8b1c --- /dev/null +++ b/nixtlats/types/single_series_forecast_finetune_loss.py @@ -0,0 +1,41 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class SingleSeriesForecastFinetuneLoss(str, enum.Enum): + """ + The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers. + """ + + DEFAULT = "default" + MAE = "mae" + MSE = "mse" + RMSE = "rmse" + MAPE = "mape" + SMAPE = "smape" + + def visit( + self, + default: typing.Callable[[], T_Result], + mae: typing.Callable[[], T_Result], + mse: typing.Callable[[], T_Result], + rmse: typing.Callable[[], T_Result], + mape: typing.Callable[[], T_Result], + smape: typing.Callable[[], T_Result], + ) -> T_Result: + if self is SingleSeriesForecastFinetuneLoss.DEFAULT: + return default() + if self is SingleSeriesForecastFinetuneLoss.MAE: + return mae() + if self is SingleSeriesForecastFinetuneLoss.MSE: + return mse() + if self is SingleSeriesForecastFinetuneLoss.RMSE: + return rmse() + if self is SingleSeriesForecastFinetuneLoss.MAPE: + return mape() + if self is SingleSeriesForecastFinetuneLoss.SMAPE: + return smape() diff --git a/nixtlats/types/single_series_forecast_model.py b/nixtlats/types/single_series_forecast_model.py new file mode 100644 index 00000000..f0e41d8d --- /dev/null +++ b/nixtlats/types/single_series_forecast_model.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class SingleSeriesForecastModel(str, enum.Enum): + """ + Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + """ + + TIMEGPT_1 = "timegpt-1" + TIMEGPT_1_LONG_HORIZON = "timegpt-1-long-horizon" + + def visit( + self, timegpt_1: typing.Callable[[], T_Result], timegpt_1_long_horizon: typing.Callable[[], T_Result] + ) -> T_Result: + if self is SingleSeriesForecastModel.TIMEGPT_1: + return timegpt_1() + if self is SingleSeriesForecastModel.TIMEGPT_1_LONG_HORIZON: + return timegpt_1_long_horizon() diff --git a/nixtlats/types/single_series_insample_forecast_model.py b/nixtlats/types/single_series_insample_forecast_model.py new file mode 100644 index 00000000..534a7794 --- /dev/null +++ b/nixtlats/types/single_series_insample_forecast_model.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class SingleSeriesInsampleForecastModel(str, enum.Enum): + """ + Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data. + """ + + TIMEGPT_1 = "timegpt-1" + TIMEGPT_1_LONG_HORIZON = "timegpt-1-long-horizon" + + def visit( + self, timegpt_1: typing.Callable[[], T_Result], timegpt_1_long_horizon: typing.Callable[[], T_Result] + ) -> T_Result: + if self is SingleSeriesInsampleForecastModel.TIMEGPT_1: + return timegpt_1() + if self is SingleSeriesInsampleForecastModel.TIMEGPT_1_LONG_HORIZON: + return timegpt_1_long_horizon()