forked from alberto-spadoni3/SSD-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
68 lines (52 loc) · 2.57 KB
/
main.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
import os
import pandas as pd
from plot_functions import plot_data, plot_all_museums
from utility_functions import *
from trend_season_functions import run_TREND_SEASON
from SARIMA import run_SARIMA
from LSTM import run_LSTM
from MLP import run_MLP
from RANDOM_FOREST import run_RANDOM_FOREST
if __name__ == '__main__':
os.chdir(os.path.dirname(os.path.abspath(__file__)))
all_visitors = pd.read_csv("Data/museum-visitors.csv", parse_dates=["Month"], index_col=0)
# plot_all_museums(museum_visitors)
# Si è scelto di lavorare sui visitatori del museo 'Avila Adobe'
museum_visitors = get_visitors_of("Avila Adobe", all_visitors)
plot_data(museum_visitors)
# Esclusione dati del periodo COVID
museum_visitors = museum_visitors.iloc[:74]
number_of_measurements = len(museum_visitors.Visitors)
periods_to_forecast = 24
cutpoint = int(0.8 * len(museum_visitors.Visitors))
# Estensione delle date per includere i valori predetti
extended_dates = extend_dates(museum_visitors, periods_to_forecast)
# Creazione del modello tramite ricerca del trend, stagionalità e relativi coefficienti
run_TREND_SEASON(museum_visitors, number_of_measurements, periods_to_forecast, extended_dates)
# Algoritmo predittivo statistico
# check_stationarity(museum_visitors)
run_SARIMA(number_of_measurements, museum_visitors, extended_dates, periods_to_forecast)
# Algoritmi predittivo neurali
MLP_predictions = run_MLP(museum_visitors, extended_dates, periods_to_forecast, cutpoint)
LSTM_predictions = run_LSTM(museum_visitors, extended_dates, periods_to_forecast, cutpoint)
# Algoritmo Machine Learning
RF_predictions = run_RANDOM_FOREST(museum_visitors, extended_dates, periods_to_forecast, cutpoint)
print("\n-------Diebold-Mariano Test-------")
# Confronto MLP e LSTM
diebold_mariano(museum_visitors.Visitors[cutpoint:], MLP_predictions, LSTM_predictions, "MLP", "LSTM")
# Confronto RF e MLP
diebold_mariano(museum_visitors.Visitors[cutpoint:], RF_predictions, MLP_predictions, "RF", "MLP")
# Confronto RF e LSTM
diebold_mariano(museum_visitors.Visitors[cutpoint:], RF_predictions, LSTM_predictions, "RF", "LSTM")
'''
PARTE 1
- Trovare funzione di trend e parameter fitting - DONE
- Eliminare trend - DONE
- Determinare se utilizzare un modello moltiplicativo o additivo - DONE
- Individuare stagionalità - DONE
- Destagionalizzare - DONE
- Fare previsione con funzione di trend - DONE
PARTE 2
- Fare previsione con modelli predittivi statistici e neurali - DONE
- Analizzare e confrontare i risultati - DONE
'''