Skip to content

Commit

Permalink
Added changes to allow processing of temperature information as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Nipun Batra committed Dec 22, 2016
1 parent 5f28f28 commit 73e7f1b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
27 changes: 22 additions & 5 deletions mf_approach/code/both_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
################################################################


from matrix_factorisation import nmf_features, transform, transform_2, preprocess, get_static_features
from matrix_factorisation import nmf_features, transform, transform_2, \
preprocess, get_static_features, get_static_features_region_level
import os

import numpy as np
Expand Down Expand Up @@ -63,7 +64,13 @@ def create_region_df(region):
df = pd.concat([sd_df, aus_df])
dfc = pd.concat([sd_dfc, aus_dfc])
elif case==3:
pass
sd_df['temperature']=.92
sd_dfc['temperature'] = .92
aus_df['temperature'] = 1.0
aus_dfc['temperature'] = 1.0
df = pd.concat([sd_df, aus_df])
dfc = pd.concat([sd_dfc, aus_dfc])




Expand All @@ -78,7 +85,7 @@ def create_region_df(region):
import itertools
feature_combinations = [['None']]
for l in range(1,4):
for a in itertools.combinations(['occ','area','rooms'], l):
for a in itertools.combinations(['temperature','occ','area','rooms'], l):
feature_combinations.append(list(a))


Expand All @@ -90,15 +97,25 @@ def create_region_df(region):
else:
start, end=1,13
X_matrix, X_normalised, col_max, col_min, appliance_cols, aggregate_cols = preprocess(df, dfc, appliance)
static_features= get_static_features(dfc, X_normalised)

if case==3:
static_features = get_static_features_region_level(dfc, X_normalised)
else:
static_features = get_static_features(dfc, X_normalised)


from copy import deepcopy
all_cols = deepcopy(appliance_cols)
all_cols.extend(aggregate_cols)
#all_feature_homes = dfc[(dfc.full_agg_available == 1) & (dfc.md_available == 1)][all_cols].dropna().index


if case==3:
max_f = 2
else:
max_f=1

for feature_comb in np.array(feature_combinations)[:1]:
for feature_comb in np.array(feature_combinations)[:max_f]:
print feature_comb
out[tuple(feature_comb)]={}
if 'None' in feature_comb:
Expand Down
7 changes: 7 additions & 0 deletions mf_approach/code/matrix_factorisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ def get_static_features(dfc, X_normalised):
rooms = dfc.ix[X_normalised.index].house_num_rooms.div(dfc.ix[X_normalised.index].house_num_rooms.max())
return {"area":area,"occ": occ,"rooms": rooms}

def get_static_features_region_level(dfc, X_normalised):
area = dfc.ix[X_normalised.index].area.div(dfc.ix[X_normalised.index].area.max()).values
occ = dfc.ix[X_normalised.index].num_occupants.div(dfc.ix[X_normalised.index].num_occupants.max()).values
rooms = dfc.ix[X_normalised.index].house_num_rooms.div(dfc.ix[X_normalised.index].house_num_rooms.max())
temperature = dfc.ix[X_normalised.index].temperature.div(dfc.ix[X_normalised.index].temperature.max())
return {"area":area,"occ": occ,"rooms": rooms,"temperature":temperature}

def preprocess_all_appliances(df, dfc):

all_appliances = ['mw','oven','hvac','fridge','dw','wm']
Expand Down

0 comments on commit 73e7f1b

Please sign in to comment.