-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_loading.py
More file actions
31 lines (25 loc) · 1.2 KB
/
data_loading.py
File metadata and controls
31 lines (25 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import pandas as pd
from .errors import compute_errors
def load_costs(building_strategy_costs, floor_strategy_costs):
building_df = pd.read_csv(building_strategy_costs)
floor_df = pd.read_csv(floor_strategy_costs)
building_df['Strategy'] = 'Building'
floor_df['Strategy'] = 'Floor'
df = pd.concat([building_df, floor_df])
return df[['Strategy', 'N', 'N_CLUSTERS', 'COMP_TIME']].groupby(['Strategy', 'N', 'N_CLUSTERS']).mean().reset_index()
def load_raw_positioning_errors(DIR_PATH):
model_results = {}
for clustering_features in os.listdir(DIR_PATH):
features_dir = os.path.join(DIR_PATH, clustering_features)
if not os.path.isdir(features_dir):
continue
for results_csv in os.listdir(features_dir):
if not results_csv.endswith('csv'):
continue
components = results_csv.split('_')
model = components[0]
strategy = components[-2]
raw_results = pd.read_csv(os.path.join(DIR_PATH, clustering_features, results_csv))
model_results.setdefault(clustering_features, {}).setdefault(strategy, {})[model] = compute_errors(raw_results)
return model_results