flexmeasures.data.models.forecasting.model_spec_factory

Functions

flexmeasures.data.models.forecasting.model_spec_factory.configure_regressors_for_nearest_weather_sensor(sensor: Sensor, query_window, horizon, regressor_transformation, transform_to_normal) list[TBSeriesSpecs]

We use weather data as regressors. Here, we configure them.

flexmeasures.data.models.forecasting.model_spec_factory.create_initial_model_specs(sensor: Sensor, forecast_start: datetime, forecast_end: datetime, forecast_horizon: timedelta, ex_post_horizon: timedelta | None = None, transform_to_normal: bool = True, use_regressors: bool = True, use_periodicity: bool = True, custom_model_params: dict | None = None, time_series_class: type | None = <class 'flexmeasures.data.models.time_series.TimedBelief'>) ModelSpecs

Generic model specs for all asset types (also for markets and weather sensors) and horizons. Fills in training, testing periods, lags. Specifies input and regressor data. Does not fill in which model to actually use. TODO: check if enough data is available both for lagged variables and regressors TODO: refactor assets and markets to store a list of pandas offset or timedelta instead of booleans for

seasonality, because e.g. although solar and building assets both have daily seasonality, only the former is insensitive to daylight savings. Therefore: solar periodicity is 24 hours, while building periodicity is 1 calendar day.

flexmeasures.data.models.forecasting.model_spec_factory.get_normalization_transformation_from_sensor_attributes(sensor: Sensor) Transformation | None

Transform data to be normal, using the BoxCox transformation. Lambda parameter is chosen according to the asset type.

Classes

class flexmeasures.data.models.forecasting.model_spec_factory.TBSeriesSpecs(search_params: dict, name: str, time_series_class: type | None = <class 'flexmeasures.data.models.time_series.TimedBelief'>, search_fnc: str = 'search', original_tz: tzinfo | None = <UTC>, feature_transformation: ReversibleTransformation | None = None, post_load_processing: Transformation | None = None, resampling_config: dict[str, Any] = None, interpolation_config: dict[str, Any] = None)

Compatibility for using timetomodel.SeriesSpecs with timely_beliefs.BeliefsDataFrames.

This implements _load_series such that <time_series_class>.search is called, with the parameters in search_params. The search function is expected to return a BeliefsDataFrame.

__init__(search_params: dict, name: str, time_series_class: type | None = <class 'flexmeasures.data.models.time_series.TimedBelief'>, search_fnc: str = 'search', original_tz: tzinfo | None = <UTC>, feature_transformation: ReversibleTransformation | None = None, post_load_processing: Transformation | None = None, resampling_config: dict[str, Any] = None, interpolation_config: dict[str, Any] = None)
_load_series() Series

Subclasses overwrite this function to get the raw data. This method is responsible to call any post_load_processing at the right place.

check_data(df: DataFrame)

Raise error if data is empty or contains nan values. Here, other than in load_series, we can show the query, which is quite helpful.