Hourly Model
eemeter.eemeter.models.hourly
¶
Copyright 2014-2024 OpenEEmeter contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
HourlyModel(settings=None)
¶
A class to fit a model to the input meter data.
Attributes:
Name | Type | Description |
---|---|---|
settings |
dict
|
A dictionary of settings. |
baseline_metrics |
dict
|
A dictionary of metrics based on input baseline data and model fit. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
settings |
dict | BaseHourlySettings | None
|
HourlySettings to use (generally left default). Will default to solar model if GHI is given to the fit step. |
None
|
Source code in eemeter/eemeter/models/hourly/model.py
settings = _settings.BaseHourlySettings()
instance-attribute
¶
is_fitted = False
instance-attribute
¶
baseline_metrics = None
instance-attribute
¶
warnings: list[EEMeterWarning] = []
instance-attribute
¶
disqualification: list[EEMeterWarning] = []
instance-attribute
¶
baseline_timezone = None
instance-attribute
¶
error = dict()
instance-attribute
¶
version = __version__
instance-attribute
¶
fit(baseline_data, ignore_disqualification=False)
¶
Fit the model using baseline data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
baseline_data |
HourlyBaselineData
|
HourlyBaselineData object. |
required |
ignore_disqualification |
bool
|
Whether to ignore disqualification errors / warnings. |
False
|
Returns:
Type | Description |
---|---|
HourlyModel
|
The fitted model. |
Raises:
Type | Description |
---|---|
TypeError
|
If baseline_data is not an HourlyBaselineData object. |
DataSufficiencyError
|
If the model can't be fit on disqualified baseline data. |
Source code in eemeter/eemeter/models/hourly/model.py
predict(reporting_data, ignore_disqualification=False)
¶
Predicts the energy consumption using the fitted model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reporting_data |
Union[HourlyBaselineData, HourlyReportingData]
|
The data used for prediction. |
required |
ignore_disqualification |
bool
|
Whether to ignore model disqualification. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
Dataframe with input data along with predicted energy consumption. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the model is not fitted. |
DisqualifiedModelError
|
If the model is disqualified and ignore_disqualification is False. |
TypeError
|
If the reporting data is not of type HourlyBaselineData or HourlyReportingData. |
Source code in eemeter/eemeter/models/hourly/model.py
to_dict()
¶
Returns a dictionary of model parameters.
Returns:
Type | Description |
---|---|
dict
|
Model parameters. |
Source code in eemeter/eemeter/models/hourly/model.py
to_json()
¶
Returns a JSON string of model parameters.
Returns:
Type | Description |
---|---|
str
|
Model parameters. |
from_dict(data)
classmethod
¶
Create a instance of the class from a dictionary (such as one produced from the to_dict method).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict
|
The dictionary containing the model data. |
required |
Returns:
Type | Description |
---|---|
HourlyModel
|
An instance of the class. |
Source code in eemeter/eemeter/models/hourly/model.py
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
|
from_json(str_data)
classmethod
¶
Create an instance of the class from a JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
str_data |
The JSON string representing the object. |
required |
Returns:
Type | Description |
---|---|
HourlyModel
|
An instance of the class. |
Source code in eemeter/eemeter/models/hourly/model.py
plot(df_eval)
¶
Plot a model fit with baseline or reporting data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df_eval |
HourlyBaselineData | HourlyReportingData
|
The baseline or reporting data object to plot. |
required |
Source code in eemeter/eemeter/models/hourly/model.py
HourlyBaselineData(df, is_electricity_data, pv_start=None, **kwargs)
¶
Data class to represent Hourly Baseline Data.
Only baseline data should go into the dataframe input, no blackout data should be input. Checks sufficiency for the data provided as input depending on OpenEEMeter specifications and populates disqualifications and warnings based on it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
A dataframe having a datetime index or a datetime column with the timezone also being set. It also requires 2 more columns - 'observed' for meter data, and 'temperature' for temperature data. Optionally, column 'ghi' can be included in order to fit on solar data. The temperature column should have values in Fahrenheit. Please convert your temperatures accordingly. |
required |
is_electricity_data |
bool
|
Flag to ascertain if this is electricity data or not. Electricity data values of 0 are set to NaN. |
required |
Attributes:
Name | Type | Description |
---|---|---|
df |
DataFrame
|
Immutable dataframe that contains the meter and temperature values for the baseline data period. |
disqualification |
list[EEMeterWarning]
|
A list of serious issues with the data that can degrade the quality of the model. If you want to go ahead with building the model while ignoring them, set the ignore_disqualification = True flag in the model. By default disqualifications are not ignored. |
warnings |
list[EEMeterWarning]
|
A list of issues with the data, but none that will severely reduce the quality of the model built. |
pv_start |
date
|
Solar install date. If left unset, assumed to be at beginning of data. |
Source code in eemeter/eemeter/models/hourly/data.py
warnings = []
instance-attribute
¶
disqualification = []
instance-attribute
¶
is_electricity_data = is_electricity_data
instance-attribute
¶
tz = None
instance-attribute
¶
pv_start = None
instance-attribute
¶
df
property
¶
Get the corrected input data stored in the class. The actual dataframe is immutable, this returns a copy.
log_warnings()
¶
Logs the warnings and disqualifications associated with the data.
HourlyReportingData(df, is_electricity_data, pv_start=None, **kwargs)
¶
Data class to represent Hourly Reporting Data.
Only reporting data should go into the dataframe input, no blackout data should be input. Checks sufficiency for the data provided as input depending on OpenEEMeter specifications and populates disqualifications and warnings based on it.
Meter data input is optional for the reporting class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
A dataframe having a datetime index or a datetime column with the timezone also being set. It also requires 2 more columns - 'observed' for meter data, and 'temperature' for temperature data. If GHI was provided during the baseline period, it should also be supplied for the reporting period with column name 'ghi'. The temperature column should have values in Fahrenheit. Please convert your temperatures accordingly. |
required |
is_electricity_data |
bool
|
Flag to ascertain if this is electricity data or not. Electricity data values of 0 are set to NaN. |
required |
Attributes:
Name | Type | Description |
---|---|---|
df |
DataFrame
|
Immutable dataframe that contains the meter and temperature values for the baseline data period. |
disqualification |
list[EEMeterWarning]
|
A list of serious issues with the data that can degrade the quality of the model. If you want to go ahead with building the model while ignoring them, set the ignore_disqualification = True flag in the model. By default disqualifications are not ignored. |
warnings |
list[EEMeterWarning]
|
A list of issues with the data, but none that will severely reduce the quality of the model built. |
pv_start |
date
|
Solar install date. If left unset, assumed to be at beginning of data. |
Source code in eemeter/eemeter/models/hourly/data.py
warnings = []
instance-attribute
¶
disqualification = []
instance-attribute
¶
is_electricity_data = is_electricity_data
instance-attribute
¶
tz = None
instance-attribute
¶
pv_start = None
instance-attribute
¶
df
property
¶
Get the corrected input data stored in the class. The actual dataframe is immutable, this returns a copy.
log_warnings()
¶
Logs the warnings and disqualifications associated with the data.