In [42]:
import numpy as np
import pandas as pd
from os.path import join
from pylab import rcParams
import matplotlib.pyplot as plt
%matplotlib inline
#rcParams['figure.figsize'] = (12, 6)
rcParams['figure.figsize'] = (13, 6)
plt.style.use('ggplot')
import nilmtk
from nilmtk import DataSet, TimeFrame, MeterGroup, HDFDataStore
from nilmtk.disaggregate import CombinatorialOptimisation
from nilmtk.utils import print_dict, show_versions
from nilmtk.metrics import f1_score
#import seaborn as sns
#sns.set_palette("Set3", n_colors=12)
import warnings
warnings.filterwarnings("ignore")
In [28]:
show_versions()
In [43]:
data_dir = '/Users/GJWood/nilm_gjw_data/HDF5/'
gjw = DataSet(join(data_dir, 'nilm_gjw_data.hdf5'))
print('loaded ' + str(len(gjw.buildings)) + ' buildings')
building_number=1
In [44]:
gjw.store.window = TimeFrame(start='2013-12-03 00:00:00', end='2013-12-05 00:00:00')
elec = gjw.buildings[building_number].elec
mains = elec.mains()
In [45]:
house = elec['fridge'] #only one meter so any selection will do
df = house.load().next() #load the first chunk of data into a dataframe
df.info() #check that the data is what we want (optional)
#note the data has two columns and a time index
In [38]:
df.head()
Out[38]:
In [39]:
df.tail()
Out[39]:
In [46]:
df.plot()
Out[46]:
We'll now do the training from the aggregate data. The algorithm segments the time series data into steady and transient states. Thus, we'll first figure out the transient and the steady states. Next, we'll try and pair the on and the off transitions based on their proximity in time and value.
In [51]:
df.ix['2013-12-03 11:00:00':'2013-12-03 12:00:00'].plot()# select a time range and plot it
Out[51]:
In [48]:
from nilmtk.disaggregate.hart_85 import Hart85
h = Hart85()
h.train(mains,cols=[('power','apparent'),('power','reactive')])
In [49]:
from nilmtk.disaggregate.hart_85 import Hart85
h = Hart85()
h.train(mains,cols=[('power','apparent')])
In [ ]: