Esempio n. 1
0
# Loading data from HDF5 store
dataset = DataSet()
t1 = time.time()
dataset.load_hdf5(EXPORT_PATH)
t2 = time.time()
print("Runtime to import from HDF5 = {:.2f}".format(t2 - t1))

# Experiment on first (and only) building
b = dataset.buildings[1]

# Filtering to include only top 8 appliances
b = filter_top_k_appliances(b, 3)

# Dividing the data into train and test
train, test = train_test_split(b)

# Again subdivide data into train, test for testing on even smaller data
#train, test = train_test_split(train, test_size=.5)


# Initializing FHMM Disaggregator
disaggregator = FHMM()
train_mains = train.utility.electric.mains[
    train.utility.electric.mains.keys()[0]][DISAGG_FEATURE]

# Get appliances data
app = train.utility.electric.appliances
train_appliances = pd.DataFrame({appliance: app[appliance][DISAGG_FEATURE] for appliance in app if DISAGG_FEATURE in app[appliance]})

Esempio n. 2
0
# Feature to perform disaggregation on
DISAGG_FEATURE = Measurement('power', 'active')

# Load data
dataset.load(PATH)

# Get data of Home_01
building = dataset.buildings[1]

# Let us filter out appliances contributing less than 5%
building = prepb.filter_contribution_less_than_x(building, x=5)


print('Dividing data into test and train')
train, test = train_test_split(building, train_size = 0.5) 

# Train
disaggregator = CO_1d()
disaggregator_name = "CO_1d"
t1 = time.time()
disaggregator.train(train, disagg_features=[DISAGG_FEATURE])
t2 = time.time()
print("Runtime to train for {} = {:.2f} seconds".format(disaggregator_name, t2 - t1))
train_time=t2-t1
    
# Disaggregate
t1 = time.time()
disaggregator.disaggregate(test)
t2 = time.time()
print("Runtime to disaggregate for {}= {:.2f} seconds".format(disaggregator_name, t2 - t1))
Esempio n. 3
0
t1 = time.time()
dataset.export(EXPORT_PATH)
t2 = time.time()
print("Runtime to export to HDF5 = {:.2f}".format(t2 - t1))


# Loading data from HDF5 store
dataset = ampds.AMPDS()
t1 = time.time()
dataset.load_hdf5(EXPORT_PATH)
t2 = time.time()
print("Runtime to import from HDF5 = {:.2f}".format(t2 - t1))

# Dividing the data into train and test
b = dataset.buildings[1]
train, test = train_test_split(b, test_size=.005)

# Initializing CO 1D Disaggregator
disaggregator = CO_1d()
train_mains = train.utility.electric.mains[
    train.utility.electric.mains.keys()[0]][DISAGG_FEATURE]

# Get appliances data
app = train.utility.electric.appliances
train_appliances = pd.DataFrame({appliance: app[appliance][DISAGG_FEATURE] for appliance in app})

# Train
disaggregator.train(train_mains, train_appliances)

# Disaggregate
disaggregator.disaggregate(test.utility.electric.mains[
# Feature to perform disaggregation on
DISAGG_FEATURE = Measurement('power', 'active')

# Load data
dataset.load_electricity(PATH)

# Get data of Home_01
building = dataset.buildings[1]

# Preprocessing:
print(' :::::::::: Dividing data into test and train')
lenToUse = len(building.utility.electric.appliances.items()[0][1])
train, test = train_test_split(
    building,
    train_size=int(float(1) / 2.0 * lenToUse),
    test_size=int(float(1) / 2.0 * lenToUse)
)  # This splits the dataset in 1/2 for training and 1/2 for testing. Test-training ratio should be set by users

###  ---------- Disaggregation with FHMM ---------- #

#  --- training model
disaggregator = FHMM()
disaggregator_name = "FHMM"
print(' :::::::::: Training FHMM disaggregator')
t1 = time.time()
disaggregator.train(train, disagg_features=[DISAGG_FEATURE])
t2 = time.time()
print("Runtime to train for {} = {:.2f} seconds".format(
    disaggregator_name, t2 - t1))
train_time = t2 - t1