flexmeasures.data.models.forecasting.pipelines.predict

Classes

class flexmeasures.data.models.forecasting.pipelines.predict.PredictPipeline(future_regressors: list[Sensor], past_regressors: list[Sensor], target_sensor: Sensor, model_path: str, output_path: str, n_steps_to_predict: int, max_forecast_horizon: int, sensor_to_save: Sensor, forecast_frequency: int = 1, probabilistic: bool = False, quantiles: list[float] | None = None, event_starts_after: datetime | None = None, event_ends_before: datetime | None = None, predict_start: datetime | None = None, predict_end: datetime | None = None, data_source: Source = None, missing_threshold: float = 1.0)
__init__(future_regressors: list[Sensor], past_regressors: list[Sensor], target_sensor: Sensor, model_path: str, output_path: str, n_steps_to_predict: int, max_forecast_horizon: int, sensor_to_save: Sensor, forecast_frequency: int = 1, probabilistic: bool = False, quantiles: list[float] | None = None, event_starts_after: datetime | None = None, event_ends_before: datetime | None = None, predict_start: datetime | None = None, predict_end: datetime | None = None, data_source: Source = None, missing_threshold: float = 1.0) None

Initialize the PredictPipeline.

Parameters:
  • sensors – Dictionary mapping custom regressor names to sensor IDs.

  • past_regressors – List of sensors serving as past regressors.

  • future_regressors – List of sensors serving as future regressors.

  • target – Custom target name.

  • model_path – Path to the model file.

  • output_path – Path where predictions will be saved.

  • n_steps_to_predict – Number of steps of 1 resolution to predict into the future.

  • max_forecast_horizon – Maximum forecast horizon in steps of 1 resolution.

  • quantiles – Optional list of quantiles to predict for probabilistic forecasts. If None, predictions are deterministic.

  • event_starts_after – Only consider events starting after this time.

  • event_ends_before – Only consider events ending before this time.

  • predict_start – Only save events starting after this time.

  • predict_end – Only save events ending before this time.

  • forecast_frequency – Create a forecast every Nth interval.

  • data_source – Data source to attribute the forecasts to.

  • probabilistic – Whether to use a probabilistic model.

  • sensor_to_save – Sensor to which the predictions will be attributed.

  • missing_threshold – Max fraction of missing data allowed before failure. Missing data under the threshold will be filled with our interpolation methods.

_prepare_df_single_horizon_prediction(y_pred: TimeSeries, belief_horizon, value_at_belief_horizon, viewpoint: int, belief_timestamp)

Prepare the DataFrame for a single prediction. Make an additional column for quantiles forecast when probabilistic is True

load_model()

Load the model and its metadata from the model_path.

make_multi_fixed_viewpoint_predictions(model, future_covariates_list: list[TimeSeries], past_covariates_list: list[TimeSeries], y_list: list[TimeSeries], belief_timestamps_list: list[Timestamp]) DataFrame

Make predictions for multiple fixed viewpoints, for the given model, X, and y.

make_single_fixed_viewpoint_prediction(model, future_covariates: TimeSeries, past_covariates: TimeSeries, current_y: TimeSeries, viewpoint: int, belief_timestamp: Timestamp) DataFrame

Make a single prediction for the given viewpoint (enumeration of the number of viewpoints), using inputs already sliced for this belief time. Notes —– The covariate/target windowing and belief semantics are documented in: - BasePipeline class docstring (“Covariate semantics”) - BasePipeline.split_data_all_beliefs_generate_splits

run(delete_model: bool = False)

Execute the prediction pipeline.

save_results_to_CSV(df_pred: DataFrame)

Save the predictions to a CSV file.