overall_accuracy = 1.0 * (a[0][0] + a[1][1]) / (np.sum(a)) return precision, recall, overall_accuracy to_consider = ["N2_K3_T50_CO", "N2_K4_T50_CO", "N2_K5_T50_CO","N2_K6_T50_CO", "N3_K3_T50_CO", "N3_K4_T50_CO", "N3_K5_T50_CO","N3_K6_T50_CO", "N4_K3_T50_CO", "N4_K4_T50_CO", "N4_K5_T50_CO","N4_K6_T50_CO", "N2_K3_T50_FHMM", "N2_K4_T50_FHMM", "N2_K5_T50_FHMM","N2_K6_T50_FHMM", "N3_K3_T50_FHMM", "N3_K4_T50_FHMM", "N3_K5_T50_FHMM","N3_K6_T50_FHMM", "N4_K3_T50_FHMM", "N4_K4_T50_FHMM", "N4_K5_T50_FHMM","N4_K6_T50_FHMM", ] for folder in to_consider: df = pd.read_csv("../../data/hvac/minutes_%s.csv" % folder) df["hvac_class_copy"] = df["hvac_class"].copy() df = df[df.dataid.isin(find_common_dataids())] if NUM_CLASSES == 2: df.hvac_class[(df.hvac_class == "Average") | (df.hvac_class == "Good")] = "Not bad" COLUMN_NAMES = ["Bad", "Not bad"] else: COLUMN_NAMES = ["Average", "Bad", "Good"] np.random.seed(0) clf = joblib.load(os.path.expanduser("~/git/nilm-actionable/data/hvac/rf_hvac.pkl")) true_labels = df['hvac_class'].values pred_labels = clf.predict(df[list(f)]) accur = accuracy_multiclass(true_labels, pred_labels) print folder print accur
return algo_name, algo_N, algo_K def find_p_r_a(a): precision = 1.0 * a[0][0] / (a[0][0] + a[1][0]) recall = 1.0 * a[0][0] / (a[0][0] + a[0][1]) overall_accuracy = 1.0 * (a[0][0] + a[1][1]) / (np.sum(a)) return precision, recall, overall_accuracy to_consider = ["GT", "N4_K3_T50_CO", "N2_K3_T50_FHMM", "N2_K3_T50_Hart"] for plot_num, folder in enumerate(to_consider): df = pd.read_csv("../../data/hvac/minutes_%s.csv" % folder) df["hvac_class_copy"] = df["hvac_class"].copy() df = df[df.dataid.isin(find_common_dataids())] df.index = range(len(df)) if NUM_CLASSES == 2: df.hvac_class[(df.hvac_class == "Average") | (df.hvac_class == "Good")] = "Not bad" COLUMN_NAMES = ["Bad", "Not bad"] else: COLUMN_NAMES = ["Average", "Bad", "Good"] np.random.seed(0) clf = joblib.load( os.path.expanduser("~/git/nilm-actionable/data/hvac/rf_hvac.pkl")) true_labels = df['hvac_class'].values pred_labels = clf.predict(df[list(f)])