In [24]:
from __future__ import print_function, division
import matplotlib.pyplot as plt
import numpy as np
from experiment035 import gen_data, gen_unquantized_data
from nilmtk import DataSet, MeterGroup

In [25]:
dataset = DataSet('/data/mine/vadeec/merged/ukdale.h5')
elec = dataset.buildings[1].elec
APPLIANCES = ['boiler', 'television']
selected_meters = [elec[appliance] for appliance in APPLIANCES]
selected = MeterGroup(selected_meters)

In [26]:
# Generate a "validation" sequence whose cost we will compute
X_val, y_val = gen_unquantized_data(metergroup=selected, validation=False)


Skipping 2014-01-22 00:00:00

In [27]:
plt.plot(y_val[4,:,0])
plt.show()

In [12]:
y_val[0,:,0]


Out[12]:
array([ 0.005,  0.   ,  0.   , ...,  0.   ,  0.   , -0.005])

In [28]:
plt.plot(X_val[4,:,1])
plt.show()

In [3]:
q = quantized(X)

In [7]:
X[0,3,:]


Out[7]:
array([-0.5])

In [31]:
import pandas as pd
from datetime import timedelta
FIRST_DAY = pd.Timestamp("2013-04-12")
start = FIRST_DAY + timedelta(days=605)
dataset.set_window(start, start+timedelta(days=1))
selected.plot()
plt.show()

In [8]:
q[0,3,:]


Out[8]:
array([-1., -1.,  1.,  1.,  1., -1., -1., -1., -1., -1.])

In [11]:
where = np.where(q==1)[0][0]
if where > 5:
    q[5:where] = 1
elif where < 5:
    q[where:5] == 1

In [13]:
X


Out[13]:
array([[[ 0.  ],
        [ 0.75],
        [ 0.  ],
        ..., 
        [ 0.  ],
        [ 0.  ],
        [ 0.  ]],

       [[ 0.  ],
        [ 0.  ],
        [ 0.  ],
        ..., 
        [ 0.25],
        [ 0.  ],
        [ 0.  ]],

       [[ 0.25],
        [ 0.  ],
        [ 0.  ],
        ..., 
        [ 0.  ],
        [ 0.  ],
        [-0.25]],

       ..., 
       [[ 0.  ],
        [-0.75],
        [ 0.  ],
        ..., 
        [ 0.  ],
        [ 0.  ],
        [ 0.  ]],

       [[ 0.25],
        [ 0.  ],
        [ 0.  ],
        ..., 
        [ 0.  ],
        [ 0.  ],
        [ 0.  ]],

       [[ 0.  ],
        [ 0.  ],
        [ 0.  ],
        ..., 
        [ 0.  ],
        [ 0.  ],
        [-0.25]]])

In [3]:
plt.plot(y[0])
plt.show()

In [37]:
X[0]


Out[37]:
array([[-1., -1., -1., ..., -1., -1., -1.],
       [-1., -1., -1., ..., -1., -1., -1.],
       [-1., -1., -1., ..., -1.,  1., -1.],
       ..., 
       [-1., -1., -1., ..., -1., -1., -1.],
       [-1., -1., -1., ..., -1., -1., -1.],
       [-1., -1., -1., ..., -1., -1., -1.]])

In [17]:
plt.plot(np.cumsum(y, axis=1)[0,:,:])
plt.show()

In [25]:
np.mean(((np.cumsum(y, axis=1) - np.cumsum(y+1, axis=1)) / 1000)**2)


Out[25]:
0.053533500000000005

In [23]:
np.cumsum(y+0.6, axis=1)


Out[23]:
array([[[   0.6       ],
        [   1.2       ],
        [   1.8       ],
        ..., 
        [ 238.8       ],
        [ 239.73333333],
        [ 240.33333333]],

       [[   0.6       ],
        [   1.53333333],
        [   2.13333333],
        ..., 
        [ 238.8       ],
        [ 239.4       ],
        [ 240.        ]],

       [[   0.6       ],
        [   1.2       ],
        [   2.13333333],
        ..., 
        [ 238.8       ],
        [ 239.4       ],
        [ 240.        ]],

       ..., 
       [[   0.6       ],
        [   1.2       ],
        [   1.8       ],
        ..., 
        [ 238.8       ],
        [ 239.4       ],
        [ 240.        ]],

       [[   0.93333333],
        [   1.53333333],
        [   2.13333333],
        ..., 
        [ 238.8       ],
        [ 239.4       ],
        [ 240.        ]],

       [[   0.6       ],
        [   1.2       ],
        [   1.8       ],
        ..., 
        [ 238.8       ],
        [ 239.4       ],
        [ 240.        ]]])

In [10]:
np.linspace(-1, 1, 11)


Out[10]:
array([-1. , -0.8, -0.6, -0.4, -0.2,  0. ,  0.2,  0.4,  0.6,  0.8,  1. ])

In [11]:
np.histogram?

In [ ]: