Construction of the regression model for the whole time series.
Using the parameters optimized by the training phase of linear regression model, the prediction is made for every point, if this prediction is far from the real value, the point is classified as anomalous. When the prediction is done, if a previous point that has to be used as lag is anomalous, the predicted value is considered and not the real one.
The way in which the anomaly check is computed takes care of in which part of the day the measurement is taken.
:param model regression_model: model given by the linear regression training
:param DataFrame energy_consumptions: formatted DataFrame containing measurements of energy consumption.
Index is of type DatetimeIndex,
column 'consumption' contains the measurement,
column 'week' contains the week code of the measurement.
:param DataFrame data_lm: DataFrame containing in the first column the real measurements and in the other columns the fetures used for regression
:param vector model_week: model week computed using the median of the normal weeks
:param vector lags: indicates which previous measurament are used as features for the regression model
:param int total_weeks: number of weeks in the dataset
:param int data_per_week: number of measurement for every week (default value is 672, a measurement every 15 minutes)
:output DataFrame hardcoded: DataFrame containing the constructed model
Index is of type DatetimeIndex,
column 'consumption' contains the measurement,
column 'model' contains the prediction made by the model
column 'anomaly' contains a bool indicating if the point is considered as anomalous
"""
# new dataset used for forecasting and anomaly detection
#this matrix contains the measurements of the central part of the days from Monday to Saturday of the week currently #being analysed. It's initialized to zeros at the start of each new week.