Commit 4140d370 by yan

Initial commit

parent 3f1a2e18
import numpy as np
data = np.load("./saved/results/dcrnn_predictions.npz")
for key, value in data.items():
print(key)
print(value)
# np.savetxt("./saved/results" + key + ".csv", value)
\ No newline at end of file
......@@ -13,9 +13,9 @@ import time
def main(config):
logger = config.get_logger('test')
graph_pkl_filename = 'data/sensor_graph/adj_mx_unix.pkl'
graph_pkl_filename = 'data/sensor_graph/adj_mx_2.pkl'
_, _, adj_mat = utils.load_graph_data(graph_pkl_filename)
data = utils.load_dataset(dataset_dir='data/METR-LA',
data = utils.load_dataset(dataset_dir='data/metr-la-datasets-10',
batch_size=config["arch"]["args"]["batch_size"],
test_batch_size=config["arch"]["args"]["batch_size"])
test_data_loader = data['test_loader']
......@@ -57,6 +57,10 @@ def main(config):
y_preds = torch.transpose(y_preds, 0, 1)
y_preds = y_preds.detach().numpy() # cast to numpy array
print("--------test results--------")
clients_avg_mae = []
clients_avg_mape = []
clients_avg_rmse = []
clients_avg_pcc = []
for horizon_i in range(y_truths.shape[1]):
y_truth = np.squeeze(y_truths[:, horizon_i, :, 0])
......@@ -67,13 +71,22 @@ def main(config):
mae = metrics.masked_mae_np(y_pred[:y_truth.shape[0]], y_truth, null_val=0)
mape = metrics.masked_mape_np(y_pred[:y_truth.shape[0]], y_truth, null_val=0)
rmse = metrics.masked_rmse_np(y_pred[:y_truth.shape[0]], y_truth, null_val=0)
pcc= metrics.masked_pcc(y_pred[:y_truth.shape[0]], y_truth, null_val=0)
clients_avg_mae.append(mae)
clients_avg_mape.append(mape)
clients_avg_rmse.append(rmse)
clients_avg_pcc.append(pcc)
print(
"Horizon {:02d}, MAE: {:.2f}, MAPE: {:.4f}, RMSE: {:.2f}".format(
horizon_i + 1, mae, mape, rmse
"Horizon {:02d}, MAE: {:.2f}, MAPE: {:.4f}, RMSE: {:.2f}, PCC: {:.4f}".format(
horizon_i + 1, mae, mape, rmse, pcc
)
)
log = {"Horizon": horizon_i+1, "MAE": mae, "MAPE": mape, "RMSE": rmse}
log = {"Horizon": horizon_i+1, "MAE": mae, "MAPE": mape, "RMSE": rmse, "PCC": pcc}
logger.info(log)
printlog = 'On average over 12 horizons, Test MAE: {:.4f}, Test MAPE: {:.4f}, Test RMSE: {:.4f}, Test PCC: {:.4f}'
print(printlog.format(np.mean(clients_avg_mae),np.mean(clients_avg_mape),np.mean(clients_avg_rmse),np.mean(clients_avg_pcc)))
log = {"On average over 12 horizons, MAE": np.mean(clients_avg_mae), "MAPE":np.mean(clients_avg_mape), "RMSE": np.mean(clients_avg_rmse), "PCC": np.mean(clients_avg_pcc)}
logger.info(log)
outputs = {
'predictions': predictions,
'groundtruth': groundtruth
......
......@@ -12,9 +12,9 @@ import math
def main(config):
logger = config.get_logger('train')
graph_pkl_filename = 'data/sensor_graph/adj_mx_unix.pkl'
graph_pkl_filename = 'data/sensor_graph/adj_mx_bay_5.pkl'
_, _, adj_mat = utils.load_graph_data(graph_pkl_filename)
data = utils.load_dataset(dataset_dir='data/METR-LA',
data = utils.load_dataset(dataset_dir='data/pems-bay-datasets-10',
batch_size=config["arch"]["args"]["batch_size"],
test_batch_size=config["arch"]["args"]["batch_size"])
for k, v in data.items():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment