epftoolbox.models.LEAR¶
-
class
epftoolbox.models.
LEAR
(calibration_window=1092)[source]¶ Class to build a LEAR model, recalibrate it, and use it to predict DA electricity prices.
An example on how to use this class is provided here.
Parameters: calibration_window (int, optional) – Calibration window (in days) for the LEAR model. Methods
predict
(X)Function that makes a prediction using some given inputs. recalibrate
(Xtrain, Ytrain)Function to recalibrate the LEAR model. recalibrate_and_forecast_next_day
(df, …)Easy-to-use interface for daily recalibration and forecasting of the LEAR model. recalibrate_predict
(Xtrain, Ytrain, Xtest)Function that first recalibrates the LEAR model and then makes a prediction. -
predict
(X)[source]¶ Function that makes a prediction using some given inputs.
Parameters: X (numpy.array) – Input of the model. Returns: An array containing the predictions. Return type: numpy.array
-
recalibrate
(Xtrain, Ytrain)[source]¶ Function to recalibrate the LEAR model.
It uses a training (Xtrain, Ytrain) pair for recalibration
Parameters: - Xtrain (numpy.array) – Input in training dataset. It should be of size [n,m] where n is the number of days in the training dataset and m the number of input features
- Ytrain (numpy.array) – Output in training dataset. It should be of size [n,24] where n is the number of days in the training dataset and 24 are the 24 prices of each day
Returns: The prediction of day-ahead prices after recalibrating the model
Return type: numpy.array
-
recalibrate_and_forecast_next_day
(df, calibration_window, next_day_date)[source]¶ Easy-to-use interface for daily recalibration and forecasting of the LEAR model.
The function receives a pandas dataframe and a date. Usually, the data should correspond with the date of the next-day when using for daily recalibration.
Parameters: - df (pandas.DataFrame) – Dataframe of historical data containing prices and N exogenous inputs.
The index of the dataframe should be dates with hourly frequency. The columns
should have the following names
['Price', 'Exogenous 1', 'Exogenous 2', ...., 'Exogenous N']
. - calibration_window (int) – Calibration window (in days) for the LEAR model.
- next_day_date (datetime) – Date of the day-ahead.
Returns: The prediction of day-ahead prices.
Return type: numpy.array
- df (pandas.DataFrame) – Dataframe of historical data containing prices and N exogenous inputs.
The index of the dataframe should be dates with hourly frequency. The columns
should have the following names
-
recalibrate_predict
(Xtrain, Ytrain, Xtest)[source]¶ Function that first recalibrates the LEAR model and then makes a prediction.
The function receives the training dataset, and trains the LEAR model. Then, using the inputs of the test dataset, it makes a new prediction.
Parameters: - Xtrain (numpy.array) – Input of the training dataset.
- Xtest (numpy.array) – Input of the test dataset.
- Ytrain (numpy.array) – Output of the training dataset.
Returns: An array containing the predictions in the test dataset.
Return type: numpy.array
-