Skip to content

Commit

Permalink
webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
nipunbatra committed Nov 3, 2016
1 parent 54984bf commit 564dd02
Show file tree
Hide file tree
Showing 6 changed files with 46,425 additions and 72 deletions.
32 changes: 18 additions & 14 deletions mf_approach/code/compute_error_all_appliances_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ def compute_prediction(feature, k):

def find_all_error():
out = {}
for appliance in ['wm','mw','oven','fridge','hvac','dw']:
out[appliance]={}
for feature in ['None', 'occ', 'area','rooms','occ_area','occ_rooms','area_rooms','occ_area_rooms']:
out[appliance][feature]={}
for k in range(1, 10):
try:
print feature, k, appliance
pred_df = compute_prediction(appliance, feature, k)
gt_df = find_gt_df(appliance, pred_df)
out[appliance][feature][k] = find_error_df(gt_df, pred_df)
except:
pass
return out

for feature in ['None', 'occ', 'area','rooms','occ_area','occ_rooms','area_rooms']:
out[feature]={}
for k in range(1, 10):
try:
print feature, k,
pred_df = compute_prediction(feature, k)
gt_df = find_gt_df(appliance, pred_df)
out[feature][k] = find_error_df(gt_df, pred_df)
except:
pass
return out

def find_gt_df(appliance, pred_df):
import pickle
Expand Down Expand Up @@ -56,13 +55,18 @@ def find_optimal(appliance):
def create_overall_dict():
out = {}
for appliance in ['wm','mw','oven','fridge','hvac','dw']:
if appliance=="hvac":
start, stop = 5, 11
else:
start, stop =1,13
appliance_cols = [appliance+"_"+str(m) for m in range(start, stop)]
out[appliance]={}
for feature in ['None', 'occ', 'area','rooms','occ_area','occ_rooms','area_rooms','occ_area_rooms']:
out[appliance][feature]={}
for k in range(1, 10):
try:
print feature, k, appliance
pred_df = compute_prediction(appliance, feature, k)
pred_df = compute_prediction(feature, k)[appliance_cols]

out[appliance][feature][k] = pred_df
except:
Expand Down
46,057 changes: 46,057 additions & 0 deletions mf_approach/data/mf_all_appliances_subset.pkl

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,55 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"59\n",
"222\n",
"545\n",
"871\n",
"1283\n",
"1415\n",
"1642\n",
"1790\n",
"2129\n",
"2242\n",
"2470\n",
"Failure:Interrupted\n",
"Exception occured 'Interrupted'\n",
"2859\n",
"2986\n",
"3367\n",
"3577\n",
"3778\n",
"3967\n",
"4297\n",
"4505\n",
"4946\n",
"5026\n",
"5371\n",
"5677\n",
"5817\n",
"6266\n",
"6836\n",
"7390\n",
"7641\n",
"7769\n",
"7866\n",
"8317\n",
"9134\n",
"9647\n",
"9922\n",
"9971\n"
]
}
],
"source": [
"for ind, home in enumerate(dfc.index[:]):\n",
" if ind%3==1:\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,44 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"94\n",
"252\n",
"624\n",
"946\n",
"1310\n",
"1463\n",
"1697\n",
"1800\n",
"2156\n",
"2365\n",
"2557\n"
]
},
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-4-cc3da05d1496>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[0mpred_df\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mX_normalised\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 49\u001b[0m \u001b[0mpred_df\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mX_normalised\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 50\u001b[0;31m \u001b[0mpred_df\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtransform_all_appliances\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpred_df\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mix\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mhome\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mall_appliances\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcol_max\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcol_min\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mall_appliance_cols_flat\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 51\u001b[0m \u001b[0m_save_results_all_appliances\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlat\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfeature_comb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhome\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpred_df\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 52\u001b[0m \u001b[0;31m#out[lat][home] = transform_2(pred_df.ix[home],all_appliances, col_max, col_min)[all_appliance_cols_flat]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/nipunbatra/git/monthly-disaggregation/mf_approach/code/matrix_factorisation.pyc\u001b[0m in \u001b[0;36mtransform_all_appliances\u001b[0;34m(pred_df, all_appliances, col_max, col_min)\u001b[0m\n\u001b[1;32m 213\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 214\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mmonth\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstart\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstop\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 215\u001b[0;31m \u001b[0mpred_df_copy\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'%s_%d'\u001b[0m \u001b[0;34m%\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mappliance\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mmonth\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mcol_max\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0mcol_min\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mpred_df\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'%s_%d'\u001b[0m\u001b[0;34m%\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mappliance\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mmonth\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m\u001b[0mcol_min\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 216\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mpred_df_copy\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/nipunbatra/anaconda/lib/python2.7/site-packages/pandas/core/generic.pyc\u001b[0m in \u001b[0;36mstat_func\u001b[0;34m(self, axis, skipna, level, numeric_only, **kwargs)\u001b[0m\n\u001b[1;32m 4835\u001b[0m skipna=skipna)\n\u001b[1;32m 4836\u001b[0m return self._reduce(f, name, axis=axis,\n\u001b[0;32m-> 4837\u001b[0;31m skipna=skipna, numeric_only=numeric_only)\n\u001b[0m\u001b[1;32m 4838\u001b[0m \u001b[0mstat_func\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__name__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4839\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mstat_func\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/nipunbatra/anaconda/lib/python2.7/site-packages/pandas/core/series.pyc\u001b[0m in \u001b[0;36m_reduce\u001b[0;34m(self, op, name, axis, skipna, numeric_only, filter_type, **kwds)\u001b[0m\n\u001b[1;32m 2191\u001b[0m raise NotImplementedError(\n\u001b[1;32m 2192\u001b[0m 'Series.{0} does not implement numeric_only.'.format(name))\n\u001b[0;32m-> 2193\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdelegate\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskipna\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mskipna\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2194\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2195\u001b[0m return delegate._reduce(op=op, name=name, axis=axis, skipna=skipna,\n",
"\u001b[0;32m/Users/nipunbatra/anaconda/lib/python2.7/site-packages/pandas/core/nanops.pyc\u001b[0m in \u001b[0;36mf\u001b[0;34m(values, axis, skipna, **kwds)\u001b[0m\n\u001b[1;32m 94\u001b[0m if _USE_BOTTLENECK and skipna and _bn_ok_dtype(values.dtype,\n\u001b[1;32m 95\u001b[0m bn_name):\n\u001b[0;32m---> 96\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbn_func\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 97\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 98\u001b[0m \u001b[0;31m# prefer to treat inf/-inf as NA, but must compute the func\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"for ind, home in enumerate(dfc.index[:]):\n",
" if ind%3==2:\n",
Expand Down
Loading

0 comments on commit 564dd02

Please sign in to comment.