Bases: object
Attributes: | elec : MeterGroup metadata : dict
|
---|
File defining custom nilmtk exception classes.
Metrics to compare disaggregation performance against ground truth data.
All metrics functions have the same interface. Each function takes predictions and ground_truth parameters. Both of which are nilmtk.MeterGroup objects. Each function returns one of two types: either a pd.Series or a single float. Most functions return a pd.Series where each index element is a meter instance int or a tuple of ints for MeterGroups.
Below is the notation used to mathematically define each metric.
\(T\) - number of time slices.
\(t\) - a time slice.
\(N\) - number of appliances.
\(n\) - an appliance.
\(y^{(n)}_t\) - ground truth power of appliance \(n\) in time slice \(t\).
\(\hat{y}^{(n)}_t\) - estimated power of appliance \(n\) in time slice \(t\).
\(x^{(n)}_t\) - ground truth state of appliance \(n\) in time slice \(t\).
\(\hat{x}^{(n)}_t\) - estimated state of appliance \(n\) in time slice \(t\).
Compute error in assigned energy.
Parameters: | predictions, ground_truth : nilmtk.MeterGroup |
---|---|
Returns: | errors : pd.Series
|
Compute F1 scores.
Parameters: | predictions, ground_truth : nilmtk.MeterGroup |
---|---|
Returns: | f1_scores : pd.Series
|
Compute fraction of energy assigned correctly
Ignores distinction between different AC types, instead if there are multiple AC types for each meter then we just take the max value across the AC types.
Parameters: | predictions, ground_truth : nilmtk.MeterGroup |
---|---|
Returns: | fraction : float in the range [0,1]
|
Compute mean normalized error in assigned power
Parameters: | predictions, ground_truth : nilmtk.MeterGroup |
---|---|
Returns: | mne : pd.Series
|
Compute RMS error in assigned power
Parameters: | predictions, ground_truth : nilmtk.MeterGroup |
---|---|
Returns: | error : pd.Series
|
Set up matplotlib’s RC params for LaTeX plotting. Call this before plotting a figure.
Parameters: | fig_width : float, optional, inches fig_height : float, optional, inches columns : {1, 2} |
---|
Plot function for series which is about 5 times faster than pd.Series.plot().
Parameters: | ax : matplotlib Axes, optional
fig : date_format : str, optional, default=’%d/%m/%y %H:%M:%S’ Can also use all **kwargs expected by `ax.plot` : |
---|
Find closest value in known_array for each element in test_array.
Parameters: | known_array : numpy array
test_array : numpy array
|
---|---|
Returns: | indices : numpy array; shape: (n, 1)
residuals : numpy array; shape: (n, 1)
|
Parameters: | data : pandas.DataFrame or Series or DatetimeIndex |
---|---|
Returns: | index : the index for the DataFrame or Series |