mean=mean) max_power = params_appliance[application]['max_on_power'] threshold = params_appliance[application]['on_power_threshold'] ground_truth = ground_truth[offset:-offset] * std + mean mains = (test_set_x[offset:-offset]) * std + mean prediction = test_prediction[offset:-offset] prediction[prediction <= 0.0] = 0.0 print(prediction.shape) print(ground_truth.shape) # np.save(args.appliance_name.replace(" ","_")+'_prediction', prediction) # to load results: np.load(args.appliance_name+'_prediction') sess.close() sample_second = 6.0 # sample time is 6 seconds print('F1:{0}'.format( nm.get_F1(ground_truth.flatten(), prediction.flatten(), threshold))) print('NDE:{0}'.format(nm.get_nde(ground_truth.flatten(), prediction.flatten()))) print('MAE:{0}'.format( nm.get_abs_error(ground_truth.flatten(), prediction.flatten()))) print('SAE:{0}'.format( nm.get_sae(ground_truth.flatten(), prediction.flatten(), sample_second))) save_name_y_pred = 'results/' + 'pointnet_building2_' + args.appliance_name + '_pred.npy' #save path for mains save_name_y_gt = 'results/' + 'pointnet_building2_' + args.appliance_name + '_gt.npy' #save path for target save_name_mains = 'results/' + 'pointnet_building2_' + args.appliance_name + '_mains.npy' #save path for target np.save(save_name_y_pred, prediction) np.save(save_name_y_gt, ground_truth) np.save(save_name_mains, mains)
log('appliance_std: ' + str(appliance_std)) prediction = test_prediction * appliance_std + appliance_mean prediction[prediction <= 0.0] = 0.0 ground_truth = ground_truth * appliance_std + appliance_mean sess.close() # ------------------------------------------ metric evaluation---------------------------------------------------------- sample_second = 8.0 # sample time is 8 seconds log('F1:{0}'.format(nm.get_F1(ground_truth.flatten(), prediction.flatten(), threshold))) log('NDE:{0}'.format(nm.get_nde(ground_truth.flatten(), prediction.flatten()))) log('\nMAE: {:}\n -std: {:}\n -min: {:}\n -max: {:}\n -q1: {:}\n -median: {:}\n -q2: {:}' .format(*nm.get_abs_error(ground_truth.flatten(), prediction.flatten()))) log('SAE: {:}'.format(nm.get_sae(ground_truth.flatten(), prediction.flatten(), sample_second))) log('Energy per Day: {:}'.format(nm.get_Epd(ground_truth.flatten(), prediction.flatten(), sample_second))) # ----------------------------------------------- save results --------------------------------------------------------- savemains = test_set_x.flatten() * aggregate_std + aggregate_mean savegt = ground_truth savepred = prediction.flatten() if args.transfer: save_name = args.save_results_dir + '/' + appliance_name + '/' + test_filename + '_transf_' + args.cnn # save path for mains else: save_name = args.save_results_dir + '/' + appliance_name + '/' + test_filename # save path for mains if not os.path.exists(save_name): os.makedirs(save_name) # Numpy saving