bill2watt.predictors package

Submodules

bill2watt.predictors.base_predictor module

This module contains the ‘BasePredictor’ class, which is used as a base for the models that predict typical load profiles based on monthly time-of-use (ToU) energy consumption values.

Notes

Info

Author: G. Lorenti Email: gianmarco.lorenti@polito.it

class bill2watt.predictors.base_predictor.BasePredictor(x_data=None, y_data=None)

Bases: object

Base class for predictors of typical load profiles (y) based on monthly time-of-use (ToU) energy consumption values (x).

Parameters

x_datapandas.DataFrame or None, optional

ToU energy consumption values associated with the SLPs.

y_datapandas.DataFrame or None, optional

Typical load profiles of the Standard Load Profiles (SLPs).

Attributes

x_data (property)pd.DataFrame or None

ToU energy consumption values of the data points used to build the predictor. None for predictors that do not require data points.

y_data (property)pd.DataFrame or None

Typical load profiles of the data points used to build the predictor. None for predictors that do not require data points.

n (property)int

Number of data points used to build the predictor.

Methods

add_data(x_data, y_data, update_existing=True)

Add new data points to the predictor.

predict(x, nd)

Placeholder method that must be implemented by child classes.

property x_data

Getter for the x_data property.

Returns a copy of the x_data if it is not None, otherwise returns None.

Returns

pd.DataFrame or None

Copy of the x_data or None.

property y_data

Getter for the y_data property.

Returns a copy of the y_data if it is not None, otherwise returns None.

Returns

pd.DataFrame or None

Copy of the y_data or None.

property n

Getter for the n property.

Returns the number of data points (length of x_data or y_data). Returns None if both x_data and y_data are None.

Returns

int

Number of data points.

add_data(x_data=None, y_data=None, update_existing=True)

Add new data points to the predictor.

Parameters

x_datapd.DataFrame or None

ToU energy consumption values of the new data points. None if no data points are provided.

y_datapd.DataFrame or None

Typical load profiles of the new data points. None if no data points are provided.

update_existingbool, optional

Flag indicating whether to update existing data points (i.e., already in the index). Default is True.

Returns

pd.DataFrame or None

The updated x_data after adding new data points.

pd.DataFrame or None

The updated y_data after adding new data points.

Raises

AssertionError

If ‘x_data’ and ‘y_data’ do not comply with requirements for new data points.

predict(x, nd)

bill2watt.predictors.category_predictor module

This module contains the ‘CategoryPredictor’ class, which is used for predicting typical load profiles based on monthly time-of-use (ToU) energy consumption values, using training data and an a-priori categorization approach.

Notes

Info

Author: G. Lorenti Email: gianmarco.lorenti@polito.it

class bill2watt.predictors.category_predictor.CategoryPredictor(x_data=None, y_data=None, category=None)

Bases: BasePredictor

This class implements a predictor for evaluating typical load profiles based on monthly time-of-use (ToU) energy consumption values, using categories defined by a specific key.

Parameters

x_datapandas.DataFrame or None

ToU energy consumption values associated with the training points. If None, default values are used.

y_datapandas.DataFrame or None

Typical load profiles of the training points. If None, default values are used.

categorystr or None, optional

The name of the column/index level used for categorization. If None and ‘y_data’ is not None, the name of the index of ‘y_data’ is used.

Attributes

x_data (property)pandas.DataFrame or None

ToU energy consumption values of the training points. If None, default values are used.

y_data (property)pandas.DataFrame or None

Typical load profiles of the training points. If None, default values are used.

category (property)str or None

The name of the column/index level used for categorization.

y_categories (property)pandas.DataFrame or None

Categorized typical load profiles based on the training data. If None, no categorization has been performed yet.

categories (property)list or None

Unique category values present in the categorized data. If None, no categorization has been performed yet.

Methods

predict(x, key)

Evaluate typical load profiles based on ToU energy consumption values and using the categories.

add_data(x_data, y_data, **kwargs)

Add new data points to the predictor and re-train the categorizer.

See Also

BasePredictor : Base class for typical load profile predictors.

property category

Get or set the name of the column/index level used for categorization.

Returns

str or None

The name of the column/index level used for categorization. If None, no categorization has been performed yet.

property y_categories

Categorized typical load profiles based on the training data.

Returns

pandas.DataFrame or None

Categorized typical load profiles. If None, no categorization has been performed yet.

property categories

Unique category values present in the categorized data.

Returns

list or None

Unique category values. If None, no categorization has been performed yet.

predict(x, key)

Evaluate typical load profiles based on ToU energy consumption values and using the categories.

Parameters

xarray-like

ToU energy consumption values of the point(s) to predict.

keytuple or list of tuples

Key values related to the categorized data associated with each point.

Returns

np.ndarray

Predicted typical load profiles based on the provided inputs.

Raises

AssertionError

If any inconsistency is found in the input data or key values are not present in the categorized data.

add_data(x_data, y_data, **kwargs)

Add new training points to the predictor and re-train the categorizer.

Parameters

x_dataarray-like

ToU energy consumption values of the new data points.

y_dataarray-like

Typical load profiles of the new data points.

Additional Parameters

Parameters from the ‘add_data’ method of the ‘BasePredictor’ parent class.

Raises

AssertionError

If ‘x_data’ and ‘y_data’ do not comply with the requirements for new data points.

bill2watt.predictors.classification_predictor module

This module contains the ‘ClassificationPredictor’ class, which is used for predicting typical load profiles based on monthly time-of-use (ToU) energy consumption values, using training data and a classification approach.

Notes

Info

Author: G. Lorenti Email: gianmarco.lorenti@polito.it

class bill2watt.predictors.classification_predictor.ClassificationPredictor(x_data=None, y_data=None, clustering=None, classifier=None)

Bases: BasePredictor

This class implements a predictor for evaluating typical load profiles based on time-of-use (ToU) energy consumption values using training data in a classification and clustering approach.

Parameters

x_datapandas.DataFrame or None

ToU energy consumption values of the training points. If None, default values are used.

y_datapandas.DataFrame or None

Typical load profiles of the training points. If None, default values are used.

clusteringobject

Clustering model object with fit and predict methods.

classifierobject

Classification model object with fit and predict methods.

Attributes

x_data (property)pandas.DataFrame or None

ToU energy consumption values of the training points. If None, default values are used.

y_data (property)pandas.DataFrame or None

Typical load profiles of the training points. If None, default values are used.

Methods

predict(x)

Predict typical load profiles based on the provided inputs.

add_data(x, y)

Add new data points to the predictor.

See Also

BasePredictor : Base class for typical load profile predictors.

predict(x)

Predict typical load profiles based on the provided inputs.

Parameters

xarray-like

ToU energy consumption values of the point(s) to predict.

Returns

np.ndarray

Predicted typical load profiles based on the provided inputs.

Notes

If ‘x’ refers to a single point, then the output is provided as a single point. If ‘x’ refers to multiple points, the output is provided as a matrix with the same number of rows as ‘x’.

Raises

AssertionError

If any inconsistency is found in the input data.

add_data(x_data, y_data, **kwargs)

Add new training points to the predictor and re-train the models.

Parameters

x_dataarray-like

ToU energy consumption values of the new data points.

y_dataarray-like

Typical load profiles of the new data points.

Additional parameters

Parameters from ‘add_data’ method of ‘BasePredictor’ parent class.

Raises

AssertionError

If ‘x_data’ and ‘y_data’ do not comply with requirements for new data points.

bill2watt.predictors.flat_predictor module

Flat Predictor

Description

This module contains the FlatPredictor class, which is used for predicting typical load profiles based on monthly time-of-use (ToU) energy consumption values, using a flat approach that spreads the consumption in each ToU tariff.

Notes

None.

Info

Author: G. Lorenti Email: gianmarco.lorenti@polito.it

class bill2watt.predictors.flat_predictor.FlatPredictor

Bases: BasePredictor

Flat Predictor.

This class implements a predictor for evaluating typical load profiles based on monthly time-of-use (ToU) energy consumption values using a flat approach that spreads the consumption in each ToU tariff.

Parameters

Attributes

Methods

predict(x, nd)

Evaluate typical load profiles based on energy consumption values and number of days of each day-type.

See Also

BasePredictor : Base class for typical load profile predictors.

predict(x, nd)

Evaluate typical load profiles in multiple points, based on ToU energy consumption values, using a flat approach.

Parameters

xarray-like

ToU energy consumption values of the point(s) to predict.

ndarray-like

Number of days of each day-type for each point.

Returns

np.ndarray

Predicted typical load profiles based on the provided inputs.

Notes

If ‘x’ (and other input parameters) refer to a single point, then the output is provided with a shape of a single point.

Raises

AssertionError

If any inconsistency is found in the input data.

add_data(x_data=None, y_data=None, **kwargs)

Add a data point to the predictor. This method is not supported by FlatPredictor and will raise an error unless ‘x_data’ and ‘y_data’ are both None.

Parameters

xNone

Energy consumption values of the data point.

yNone

Corresponding load profile of the data point.

*+kwargsdict

Additional parameters, added for compatibility.

Raises

NotImplementedError

This method is not supported by FlatPredictor and cannot be used unless ‘x_data’ and ‘y_data’ are both None.

bill2watt.predictors.regression_predictor module

This module contains the ‘RegressionPredictor’ class, which is used for predicting typical load profiles based on monthly time-of-use (ToU) energy consumption values, using training data and a regression approach.

Notes

Info

Author: G. Lorenti Email: gianmarco.lorenti@polito.it

class bill2watt.predictors.regression_predictor.RegressionPredictor(x_data=None, y_data=None, regressor=None)

Bases: BasePredictor

This class implements a predictor for evaluating typical load profiles based on time-of-use (ToU) energy consumption values using training data in a regression approach.

Parameters

x_datapandas.DataFrame or None

ToU energy consumption values of the training points. Since they are not used, can be also None.

y_datapandas.DataFrame or None

Typical load profiles of the training points. If None, default values are used.

regressorobject

Regression model object with fit and predict methods.

Attributes

x_data (property)pandas.DataFrame or None

ToU energy consumption values of the training points. If None, default values are used.

y_data (property)pandas.DataFrame or None

Typical load profiles of the training points. If None, default values are used.

Methods

predict(x)

Predict typical load profiles based on the provided inputs.

add_data(x, y)

Add new data points to the predictor.

See Also

BasePredictor : Base class for typical load profile predictors.

predict(x)

Predict typical load profiles based on the provided inputs.

Parameters

xarray-like

ToU energy consumption values of the point(s) to predict.

Returns

np.ndarray

Predicted typical load profiles based on the provided inputs.

Notes

If ‘x’ (and other input parameters) refer to a single point, then the output is provided with a shape of a single point.

Raises

AssertionError

If any inconsistency is found in the input data.

add_data(x_data, y_data, **kwargs)

Add new training points to the predictor and re-train the regressor.

Parameters

x_dataarray-like

ToU energy consumption values of the new data points.

y_dataarray-like

Typical load profiles of the new data points.

Additional parameters

Parameters from ‘add_data’ method of ‘BasePredictor’ parent class.

Raises

AssertionError

If ‘x_data’ and ‘y_data’ do not comply with requirements for new data points.

bill2watt.predictors.slp_predictor module

This module contains the ‘SLPPredictor’ class, which is used for predicting typical load profiles based on monthly time-of-use (ToU) energy consumption values, using Standard Load Profiles (SPLs).

Notes

Info

Author: G. Lorenti Email: gianmarco.lorenti@polito.it

class bill2watt.predictors.slp_predictor.SLPPredictor(x_data=None, y_data=None)

Bases: BasePredictor

This class implements a predictor for evaluating typical load profiles based on monthly time-of-use (ToU) energy consumption values, using Standard Load Profiles (SLPs).

Parameters

x_datapandas.DataFrame or None

ToU energy consumption values associated with the SLPs. Since they are not used, can be also None.

y_datapandas.DataFrame or None

Typical load profiles of the Standard Load Profiles (SLPs). If None, default values are used.

Attributes

x_data (property)pandas.DataFrame or None

ToU energy consumption values of the training points. If None, default values are used.

y_data (property)pandas.DataFrame or None

Typical load profiles of the training points. If None, default values are used.

Methods

predict(x, key, nd=None, scaler=None)

Evaluate typical load profiles based on ToU energy consumption values and using the SLPs.

add_data(x, y)

Add new data points to the predictor.

See Also

BasePredictor : Base class for typical load profile predictors.

predict(x, key)

Evaluate typical load profiles in multiple points, based on ToU energy consumption values, using the SLPs.

Parameters

xarray-like

ToU energy consumption values of the point(s) to predict.

keytuple or list of tuples

Key values related to the SLP associated with each point.

Returns

np.ndarray

Predicted typical load profiles based on the provided inputs.

Notes

If ‘x’ (and other input parameters) refer to a single point, then the output is provided with a shape of a single point.

Raises

AssertionError

If any inconsistency is found in the input data or key values are not present in the model data.

Module contents