-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomparation.py
69 lines (45 loc) · 1.76 KB
/
comparation.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 13 17:07:07 2022
@author: guane
"""
#%% Libraries
import os
import pandas as pd
import numpy as np
import seaborn as sns
from scipy import stats
import scikit_posthocs as sp
import stac
import matplotlib.pyplot as plt
location = os.getcwd()
#%% Load data and variables
df = pd.read_excel("data/Metrics.xlsx", index_col=0, sheet_name='Table')
data = np.asarray(df.iloc[1:,2:])
metrics = ['MSE', 'RMSE', 'MAE', 'MAPE']
values = [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44]
names = ['MSE-RNN','MSE-GRU','MSE-LSTM', 'Kernel MSE-RNN', 'Kernel MSE-GRU',
'Kernel MSE-LSTM','L1-RNN', 'L1-GRU', 'L1-LSTM', 'Proposal-RNN',
'Proposal-GRU', 'Proposal-LSTM']
results_ranking = np.zeros(data.shape)
#%% Code
# Prediction horizon models
prediction = 1
for i in range(data.shape[1]):
print("\n Prediction horizon {horizon} ------------------ ".format(horizon=str(prediction)))
if prediction == 7:
prediction = 1
else:
prediction += 1
# Performance metrics
for j in range(len(metrics)):
print('Performance {}'.format(metrics[j]))
index = [values[k] + j for k in range(len(values))]
data_ranking = np.array([data[int(index[q])][i] for q in range(len(index))])
values_for_ranking = pd.Series(data_ranking, index=names)
ser = pd.Series(data_ranking, index=names).rank(ascending=True)
# Save results ------------------------------------------------------
for s in range(len(ser)):
#print(i, index[s], ser[s])
results_ranking[index[s]][i] = int(ser[s])