In [3]:
from __future__ import print_function, division
from neuralnilm import RealApplianceSource
import matplotlib.pyplot as plt
import numpy as np
In [91]:
source = RealApplianceSource(
filename='/data/mine/vadeec/merged/ukdale.h5',
appliances=[
['fridge freezer', 'fridge', 'freezer'],
'hair straighteners',
'television',
'dish washer',
['washer dryer', 'washing machine']
],
max_appliance_powers=[300, 500, 200, 2500, 2400],
n_seq_per_batch=2,
max_input_power=5900,
on_power_thresholds=[20, 20, 20, 20, 10],
min_on_durations=[60, 60, 60, 1800, 1800],
window=("2013-06-01", "2013-07-01"),
seq_length=1500,
output_one_appliance=False,
boolean_targets=False,
min_off_durations=[60] * 5,
subsample_target=5,
train_buildings=[1],
validation_buildings=[1],
skip_probability=0.7
)
In [92]:
X, y = source._gen_data()
In [93]:
def cost(x, t):
return (x - t) ** 2
In [94]:
t = y
noise = np.random.randn(*y.shape) * 0.1
x = t + noise
raw_cost = (x - t) ** 2
In [102]:
sum_over_sequences = t.sum(axis=1)
sum_over_sequences
Out[102]:
In [103]:
sum_over_batches = sum_over_sequences.sum(axis=1)
In [104]:
sum_over_batches = sum_over_batches.reshape(-1,1)
sum_over_batches
Out[104]:
In [105]:
normed = sum_over_sequences / sum_over_batches
normed
Out[105]:
In [108]:
normed[1,:].sum()
Out[108]:
In [111]:
raw_cost.mean(axis=1)
Out[111]:
In [122]:
cost = raw_cost.mean(axis=1) * (1 - normed)
cost
Out[122]:
In [123]:
cost.mean()
Out[123]:
In [119]:
1 - normed
Out[119]:
In [116]:
normed / normed.sum(axis=1)
In [117]:
normed.sum(axis=1)
Out[117]:
In [ ]: