cleaning - fix getSimilarDaysIndices ; to finish
[talweg.git] / reports / report.ipynb
CommitLineData
ff5df8e3
BA
1{
2 "cells": [
3 {
4 "cell_type": "markdown",
5e838b3e
BA
5 "metadata": {
6 "deletable": true,
7 "editable": true
8 },
ff5df8e3
BA
9 "source": [
10 "\n",
11 "\n",
12 "<h2>Introduction</h2>\n",
13 "\n",
14 "J'ai fait quelques essais dans différentes configurations pour la méthode \"Neighbors\"\n",
15 "(la seule dont on a parlé).<br>Il semble que le mieux soit\n",
16 "\n",
17 " * simtype=\"exo\" ou \"mix\" : similarités exogènes avec/sans endogènes (fenêtre optimisée par VC)\n",
18 " * same_season=FALSE : les indices pour la validation croisée ne tiennent pas compte des saisons\n",
19 " * mix_strategy=\"mult\" : on multiplie les poids (au lieu d'en éteindre)\n",
20 "\n",
21 "J'ai systématiquement comparé à une approche naïve : la moyennes des lendemains des jours\n",
22 "\"similaires\" dans tout le passé ; à chaque fois sans prédiction du saut (sauf pour Neighbors :\n",
23 "prédiction basée sur les poids calculés).\n",
24 "\n",
25 "Ensuite j'affiche les erreurs, quelques courbes prévues/mesurées, quelques filaments puis les\n",
26 "histogrammes de quelques poids. Concernant les graphes de filaments, la moitié gauche du graphe\n",
27 "correspond aux jours similaires au jour courant, tandis que la moitié droite affiche les\n",
28 "lendemains : ce sont donc les voisinages tels qu'utilisés dans l'algorithme.\n",
29 "\n"
30 ]
31 },
32 {
33 "cell_type": "code",
34 "execution_count": null,
5e838b3e
BA
35 "metadata": {
36 "collapsed": false,
37 "deletable": true,
38 "editable": true
39 },
ff5df8e3
BA
40 "outputs": [],
41 "source": [
42 "library(talweg)\n",
43 "\n",
44 "ts_data = read.csv(system.file(\"extdata\",\"pm10_mesures_H_loc_report.csv\",package=\"talweg\"))\n",
45 "exo_data = read.csv(system.file(\"extdata\",\"meteo_extra_noNAs.csv\",package=\"talweg\"))\n",
5e838b3e
BA
46 "# Predict from P+1 to P+H included\n",
47 "H = 17\n",
48 "data = getData(ts_data, exo_data, input_tz = \"GMT\", working_tz=\"GMT\", predict_at=7)\n",
ff5df8e3
BA
49 "\n",
50 "indices_ch = seq(as.Date(\"2015-01-18\"),as.Date(\"2015-01-24\"),\"days\")\n",
51 "indices_ep = seq(as.Date(\"2015-03-15\"),as.Date(\"2015-03-21\"),\"days\")\n",
5e838b3e 52 "indices_np = seq(as.Date(\"2015-04-26\"),as.Date(\"2015-05-02\"),\"days\")"
ff5df8e3
BA
53 ]
54 },
55 {
56 "cell_type": "markdown",
5e838b3e
BA
57 "metadata": {
58 "deletable": true,
59 "editable": true
60 },
ff5df8e3 61 "source": [
ff5df8e3
BA
62 "<h2 style=\"color:blue;font-size:2em\">Pollution par chauffage</h2>"
63 ]
64 },
65 {
66 "cell_type": "code",
67 "execution_count": null,
5e838b3e
BA
68 "metadata": {
69 "collapsed": false,
70 "deletable": true,
71 "editable": true
72 },
ff5df8e3
BA
73 "outputs": [],
74 "source": [
5e838b3e 75 "reload(\"../pkg\")\n",
a866acb3
BA
76 "#p1 = computeForecast(data, indices_ch, \"Neighbors\", \"Zero\", horizon=H, simtype=\"exo\")\n",
77 "#p2 = computeForecast(data, indices_ch, \"Neighbors\", \"Zero\", horizon=H, simtype=\"endo\")\n",
78 "#p3 = computeForecast(data, indices_ch, \"Neighbors\", \"Zero\", horizon=H, simtype=\"mix\")\n",
5e838b3e
BA
79 "p4 = computeForecast(data, indices_ch, \"Neighbors2\", \"Zero\", horizon=H, simtype=\"exo\")\n",
80 "p5 = computeForecast(data, indices_ch, \"Neighbors2\", \"Zero\", horizon=H, simtype=\"endo\")\n",
a866acb3
BA
81 "p6 = computeForecast(data, indices_ch, \"Neighbors2\", \"Zero\", horizon=H, simtype=\"mix\")"
82 ]
83 },
84 {
85 "cell_type": "code",
86 "execution_count": null,
87 "metadata": {
88 "collapsed": false
89 },
90 "outputs": [],
91 "source": [
92 "getSimilarDaysIndices(1000,10,TRUE,data)"
93 ]
94 },
95 {
96 "cell_type": "code",
97 "execution_count": null,
98 "metadata": {
99 "collapsed": false
100 },
101 "outputs": [],
102 "source": [
103 "as.POSIXlt(data$getTime(1000)[1])"
5e838b3e
BA
104 ]
105 },
106 {
107 "cell_type": "code",
108 "execution_count": null,
109 "metadata": {
110 "collapsed": false
111 },
112 "outputs": [],
113 "source": [
114 "e1 = computeError(data, p1, H)\n",
115 "e2 = computeError(data, p2, H)\n",
116 "e3 = computeError(data, p3, H)\n",
117 "e4 = computeError(data, p4, H)\n",
118 "e5 = computeError(data, p5, H)\n",
119 "e6 = computeError(data, p6, H)\n",
120 "plotError(list(e1,e2,e3,e4,e5,e6), cols=c(1,2,colors()[258], 4,5,6))"
ff5df8e3
BA
121 ]
122 },
123 {
124 "cell_type": "code",
125 "execution_count": null,
5e838b3e
BA
126 "metadata": {
127 "collapsed": false,
128 "deletable": true,
129 "editable": true
130 },
ff5df8e3
BA
131 "outputs": [],
132 "source": [
a866acb3 133 "plotError(list(e4,e1,e2,e3, e5,e6), cols=c(1,2,3,4,5,6))"
ff5df8e3
BA
134 ]
135 },
136 {
137 "cell_type": "code",
138 "execution_count": null,
5e838b3e
BA
139 "metadata": {
140 "collapsed": false,
141 "deletable": true,
142 "editable": true
143 },
ff5df8e3
BA
144 "outputs": [],
145 "source": [
146 "options(repr.plot.width=9, repr.plot.height=4)\n",
147 "par(mfrow=c(1,2))\n",
148 "\n",
149 "plotPredReal(data, p_nn_exo, i_np); title(paste(\"PredReal nn exo day\",i_np))\n",
150 "plotPredReal(data, p_nn_exo, i_p); title(paste(\"PredReal nn exo day\",i_p))\n",
151 "\n",
152 "plotPredReal(data, p_nn_mix, i_np); title(paste(\"PredReal nn mix day\",i_np))\n",
153 "plotPredReal(data, p_nn_mix, i_p); title(paste(\"PredReal nn mix day\",i_p))\n",
154 "\n",
155 "plotPredReal(data, p_az, i_np); title(paste(\"PredReal az day\",i_np))\n",
156 "plotPredReal(data, p_az, i_p); title(paste(\"PredReal az day\",i_p))\n",
157 "\n",
158 "# Bleu: prévue, noir: réalisée"
159 ]
160 },
161 {
162 "cell_type": "code",
163 "execution_count": null,
5e838b3e
BA
164 "metadata": {
165 "collapsed": false,
166 "deletable": true,
167 "editable": true
168 },
ff5df8e3
BA
169 "outputs": [],
170 "source": [
171 "par(mfrow=c(1,2))\n",
172 "f_np_exo = computeFilaments(data, p_nn_exo, i_np, plot=TRUE); title(paste(\"Filaments nn exo day\",i_np))\n",
173 "f_p_exo = computeFilaments(data, p_nn_exo, i_p, plot=TRUE); title(paste(\"Filaments nn exo day\",i_p))\n",
174 "\n",
175 "f_np_mix = computeFilaments(data, p_nn_mix, i_np, plot=TRUE); title(paste(\"Filaments nn mix day\",i_np))\n",
176 "f_p_mix = computeFilaments(data, p_nn_mix, i_p, plot=TRUE); title(paste(\"Filaments nn mix day\",i_p))"
177 ]
178 },
179 {
180 "cell_type": "code",
181 "execution_count": null,
5e838b3e
BA
182 "metadata": {
183 "collapsed": false,
184 "deletable": true,
185 "editable": true
186 },
ff5df8e3
BA
187 "outputs": [],
188 "source": [
189 "par(mfrow=c(1,2))\n",
190 "plotFilamentsBox(data, f_np_exo); title(paste(\"FilBox nn exo day\",i_np))\n",
191 "plotFilamentsBox(data, f_p_exo); title(paste(\"FilBox nn exo day\",i_p))\n",
192 "\n",
193 "plotFilamentsBox(data, f_np_mix); title(paste(\"FilBox nn mix day\",i_np))\n",
194 "plotFilamentsBox(data, f_p_mix); title(paste(\"FilBox nn mix day\",i_p))"
195 ]
196 },
197 {
198 "cell_type": "code",
199 "execution_count": null,
5e838b3e
BA
200 "metadata": {
201 "collapsed": false,
202 "deletable": true,
203 "editable": true
204 },
ff5df8e3
BA
205 "outputs": [],
206 "source": [
207 "par(mfrow=c(1,2))\n",
208 "plotRelVar(data, f_np_exo); title(paste(\"StdDev nn exo day\",i_np))\n",
209 "plotRelVar(data, f_p_exo); title(paste(\"StdDev nn exo day\",i_p))\n",
210 "\n",
211 "plotRelVar(data, f_np_mix); title(paste(\"StdDev nn mix day\",i_np))\n",
212 "plotRelVar(data, f_p_mix); title(paste(\"StdDev nn mix day\",i_p))\n",
213 "\n",
214 "# Variabilité globale en rouge ; sur les 60 voisins (+ lendemains) en noir"
215 ]
216 },
217 {
218 "cell_type": "code",
219 "execution_count": null,
5e838b3e
BA
220 "metadata": {
221 "collapsed": false,
222 "deletable": true,
223 "editable": true
224 },
ff5df8e3
BA
225 "outputs": [],
226 "source": [
227 "par(mfrow=c(1,2))\n",
228 "plotSimils(p_nn_exo, i_np); title(paste(\"Weights nn exo day\",i_np))\n",
229 "plotSimils(p_nn_exo, i_p); title(paste(\"Weights nn exo day\",i_p))\n",
230 "\n",
231 "plotSimils(p_nn_mix, i_np); title(paste(\"Weights nn mix day\",i_np))\n",
d4841a3f 232 "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p))\n",
ff5df8e3
BA
233 "\n",
234 "# - pollué à gauche, + pollué à droite"
235 ]
236 },
237 {
238 "cell_type": "code",
239 "execution_count": null,
5e838b3e
BA
240 "metadata": {
241 "collapsed": false,
242 "deletable": true,
243 "editable": true
244 },
ff5df8e3
BA
245 "outputs": [],
246 "source": [
247 "# Fenêtres sélectionnées dans ]0,10] / endo à gauche, exo à droite\n",
248 "p_nn_exo$getParams(i_np)$window\n",
249 "p_nn_exo$getParams(i_p)$window\n",
250 "\n",
251 "p_nn_mix$getParams(i_np)$window\n",
252 "p_nn_mix$getParams(i_p)$window"
253 ]
254 },
255 {
256 "cell_type": "markdown",
5e838b3e
BA
257 "metadata": {
258 "deletable": true,
259 "editable": true
260 },
ff5df8e3
BA
261 "source": [
262 "\n",
263 "\n",
264 "<h2 style=\"color:blue;font-size:2em\">Pollution par épandage</h2>"
265 ]
266 },
267 {
268 "cell_type": "code",
269 "execution_count": null,
5e838b3e
BA
270 "metadata": {
271 "collapsed": false,
272 "deletable": true,
273 "editable": true
274 },
ff5df8e3
BA
275 "outputs": [],
276 "source": [
55639673
BA
277 "p_nn_exo = computeForecast(data, indices_ep, \"Neighbors\", \"Neighbors\",\n",
278 "\thorizon=3, simtype=\"exo\")\n",
279 "p_nn_mix = computeForecast(data, indices_ep, \"Neighbors\", \"Neighbors\",\n",
280 "\thorizon=3, simtype=\"mix\")\n",
281 "p_az = computeForecast(data, indices_ep, \"Average\", \"Zero\",\n",
282 "\thorizon=3)\n",
283 "p_pz = computeForecast(data, indices_ep, \"Persistence\", \"Zero\",\n",
284 "\thorizon=3, same_day=TRUE)"
ff5df8e3
BA
285 ]
286 },
287 {
288 "cell_type": "code",
289 "execution_count": null,
5e838b3e
BA
290 "metadata": {
291 "collapsed": false,
292 "deletable": true,
293 "editable": true
294 },
ff5df8e3
BA
295 "outputs": [],
296 "source": [
55639673
BA
297 "e_nn_exo = computeError(data, p_nn_exo, 3)\n",
298 "e_nn_mix = computeError(data, p_nn_mix, 3)\n",
299 "e_az = computeError(data, p_az, 3)\n",
300 "e_pz = computeError(data, p_pz, 3)\n",
ff5df8e3
BA
301 "options(repr.plot.width=9, repr.plot.height=7)\n",
302 "plotError(list(e_nn_mix, e_pz, e_az, e_nn_exo), cols=c(1,2,colors()[258], 4))\n",
303 "\n",
304 "# Noir: neighbors_mix, bleu: neighbors_exo, vert: moyenne, rouge: persistence\n",
305 "\n",
306 "i_np = which.min(e_nn_exo$abs$indices)\n",
307 "i_p = which.max(e_nn_exo$abs$indices)"
308 ]
309 },
310 {
311 "cell_type": "code",
312 "execution_count": null,
5e838b3e
BA
313 "metadata": {
314 "collapsed": false,
315 "deletable": true,
316 "editable": true
317 },
ff5df8e3
BA
318 "outputs": [],
319 "source": [
320 "options(repr.plot.width=9, repr.plot.height=4)\n",
321 "par(mfrow=c(1,2))\n",
322 "\n",
323 "plotPredReal(data, p_nn_exo, i_np); title(paste(\"PredReal nn exo day\",i_np))\n",
324 "plotPredReal(data, p_nn_exo, i_p); title(paste(\"PredReal nn exo day\",i_p))\n",
325 "\n",
326 "plotPredReal(data, p_nn_mix, i_np); title(paste(\"PredReal nn mix day\",i_np))\n",
327 "plotPredReal(data, p_nn_mix, i_p); title(paste(\"PredReal nn mix day\",i_p))\n",
328 "\n",
329 "plotPredReal(data, p_az, i_np); title(paste(\"PredReal az day\",i_np))\n",
330 "plotPredReal(data, p_az, i_p); title(paste(\"PredReal az day\",i_p))\n",
331 "\n",
332 "# Bleu: prévue, noir: réalisée"
333 ]
334 },
335 {
336 "cell_type": "code",
337 "execution_count": null,
5e838b3e
BA
338 "metadata": {
339 "collapsed": false,
340 "deletable": true,
341 "editable": true
342 },
ff5df8e3
BA
343 "outputs": [],
344 "source": [
345 "par(mfrow=c(1,2))\n",
346 "f_np_exo = computeFilaments(data, p_nn_exo, i_np, plot=TRUE); title(paste(\"Filaments nn exo day\",i_np))\n",
347 "f_p_exo = computeFilaments(data, p_nn_exo, i_p, plot=TRUE); title(paste(\"Filaments nn exo day\",i_p))\n",
348 "\n",
349 "f_np_mix = computeFilaments(data, p_nn_mix, i_np, plot=TRUE); title(paste(\"Filaments nn mix day\",i_np))\n",
350 "f_p_mix = computeFilaments(data, p_nn_mix, i_p, plot=TRUE); title(paste(\"Filaments nn mix day\",i_p))"
351 ]
352 },
353 {
354 "cell_type": "code",
355 "execution_count": null,
5e838b3e
BA
356 "metadata": {
357 "collapsed": false,
358 "deletable": true,
359 "editable": true
360 },
ff5df8e3
BA
361 "outputs": [],
362 "source": [
363 "par(mfrow=c(1,2))\n",
364 "plotFilamentsBox(data, f_np_exo); title(paste(\"FilBox nn exo day\",i_np))\n",
365 "plotFilamentsBox(data, f_p_exo); title(paste(\"FilBox nn exo day\",i_p))\n",
366 "\n",
367 "plotFilamentsBox(data, f_np_mix); title(paste(\"FilBox nn mix day\",i_np))\n",
368 "plotFilamentsBox(data, f_p_mix); title(paste(\"FilBox nn mix day\",i_p))"
369 ]
370 },
371 {
372 "cell_type": "code",
373 "execution_count": null,
5e838b3e
BA
374 "metadata": {
375 "collapsed": false,
376 "deletable": true,
377 "editable": true
378 },
ff5df8e3
BA
379 "outputs": [],
380 "source": [
381 "par(mfrow=c(1,2))\n",
382 "plotRelVar(data, f_np_exo); title(paste(\"StdDev nn exo day\",i_np))\n",
383 "plotRelVar(data, f_p_exo); title(paste(\"StdDev nn exo day\",i_p))\n",
384 "\n",
385 "plotRelVar(data, f_np_mix); title(paste(\"StdDev nn mix day\",i_np))\n",
386 "plotRelVar(data, f_p_mix); title(paste(\"StdDev nn mix day\",i_p))\n",
387 "\n",
388 "# Variabilité globale en rouge ; sur les 60 voisins (+ lendemains) en noir"
389 ]
390 },
391 {
392 "cell_type": "code",
393 "execution_count": null,
5e838b3e
BA
394 "metadata": {
395 "collapsed": false,
396 "deletable": true,
397 "editable": true
398 },
ff5df8e3
BA
399 "outputs": [],
400 "source": [
401 "par(mfrow=c(1,2))\n",
402 "plotSimils(p_nn_exo, i_np); title(paste(\"Weights nn exo day\",i_np))\n",
403 "plotSimils(p_nn_exo, i_p); title(paste(\"Weights nn exo day\",i_p))\n",
404 "\n",
405 "plotSimils(p_nn_mix, i_np); title(paste(\"Weights nn mix day\",i_np))\n",
d4841a3f 406 "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p))\n",
ff5df8e3
BA
407 "\n",
408 "# - pollué à gauche, + pollué à droite"
409 ]
410 },
411 {
412 "cell_type": "code",
413 "execution_count": null,
5e838b3e
BA
414 "metadata": {
415 "collapsed": false,
416 "deletable": true,
417 "editable": true
418 },
ff5df8e3
BA
419 "outputs": [],
420 "source": [
421 "# Fenêtres sélectionnées dans ]0,10] / endo à gauche, exo à droite\n",
422 "p_nn_exo$getParams(i_np)$window\n",
423 "p_nn_exo$getParams(i_p)$window\n",
424 "\n",
425 "p_nn_mix$getParams(i_np)$window\n",
426 "p_nn_mix$getParams(i_p)$window"
427 ]
428 },
429 {
430 "cell_type": "markdown",
5e838b3e
BA
431 "metadata": {
432 "deletable": true,
433 "editable": true
434 },
ff5df8e3
BA
435 "source": [
436 "\n",
437 "\n",
438 "<h2 style=\"color:blue;font-size:2em\">Semaine non polluée</h2>"
439 ]
440 },
441 {
442 "cell_type": "code",
443 "execution_count": null,
5e838b3e
BA
444 "metadata": {
445 "collapsed": false,
446 "deletable": true,
447 "editable": true
448 },
ff5df8e3
BA
449 "outputs": [],
450 "source": [
55639673
BA
451 "p_nn_exo = computeForecast(data, indices_np, \"Neighbors\", \"Neighbors\",\n",
452 "\thorizon=3, simtype=\"exo\")\n",
453 "p_nn_mix = computeForecast(data, indices_np, \"Neighbors\", \"Neighbors\",\n",
454 "\thorizon=3, simtype=\"mix\")\n",
455 "p_az = computeForecast(data, indices_np, \"Average\", \"Zero\",\n",
456 "\thorizon=3)\n",
457 "p_pz = computeForecast(data, indices_np, \"Persistence\", \"Zero\",\n",
458 "\thorizon=3, same_day=FALSE)"
ff5df8e3
BA
459 ]
460 },
461 {
462 "cell_type": "code",
463 "execution_count": null,
5e838b3e
BA
464 "metadata": {
465 "collapsed": false,
466 "deletable": true,
467 "editable": true
468 },
ff5df8e3
BA
469 "outputs": [],
470 "source": [
55639673
BA
471 "e_nn_exo = computeError(data, p_nn_exo, 3)\n",
472 "e_nn_mix = computeError(data, p_nn_mix, 3)\n",
473 "e_az = computeError(data, p_az, 3)\n",
474 "e_pz = computeError(data, p_pz, 3)\n",
ff5df8e3
BA
475 "options(repr.plot.width=9, repr.plot.height=7)\n",
476 "plotError(list(e_nn_mix, e_pz, e_az, e_nn_exo), cols=c(1,2,colors()[258], 4))\n",
477 "\n",
478 "# Noir: neighbors_mix, bleu: neighbors_exo, vert: moyenne, rouge: persistence\n",
479 "\n",
480 "i_np = which.min(e_nn_exo$abs$indices)\n",
481 "i_p = which.max(e_nn_exo$abs$indices)"
482 ]
483 },
484 {
485 "cell_type": "code",
486 "execution_count": null,
5e838b3e
BA
487 "metadata": {
488 "collapsed": false,
489 "deletable": true,
490 "editable": true
491 },
ff5df8e3
BA
492 "outputs": [],
493 "source": [
494 "options(repr.plot.width=9, repr.plot.height=4)\n",
495 "par(mfrow=c(1,2))\n",
496 "\n",
497 "plotPredReal(data, p_nn_exo, i_np); title(paste(\"PredReal nn exo day\",i_np))\n",
498 "plotPredReal(data, p_nn_exo, i_p); title(paste(\"PredReal nn exo day\",i_p))\n",
499 "\n",
500 "plotPredReal(data, p_nn_mix, i_np); title(paste(\"PredReal nn mix day\",i_np))\n",
501 "plotPredReal(data, p_nn_mix, i_p); title(paste(\"PredReal nn mix day\",i_p))\n",
502 "\n",
503 "plotPredReal(data, p_az, i_np); title(paste(\"PredReal az day\",i_np))\n",
504 "plotPredReal(data, p_az, i_p); title(paste(\"PredReal az day\",i_p))\n",
505 "\n",
506 "# Bleu: prévue, noir: réalisée"
507 ]
508 },
509 {
510 "cell_type": "code",
511 "execution_count": null,
5e838b3e
BA
512 "metadata": {
513 "collapsed": false,
514 "deletable": true,
515 "editable": true
516 },
ff5df8e3
BA
517 "outputs": [],
518 "source": [
519 "par(mfrow=c(1,2))\n",
520 "f_np_exo = computeFilaments(data, p_nn_exo, i_np, plot=TRUE); title(paste(\"Filaments nn exo day\",i_np))\n",
521 "f_p_exo = computeFilaments(data, p_nn_exo, i_p, plot=TRUE); title(paste(\"Filaments nn exo day\",i_p))\n",
522 "\n",
523 "f_np_mix = computeFilaments(data, p_nn_mix, i_np, plot=TRUE); title(paste(\"Filaments nn mix day\",i_np))\n",
524 "f_p_mix = computeFilaments(data, p_nn_mix, i_p, plot=TRUE); title(paste(\"Filaments nn mix day\",i_p))"
525 ]
526 },
527 {
528 "cell_type": "code",
529 "execution_count": null,
5e838b3e
BA
530 "metadata": {
531 "collapsed": false,
532 "deletable": true,
533 "editable": true
534 },
ff5df8e3
BA
535 "outputs": [],
536 "source": [
537 "par(mfrow=c(1,2))\n",
538 "plotFilamentsBox(data, f_np_exo); title(paste(\"FilBox nn exo day\",i_np))\n",
539 "plotFilamentsBox(data, f_p_exo); title(paste(\"FilBox nn exo day\",i_p))\n",
540 "\n",
541 "plotFilamentsBox(data, f_np_mix); title(paste(\"FilBox nn mix day\",i_np))\n",
542 "plotFilamentsBox(data, f_p_mix); title(paste(\"FilBox nn mix day\",i_p))"
543 ]
544 },
545 {
546 "cell_type": "code",
547 "execution_count": null,
5e838b3e
BA
548 "metadata": {
549 "collapsed": false,
550 "deletable": true,
551 "editable": true
552 },
ff5df8e3
BA
553 "outputs": [],
554 "source": [
555 "par(mfrow=c(1,2))\n",
556 "plotRelVar(data, f_np_exo); title(paste(\"StdDev nn exo day\",i_np))\n",
557 "plotRelVar(data, f_p_exo); title(paste(\"StdDev nn exo day\",i_p))\n",
558 "\n",
559 "plotRelVar(data, f_np_mix); title(paste(\"StdDev nn mix day\",i_np))\n",
560 "plotRelVar(data, f_p_mix); title(paste(\"StdDev nn mix day\",i_p))\n",
561 "\n",
562 "# Variabilité globale en rouge ; sur les 60 voisins (+ lendemains) en noir"
563 ]
564 },
565 {
566 "cell_type": "code",
567 "execution_count": null,
5e838b3e
BA
568 "metadata": {
569 "collapsed": false,
570 "deletable": true,
571 "editable": true
572 },
ff5df8e3
BA
573 "outputs": [],
574 "source": [
575 "par(mfrow=c(1,2))\n",
576 "plotSimils(p_nn_exo, i_np); title(paste(\"Weights nn exo day\",i_np))\n",
577 "plotSimils(p_nn_exo, i_p); title(paste(\"Weights nn exo day\",i_p))\n",
578 "\n",
579 "plotSimils(p_nn_mix, i_np); title(paste(\"Weights nn mix day\",i_np))\n",
d4841a3f 580 "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p))\n",
ff5df8e3
BA
581 "\n",
582 "# - pollué à gauche, + pollué à droite"
583 ]
584 },
585 {
586 "cell_type": "code",
587 "execution_count": null,
5e838b3e
BA
588 "metadata": {
589 "collapsed": false,
590 "deletable": true,
591 "editable": true
592 },
ff5df8e3
BA
593 "outputs": [],
594 "source": [
595 "# Fenêtres sélectionnées dans ]0,10] / endo à gauche, exo à droite\n",
596 "p_nn_exo$getParams(i_np)$window\n",
597 "p_nn_exo$getParams(i_p)$window\n",
598 "\n",
599 "p_nn_mix$getParams(i_np)$window\n",
600 "p_nn_mix$getParams(i_p)$window"
601 ]
602 },
603 {
604 "cell_type": "markdown",
5e838b3e
BA
605 "metadata": {
606 "deletable": true,
607 "editable": true
608 },
ff5df8e3
BA
609 "source": [
610 "\n",
611 "\n",
612 "<h2>Bilan</h2>\n",
613 "\n",
614 "Problème difficile : on ne fait guère mieux qu'une naïve moyenne des lendemains des jours\n",
615 "similaires dans le passé, ce qui n'est pas loin de prédire une série constante égale à la\n",
616 "dernière valeur observée (méthode \"zéro\"). La persistence donne parfois de bons résultats\n",
617 "mais est trop instable (sensibilité à l'argument <code>same_day</code>).\n",
618 "\n",
619 "Comment améliorer la méthode ?"
620 ]
621 }
622 ],
623 "metadata": {
624 "kernelspec": {
625 "display_name": "R",
626 "language": "R",
627 "name": "ir"
628 },
629 "language_info": {
630 "codemirror_mode": "r",
631 "file_extension": ".r",
632 "mimetype": "text/x-r-source",
633 "name": "R",
634 "pygments_lexer": "r",
635 "version": "3.3.3"
636 }
637 },
638 "nbformat": 4,
639 "nbformat_minor": 2
640}