'update'
[talweg.git] / reports / report.gj
... / ...
CommitLineData
1-----
2<h2>Introduction</h2>
3
4J'ai fait quelques essais dans deux configurations pour la méthode "Neighbors"
5(la seule dont on a parlé, incorporant désormais la "variante Bruno/Michel").
6
7 * avec simtype="mix" et raccordement simple ("Zero") dans le cas "non local", i.e. on va
8 chercher des voisins n'importe où du moment qu'ils correspondent à deux jours consécutifs sans
9 valeurs manquantes.
10 * avec simtype="endo" et raccordement "Neighbor" dans le cas "local" : voisins de même niveau de
11 pollution et même saison.
12
13J'ai systématiquement comparé à une approche naïve : la moyenne des lendemains des jours
14"similaires" dans tout le passé, ainsi qu'à la persistence -- reproduisant le jour courant ou
15allant chercher le futur similaire une semaine avant.
16
17Ensuite j'affiche les erreurs, quelques courbes prévues/mesurées, quelques filaments puis les
18histogrammes de quelques poids. Concernant les graphes de filaments, la moitié gauche du graphe
19correspond aux jours similaires au jour courant, tandis que la moitié droite affiche les
20lendemains : ce sont donc les voisinages tels qu'utilisés dans l'algorithme.
21
22<%
23list_titles = ['Pollution par chauffage', 'Pollution par épandage', 'Semaine non polluée']
24list_indices = ['indices_ch', 'indices_ep', 'indices_np']
25%>
26-----r
27library(talweg)
28
29P = ${P} #instant de prévision
30H = ${H} #horizon (en heures)
31
32ts_data = read.csv(system.file("extdata","pm10_mesures_H_loc_report.csv",package="talweg"))
33exo_data = read.csv(system.file("extdata","meteo_extra_noNAs.csv",package="talweg"))
34# NOTE: 'GMT' because DST gaps are filled and multiple values merged in above dataset.
35# Prediction from P+1 to P+H included.
36data = getData(ts_data, exo_data, input_tz = "GMT", working_tz="GMT", predict_at=P)
37
38indices_ch = seq(as.Date("2015-01-18"),as.Date("2015-01-24"),"days")
39indices_ep = seq(as.Date("2015-03-15"),as.Date("2015-03-21"),"days")
40indices_np = seq(as.Date("2015-04-26"),as.Date("2015-05-02"),"days")
41
42% for i in range(3):
43-----
44<h2 style="color:blue;font-size:2em">${list_titles[i]}</h2>
45-----r
46p_n = computeForecast(data, ${list_indices[i]}, "Neighbors", "Zero", horizon=H,
47 simtype="mix", local=FALSE)
48p_l = computeForecast(data, ${list_indices[i]}, "Neighbors", "Neighbors", horizon=H,
49 simtype="endo", local=TRUE)
50p_a = computeForecast(data, ${list_indices[i]}, "Average", "Zero", horizon=H)
51p_p = computeForecast(data, ${list_indices[i]}, "Persistence", "Zero", horizon=H,
52 same_day=${'TRUE' if loop.index < 2 else 'FALSE'})
53-----r
54e_n = computeError(data, p_n, H)
55e_l = computeError(data, p_nl, H)
56e_a = computeError(data, p_a, H)
57e_p = computeError(data, p_p, H)
58options(repr.plot.width=9, repr.plot.height=7)
59plotError(list(e_n, e_p, e_a, e_l), cols=c(1,2,colors()[258], 4))
60
61# Noir: Neighbors non-local, bleu: Neighbors local, vert: moyenne, rouge: persistence
62
63i_np = which.min(e_n$abs$indices)
64i_p = which.max(e_n$abs$indices)
65-----r
66options(repr.plot.width=9, repr.plot.height=4)
67par(mfrow=c(1,2))
68
69plotPredReal(data, p_n, i_np); title(paste("PredReal non-loc day",i_np))
70plotPredReal(data, p_n, i_p); title(paste("PredReal non-loc day",i_p))
71
72plotPredReal(data, p_l, i_np); title(paste("PredReal loc day",i_np))
73plotPredReal(data, p_l, i_p); title(paste("PredReal loc day",i_p))
74
75plotPredReal(data, p_a, i_np); title(paste("PredReal avg day",i_np))
76plotPredReal(data, p_a, i_p); title(paste("PredReal avg day",i_p))
77
78# Bleu: prévue, noir: réalisée
79-----r
80par(mfrow=c(1,2))
81f_np_n = computeFilaments(data, p_n, i_np, plot=TRUE); title(paste("Filaments non-loc day",i_np))
82f_p_n = computeFilaments(data, p_n, i_p, plot=TRUE); title(paste("Filaments non-loc day",i_p))
83
84f_np_l = computeFilaments(data, p_l, i_np, plot=TRUE); title(paste("Filaments loc day",i_np))
85f_p_l = computeFilaments(data, p_l, i_p, plot=TRUE); title(paste("Filaments loc day",i_p))
86-----r
87par(mfrow=c(1,2))
88plotFilamentsBox(data, f_np_n); title(paste("FilBox non-loc day",i_np))
89plotFilamentsBox(data, f_p_n); title(paste("FilBox non-loc day",i_p))
90
91# Generally too few neighbors:
92#plotFilamentsBox(data, f_np_l); title(paste("FilBox loc day",i_np))
93#plotFilamentsBox(data, f_p_l); title(paste("FilBox loc day",i_p))
94-----r
95par(mfrow=c(1,2))
96plotRelVar(data, f_np_n); title(paste("StdDev non-loc day",i_np))
97plotRelVar(data, f_p_n); title(paste("StdDev non-loc day",i_p))
98
99plotRelVar(data, f_np_l); title(paste("StdDev loc day",i_np))
100plotRelVar(data, f_p_l); title(paste("StdDev loc day",i_p))
101
102# Variabilité globale en rouge ; sur les 60 voisins (+ lendemains) en noir
103-----r
104par(mfrow=c(1,2))
105plotSimils(p_n, i_np); title(paste("Weights non-loc day",i_np))
106plotSimils(p_n, i_p); title(paste("Weights non-loc day",i_p))
107
108plotSimils(p_l, i_np); title(paste("Weights loc day",i_np))
109plotSimils(p_l, i_p); title(paste("Weights loc day",i_p))
110
111# - pollué à gauche, + pollué à droite
112-----r
113# Fenêtres sélectionnées dans ]0,7] / non-loc à gauche, loc à droite
114p_n$getParams(i_np)$window
115p_n$getParams(i_p)$window
116
117p_l$getParams(i_np)$window
118p_l$getParams(i_p)$window
119% endfor