Commit | Line | Data |
---|---|---|
f71b975b BA |
1 | -----r |
2 | library(talweg) | |
3 | ||
4 | P = ${P} #première heure de prévision | |
5 | H = ${H} #dernière heure de prévision | |
6 | ||
7 | ts_data = read.csv(system.file("extdata","pm10_mesures_H_loc.csv", | |
8 | package="talweg")) | |
9 | exo_data = read.csv(system.file("extdata","meteo_extra_noNAs.csv", | |
10 | package="talweg")) | |
11 | data = getData(ts_data, exo_data) | |
12 | ||
13 | indices = seq(as.Date("2015-01-01"),as.Date("2015-12-31"),"days") | |
14 | -----r | |
15 | p1 = computeForecast(data, indices, "Neighbors", "Neighbors", | |
16 | predict_from=P, horizon=H, simtype="mix", local=FALSE) | |
17 | p2 = computeForecast(data, indices, "Neighbors", NULL, | |
18 | predict_from=P, horizon=H, simtype="none", local=TRUE) | |
19 | p3 = computeForecast(data, indices, "Average", "Zero", | |
20 | predict_from=P, horizon=H) | |
21 | p4 = computeForecast(data, indices, "Persistence", "Zero", | |
22 | predict_from=P, horizon=H, same_day=TRUE) | |
23 | -----r | |
24 | e1 = computeError(data, p1, P, H) | |
25 | e2 = computeError(data, p2, P, H) | |
26 | e3 = computeError(data, p3, P, H) | |
27 | e4 = computeError(data, p4, P, H) | |
28 | options(repr.plot.width=9, repr.plot.height=7) | |
29 | plotError(list(e1, e4, e3, e2), cols=c(1,2,colors()[258],4)) | |
30 | ||
31 | # noir: Neighbors non-local (p1), bleu: Neighbors local (p2), | |
32 | # vert: moyenne (p3), rouge: persistence (p4) | |
33 | ||
34 | ## TODO: plot modifié, retourner jour par jour et agréger au mois | |
35 | ||
36 | ## TODO: garder éventuellement ça :: | |
37 | sum_p23 = e2$abs$indices + e3$abs$indices | |
38 | i_np = which.min(sum_p23) #indice de jour "facile" | |
39 | i_p = which.max(sum_p23) #indice de jour "difficile" | |
40 | % if P == 8: | |
41 | -----r | |
42 | options(repr.plot.width=9, repr.plot.height=4) | |
43 | par(mfrow=c(1,2)) | |
44 | ||
45 | plotPredReal(data, p1, i_np); title(paste("PredReal p1 day",i_np)) | |
46 | plotPredReal(data, p1, i_p); title(paste("PredReal p1 day",i_p)) | |
47 | ||
48 | plotPredReal(data, p2, i_np); title(paste("PredReal p2 day",i_np)) | |
49 | plotPredReal(data, p2, i_p); title(paste("PredReal p2 day",i_p)) | |
50 | ||
51 | # Bleu : prévue ; noir : réalisée (confondues jusqu'à predict_from-1) |