Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DCRNN
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yan
DCRNN
Commits
4140d370
Commit
4140d370
authored
Jul 11, 2022
by
yan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
3f1a2e18
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
7 deletions
+29
-7
readnpz.py
readnpz.py
+9
-0
test.py
test.py
+18
-5
train.py
train.py
+2
-2
No files found.
readnpz.py
0 → 100644
View file @
4140d370
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
test.py
View file @
4140d370
...
...
@@ -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
...
...
train.py
View file @
4140d370
...
...
@@ -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
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment