awt_quant.forecast.macro_forecast¶
Macro Data Forecasting and Visualization
This module provides functionality for forecasting macroeconomic time series data using AutoTS and TimeGPT. It includes preprocessing utilities, automated forecasting methods, and visualization tools.
- Functions:
MacroDataForecasting: A class for managing time series data and forecasting.
convert_numpy_floats(obj): Converts NumPy float64 values to native Python floats.
api_forecast(series_id): Fetches macroeconomic data and forecasts future values using TimeGPT.
- Usage:
time_series_data, meta_data = get_macro(“GDP”) forecasting = MacroDataForecasting(time_series_data) forecast_results = forecasting.execute_forecasts()
Module Contents¶
- class awt_quant.forecast.macro_forecast.MacroDataForecasting(time_series, meta_data=None)[source]¶
A class for forecasting macroeconomic time series data using AutoTS.
Initializes the MacroDataForecasting class.
- Parameters:
time_series (pd.DataFrame) – The macroeconomic time series data.
meta_data (dict, optional) – Metadata related to the time series.
- preprocess_data(method='average', normalize=False, return_type=None, na_method='drop')[source]¶
Preprocesses the time series data by handling missing values and formatting dates.
- Parameters:
method (str, optional) – Method to handle missing values (‘average’, ‘interpolate’). Defaults to ‘average’.
normalize (bool, optional) – Whether to normalize the data. Defaults to False.
return_type (str, optional) – Type of return calculation (‘log’, ‘percent’) or None. Defaults to None.
na_method (str, optional) – Method to handle missing values (‘drop’, ‘ffill’, ‘interpolate’). Defaults to ‘drop’.
- forecast_with_autots(forecast_length=30, frequency='infer', prediction_interval=0.9, model_list='superfast', transformer_list='superfast', ensemble='distance', max_generations=4, num_validations=1, validation_method='backward', metric_weighting={'smape_weighting': 0.5, 'mae_weighting': 0.5}, drop_most_recent=0, n_jobs='auto')[source]¶
Generates forecasts using the AutoTS library with enhanced parameterization.
- Parameters:
forecast_length (int, optional) – Number of periods to forecast. Defaults to 30.
frequency (str, optional) – Frequency of the time series data. Defaults to ‘infer’.
prediction_interval (float, optional) – Prediction interval for the forecast. Defaults to 0.9.
model_list (list or str, optional) – Models to be used in the search. Defaults to ‘superfast’.
transformer_list (list or str, optional) – Data transformations to be applied. Defaults to ‘superfast’.
ensemble (str, optional) – Ensemble method to use. Defaults to ‘distance’.
max_generations (int, optional) – Number of generations for the model search. Defaults to 4.
num_validations (int, optional) – Number of validation sets used in model selection. Defaults to 1.
validation_method (str, optional) – Method for time series cross-validation. Defaults to ‘backward’.
metric_weighting (dict, optional) – Weighting of different performance metrics. Defaults to {‘smape_weighting’: 0.5, ‘mae_weighting’: 0.5}.
drop_most_recent (int, optional) – Number of most recent data points to drop. Defaults to 0.
n_jobs (int or str, optional) – Number of jobs to run in parallel. Defaults to ‘auto’.
- Returns:
Dictionary containing forecast results, lower and upper bounds.
- Return type: