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.
data.demo_data Demo dataset configuration for safety-critical forecasting tasks.
data.demo_loader Demo data loader for safety-critical forecasting tasks.

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.checking.check_exog Validate that exog is a pandas Series or DataFrame.
preprocessing.checking.check_exog_dtypes Check that exogenous variables have valid data types (int, float, category).
preprocessing.checking.check_interval Validate that a confidence interval specification is valid.
preprocessing.checking.check_predict_input Check all inputs of predict method. This is a helper function to validate
preprocessing.checking.check_residuals_input Check residuals input arguments in Forecasters.
preprocessing.checking.check_y Validate that y is a pandas Series without missing values.
preprocessing.checking.get_exog_dtypes Extract and store the data types of exogenous variables.
preprocessing.checking.set_cpu_gpu_device Set the device for the estimator to either ‘cpu’, ‘gpu’, ‘cuda’, or None.
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.data_transform Data transformation utilities for time series forecasting.
preprocessing.forecaster_config Forecaster configuration utilities.
preprocessing.linearly_interpolate_ts Linear interpolation transformer for time series data.
preprocessing.repeating_basis_function Repeating Basis Function transformer for cyclical features.
preprocessing.rolling.RollingFeatures Compute rolling window statistics over time series data.

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).
forecaster.wrappers.model Recursive forecaster model wrappers for different estimators.
forecaster.wrappers.lgbm Recursive forecaster wrapper using LightGBM.
forecaster.wrappers.xgb Recursive forecaster model wrappers for different estimators.

Splitter

Time-series-aware cross-validation folds and train/val/test holdout helpers.

splitter.split_base Base class for time series cross-validation splitting.
splitter.split_one_step One step ahead cross-validation splitting.
splitter.split_ts_cv Time series cross-validation splitting.
splitter.split.split_abs_train_val_test Splits a time series DataFrame into training, validation, and test sets based on absolute timestamps.
splitter.split.split_rel_train_val_test Splits a time series DataFrame into training, validation, and test sets by percentages.
splitter.utils_common Common validation and initialization utilities for model selection.

Backtesting

Backtesting orchestration for time series forecasters.

backtesting.validation.backtesting_forecaster Backtesting of forecaster model following the folds generated by the TimeSeriesFold
backtesting.validation.backtesting_forecaster_one_step Backtesting of forecaster model using one-step-ahead predictions.
backtesting.validation

Configurator

Task-level configuration objects for the forecasting pipelines.

configurator.config_entsoe.ConfigEntsoe Configuration for the ENTSO-E forecasting pipeline.
configurator.config_multi.ConfigMulti Configuration for the multi-input forecasting pipeline.

Manager

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

manager.demo_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.logger Audit-grade logging for spotforecast2-safe.
manager.persistence
manager.tools Utility tools for command-line interface parsing.
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, and data transforms.

utils.cpe.get_cpe_identifier Generates the CPE 2.3 identifier for the spotforecast2-safe project.
utils.convert_to_utc Utility functions for timezone conversion.

Security

Masking and PII-protection utilities for safe logging (CWE-532, CWE-312).

security.masking.mask_estimator Return a non-sensitive string representation of an estimator.

Calendar

Calendar, holiday, and day/night feature engineering for covariate construction.

calendar.holiday.create_holiday_df Create a DataFrame with datetime index and a binary holiday indicator column.
calendar.holiday.get_holiday_features Build public-holiday indicators and align them to a regular time grid.
calendar.features.get_calendar_features Create calendar-based features for a contiguous time range.
calendar.features.get_day_night_features Create day/night features using astronomical sunrise and sunset times.

Weather

Weather data integration using the Open-Meteo API.

weather.client.WeatherClient Client for fetching weather data from Open-Meteo API.
weather.client.WeatherService High-level service for weather data generation.
weather.features.get_weather_features Fetch weather data and compute rolling-window features.

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.