예제 #1
0
def fraction_energy_assigned_correctly(predictions, ground_truth):
    '''Compute fraction of energy assigned correctly
    
    .. math::
        fraction = 
        \\sum_n min \\left ( 
        \\frac{\\sum_n y}{\\sum_{n,t} y}, 
        \\frac{\\sum_n \\hat{y}}{\\sum_{n,t} \\hat{y}} 
        \\right )

    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]
        Fraction of Energy Correctly Assigned.
    '''

    predictions_submeters = MeterGroup(meters=predictions.submeters().meters)
    ground_truth_submeters = MeterGroup(meters=ground_truth.submeters().meters)

    fraction_per_meter_predictions = predictions_submeters.fraction_per_meter()
    fraction_per_meter_ground_truth = ground_truth_submeters.fraction_per_meter()

    fraction = 0
    for meter_instance in predictions_submeters.instance():
        fraction += min(fraction_per_meter_ground_truth[meter_instance],
                        fraction_per_meter_predictions[meter_instance])
    return fraction
예제 #2
0
def fraction_energy_assigned_correctly(predictions, ground_truth):    
    predictions_submeters = MeterGroup(meters=predictions.submeters().meters)
    ground_truth_submeters = MeterGroup(meters=ground_truth.submeters().meters)
    
    fraction_per_meter_predictions  = predictions_submeters.fraction_per_meter()
    fraction_per_meter_ground_truth = ground_truth_submeters.fraction_per_meter()
    
    fraction = 0
    for meter_instance,v in enumerate(predictions_submeters.instance()):
        fraction += min(fraction_per_meter_ground_truth.values[meter_instance],
                        fraction_per_meter_predictions.values[meter_instance])

    return fraction
예제 #3
0
def fraction_energy_assigned_correctly(predictions, ground_truth):
    predictions_submeters = MeterGroup(meters=predictions.submeters().meters)
    ground_truth_submeters = MeterGroup(meters=ground_truth.submeters().meters)

    fraction_per_meter_predictions = predictions_submeters.fraction_per_meter()
    fraction_per_meter_ground_truth = ground_truth_submeters.fraction_per_meter(
    )

    fraction = 0
    for meter_instance, v in enumerate(predictions_submeters.instance()):
        fraction += min(fraction_per_meter_ground_truth.values[meter_instance],
                        fraction_per_meter_predictions.values[meter_instance])

    return fraction
예제 #4
0
warnings.simplefilter('default')

# Silence ImportWarnings for the time being
warnings.filterwarnings('ignore', category=ImportWarning)

from nilmtk import *
from nilmtk.version import version as __version__
from nilmtk.timeframe import TimeFrame
from nilmtk.elecmeter import ElecMeter
from nilmtk.datastore import DataStore, HDFDataStore, CSVDataStore, Key
from nilmtk.metergroup import MeterGroup
from nilmtk.appliance import Appliance
from nilmtk.building import Building
from nilmtk.dataset import DataSet

global_meter_group = MeterGroup()


def teardown_package():
    """Nosetests package teardown function (run when tests are done).
    See http://nose.readthedocs.org/en/latest/writing_tests.html#test-packages

    Uses git to reset data_dir after tests have run.
    """
    from nilmtk.tests.testingtools import data_dir
    import subprocess
    
    #Workaround for open .h5 files on Windows
    from tables.file import _open_files
    _open_files.close_all()