Function reference

Data

Utilities for fetching and loading time series, weather, and holiday data.

data.fetch_data.fetch_data Fetches a dataset from a CSV file or processes a DataFrame.
data.fetch_data.fetch_holiday_data Fetches holiday data for the dataset period.
data.fetch_data.fetch_weather_data Fetch weather data for the dataset period plus forecast horizon.
data.fetch_data.get_cache_home Return the location where persistent models are to be cached.
data.fetch_data.get_data_home Return the location where datasets are to be stored.
data.fetch_data.get_package_data_home Return the location of the internal package datasets.
data.fetch_data.load_timeseries Load the actual-load time series from interim/energy_load.csv.
data.fetch_data.load_timeseries_forecast Load the day-ahead forecast time series from interim/energy_load.csv.
data.data Data structures for input and processed data.

Preprocessing

Hardened tools for data curation, resampling, outlier detection, feature engineering, and temporal train/test splitting.

preprocessing.curate_data.agg_and_resample_data Aggregates and resamples the data to (e.g.,hourly) frequency by computing the specified aggregation (e.g. for each hour).
preprocessing.curate_data.basic_ts_checks Checks if the time series data has a datetime index and is sorted.
preprocessing.curate_data.curate_holidays Checks if the holiday dataframe has the correct shape.
preprocessing.curate_data.curate_weather Checks if the weather dataframe has the correct shape.
preprocessing.curate_data.get_start_end Get start and end date strings for data and covariate ranges.
preprocessing.curate_data.remove_duplicate_timestamps Resolve duplicate timestamps across all data columns.
preprocessing.curate_data.reset_index Resets the index of the dataframe and assigns a name to the index column.
preprocessing.outlier.get_outliers Detect outliers in each column using Isolation Forest.
preprocessing.outlier.manual_outlier_removal Manual outlier removal function.
preprocessing.outlier.mark_outliers Marks outliers as NaN in the dataset using Isolation Forest.
preprocessing.split.split_abs_train_val_test Splits a time series DataFrame into training, validation, and test sets based on absolute timestamps.
preprocessing.split.split_rel_train_val_test Splits a time series DataFrame into training, validation, and test sets by percentages.
preprocessing.exog_builder.ExogBuilder Builds a set of exogenous features for a given date range.
preprocessing.imputation.apply_imputation Apply imputation to a DataFrame based on the method specified in config.
preprocessing.imputation.WeightFunction Callable class for sample weights that can be pickled.
preprocessing.imputation.custom_weights Return 0 if index is in or near any gap.
preprocessing.imputation.get_missing_weights Return imputed DataFrame and a series indicating missing weights.
preprocessing.linearly_interpolate_ts Linear interpolation transformer for time series data.
preprocessing.repeating_basis_function Repeating Basis Function transformer for cyclical features.

Processing

Utilities for aggregated and n-to-n predictions.

processing.agg_predict.agg_predict Aggregates multiple prediction columns into a single combined prediction series.
processing.n2n_predict.n2n_predict End-to-end baseline forecasting using equivalent date method.
processing.n2n_predict_with_covariates.n2n_predict_with_covariates End-to-end recursive forecasting with exogenous covariates.

Forecaster

Recursive forecasting classes, seasonal baselines, and metrics.

forecaster.base ForecasterBase class.
forecaster.recursive._forecaster_recursive.ForecasterRecursive Recursive autoregressive forecaster for scikit-learn compatible estimators.
forecaster.recursive._forecaster_equivalent_date.ForecasterEquivalentDate This forecaster predicts future values based on the most recent equivalent
forecaster.recursive._forecaster_recursive_multiseries
forecaster.utils
forecaster.metrics.add_y_train_argument Add y_train argument to a function if it is not already present.
forecaster.metrics.calculate_coverage Calculate coverage of a given interval.
forecaster.metrics.create_mean_pinball_loss Create pinball loss for a given quantile.
forecaster.metrics.crps_from_predictions Compute the Continuous Ranked Probability Score (CRPS) from predictions.
forecaster.metrics.crps_from_quantiles Calculate the Continuous Ranked Probability Score (CRPS) from quantiles.
forecaster.metrics.mean_absolute_scaled_error Mean Absolute Scaled Error (MASE).
forecaster.metrics.root_mean_squared_scaled_error Root Mean Squared Scaled Error (RMSSE).
forecaster.metrics.symmetric_mean_absolute_percentage_error Compute the Symmetric Mean Absolute Percentage Error (SMAPE).

Model Selection

Backtesting and cross-validation utilities for time series models.

model_selection.validation.backtesting_forecaster Backtesting of forecaster model following the folds generated by the TimeSeriesFold
model_selection.validation.backtesting_forecaster_one_step Backtesting of forecaster model using one-step-ahead predictions.
model_selection.split_base Base class for time series cross-validation splitting.
model_selection.split_one_step One step ahead cross-validation splitting.
model_selection.split_ts_cv Time series cross-validation splitting.
model_selection.utils_common Common validation and initialization utilities for model selection.
model_selection.validation

Manager

High-level training, prediction, and model persistence orchestration.

manager.metrics.calculate_metrics Calculate MAE and MSE for numeric evaluation.
manager.trainer.get_last_model Get the latest trained model from the cache.
manager.trainer.get_path_model Yield the path to a model file for a given iteration and model name.
manager.trainer.load_iteration Load a saved model at a given iteration.
manager.predictor.build_prediction_package Build a prediction package compatible with PredictionFigure.
manager.predictor.get_model_prediction Get the prediction package from the latest trained model.
manager.configurator.config_entsoe.ConfigEntsoe Configuration for the ENTSO-E forecasting pipeline.
manager.configurator.config_multi.ConfigMulti Configuration for the multi-input forecasting pipeline.
manager.datasets.demo_data Demo dataset configuration for safety-critical forecasting tasks.
manager.datasets.demo_loader Demo data loader for safety-critical forecasting tasks.
manager.logger
manager.models.forecaster_recursive_lgbm
manager.models.forecaster_recursive_model Recursive forecaster model wrappers for different estimators.
manager.models.forecaster_recursive_xgb Recursive forecaster model wrappers for different estimators.
manager.persistence
manager.tools Utility tools for command-line interface parsing.
manager.exo.weather.get_weather_features Fetch weather data and compute rolling-window features.
manager.exo.calendar.get_calendar_features Create calendar-based features for a contiguous time range.
manager.exo.calendar.get_day_night_features Create day/night features using astronomical sunrise and sunset times.
manager.exo.calendar.get_holiday_features Fetch public-holiday indicators and align them to a regular time grid.
manager.features.apply_cyclical_encoding Apply cyclical (sine/cosine) encoding to periodic integer features.
manager.features.create_interaction_features Append bilinear interaction terms to an exogenous feature matrix.
manager.features.select_exogenous_features Select and deduplicate exogenous feature columns for model training.
manager.features.merge_data_and_covariates Merge target data with exogenous features and split into train/predict slices.
manager.features.get_target_data Extract the training series and exogenous slices for one target column.

Utils

General-purpose utility functions: CPE generation, validation, holiday calendars, and data transforms.

utils.cpe.get_cpe_identifier Generates the CPE 2.3 identifier for the spotforecast2-safe project.
utils.generate_holiday.create_holiday_df Create a DataFrame with datetime index and a binary holiday indicator column.
utils.validation.check_exog Validate that exog is a pandas Series or DataFrame.
utils.validation.check_exog_dtypes Check that exogenous variables have valid data types (int, float, category).
utils.validation.check_interval Validate that a confidence interval specification is valid.
utils.validation.check_predict_input Check all inputs of predict method. This is a helper function to validate
utils.validation.check_residuals_input Check residuals input arguments in Forecasters.
utils.validation.check_y Validate that y is a pandas Series without missing values.
utils.validation.get_exog_dtypes Extract and store the data types of exogenous variables.
utils.validation.set_cpu_gpu_device Set the device for the estimator to either ‘cpu’, ‘gpu’, ‘cuda’, or None.
utils.convert_to_utc Utility functions for timezone conversion.
utils.data_transform Data transformation utilities for time series forecasting.
utils.forecaster_config Forecaster configuration utilities.

Weather

Weather data integration using the Open-Meteo API.

weather.weather_client.WeatherClient Client for fetching weather data from Open-Meteo API.
weather.weather_client.WeatherService High-level service for weather data generation.

Downloader

Data downloaders for external data sources (e.g. ENTSO-E).

downloader.entsoe.download_new_data Download new load and forecast data from ENTSO-E.
downloader.entsoe.merge_build_manual Merge all raw CSV files from the ‘raw’ directory into a single interim file.

Exceptions

Custom exception types for safety-critical failure signalling.

exceptions Custom exceptions and warnings for spotforecast2.

Tasks

Executable tasks for demonstration and production pipelines.

tasks.task_safe_demo Task demo: compare baseline, covariate, and custom LightGBM forecasts against ground truth.
tasks.task_safe_n_to_1_with_covariates_and_dataframe N-to-1 Forecasting with Exogenous Covariates and Prediction Aggregation.