fix methods, update report generation
[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",
ee8b1b4e
BA
78 "p3 = computeForecast(data, indices_ch, \"Neighbors\", \"Zero\", horizon=H, simtype=\"mix\")\n",
79 "p4 = computeForecast(data, indices_ch, \"Neighbors\", \"Neighbors\", horizon=H, simtype=\"mix\")\n",
80 "#p4 = computeForecast(data, indices_ch, \"Neighbors2\", \"Zero\", horizon=H, simtype=\"exo\")\n",
81 "#p5 = computeForecast(data, indices_ch, \"Neighbors2\", \"Zero\", horizon=H, simtype=\"endo\")\n",
82 "#p6 = computeForecast(data, indices_ch, \"Neighbors2\", \"Zero\", horizon=H, simtype=\"mix\")"
a866acb3
BA
83 ]
84 },
85 {
86 "cell_type": "code",
87 "execution_count": null,
88 "metadata": {
ee8b1b4e
BA
89 "collapsed": false,
90 "deletable": true,
91 "editable": true
a866acb3
BA
92 },
93 "outputs": [],
94 "source": [
95 "getSimilarDaysIndices(1000,10,TRUE,data)"
96 ]
97 },
98 {
99 "cell_type": "code",
100 "execution_count": null,
101 "metadata": {
ee8b1b4e
BA
102 "collapsed": false,
103 "deletable": true,
104 "editable": true
a866acb3
BA
105 },
106 "outputs": [],
107 "source": [
108 "as.POSIXlt(data$getTime(1000)[1])"
5e838b3e
BA
109 ]
110 },
111 {
112 "cell_type": "code",
113 "execution_count": null,
114 "metadata": {
ee8b1b4e
BA
115 "collapsed": false,
116 "deletable": true,
117 "editable": true
5e838b3e
BA
118 },
119 "outputs": [],
120 "source": [
ee8b1b4e
BA
121 "#e1 = computeError(data, p1, H)\n",
122 "#e2 = computeError(data, p2, H)\n",
5e838b3e
BA
123 "e3 = computeError(data, p3, H)\n",
124 "e4 = computeError(data, p4, H)\n",
ee8b1b4e
BA
125 "#e5 = computeError(data, p5, H)\n",
126 "#e6 = computeError(data, p6, H)\n",
127 "plotError(list(e3,e4), cols=c(1,2))"
ff5df8e3
BA
128 ]
129 },
130 {
131 "cell_type": "code",
132 "execution_count": null,
5e838b3e
BA
133 "metadata": {
134 "collapsed": false,
135 "deletable": true,
136 "editable": true
137 },
ff5df8e3
BA
138 "outputs": [],
139 "source": [
ee8b1b4e
BA
140 "\tfirst_day = 1\n",
141 "params=p3$getParams(3)\n",
142 "\tfilter = (params$indices >= first_day)\n",
143 "\tindices = params$indices[filter]\n",
144 "\tweights = params$weights[filter]\n",
145 "\n",
146 "\n",
147 "\tgaps = sapply(indices, function(i) {\n",
148 "\t\tdata$getSerie(i+1)[1] - tail(data$getSerie(i), 1)\n",
149 "\t})\n",
150 "\tscal_product = weights * gaps\n",
151 "\tnorm_fact = sum( weights[!is.na(scal_product)] )\n",
152 "\tsum(scal_product, na.rm=TRUE) / norm_fact\n"
153 ]
154 },
155 {
156 "cell_type": "code",
157 "execution_count": null,
158 "metadata": {
159 "collapsed": false
160 },
161 "outputs": [],
162 "source": [
163 "hist(weights)"
ff5df8e3
BA
164 ]
165 },
166 {
167 "cell_type": "code",
168 "execution_count": null,
5e838b3e
BA
169 "metadata": {
170 "collapsed": false,
171 "deletable": true,
172 "editable": true
173 },
ff5df8e3
BA
174 "outputs": [],
175 "source": [
176 "options(repr.plot.width=9, repr.plot.height=4)\n",
177 "par(mfrow=c(1,2))\n",
178 "\n",
ee8b1b4e
BA
179 "plotPredReal(data, p3, 3); title(paste(\"PredReal nn exo day\",3))\n",
180 "plotPredReal(data, p3, 5); title(paste(\"PredReal nn exo day\",5))\n",
ff5df8e3 181 "\n",
ee8b1b4e
BA
182 "plotPredReal(data, p4, 3); title(paste(\"PredReal nn mix day\",3))\n",
183 "plotPredReal(data, p4, 5); title(paste(\"PredReal nn mix day\",5))\n",
ff5df8e3
BA
184 "\n",
185 "# Bleu: prévue, noir: réalisée"
186 ]
187 },
188 {
189 "cell_type": "code",
190 "execution_count": null,
5e838b3e
BA
191 "metadata": {
192 "collapsed": false,
193 "deletable": true,
194 "editable": true
195 },
ff5df8e3
BA
196 "outputs": [],
197 "source": [
198 "par(mfrow=c(1,2))\n",
199 "f_np_exo = computeFilaments(data, p_nn_exo, i_np, plot=TRUE); title(paste(\"Filaments nn exo day\",i_np))\n",
200 "f_p_exo = computeFilaments(data, p_nn_exo, i_p, plot=TRUE); title(paste(\"Filaments nn exo day\",i_p))\n",
201 "\n",
202 "f_np_mix = computeFilaments(data, p_nn_mix, i_np, plot=TRUE); title(paste(\"Filaments nn mix day\",i_np))\n",
203 "f_p_mix = computeFilaments(data, p_nn_mix, i_p, plot=TRUE); title(paste(\"Filaments nn mix day\",i_p))"
204 ]
205 },
206 {
207 "cell_type": "code",
208 "execution_count": null,
5e838b3e
BA
209 "metadata": {
210 "collapsed": false,
211 "deletable": true,
212 "editable": true
213 },
ff5df8e3
BA
214 "outputs": [],
215 "source": [
216 "par(mfrow=c(1,2))\n",
217 "plotFilamentsBox(data, f_np_exo); title(paste(\"FilBox nn exo day\",i_np))\n",
218 "plotFilamentsBox(data, f_p_exo); title(paste(\"FilBox nn exo day\",i_p))\n",
219 "\n",
220 "plotFilamentsBox(data, f_np_mix); title(paste(\"FilBox nn mix day\",i_np))\n",
221 "plotFilamentsBox(data, f_p_mix); title(paste(\"FilBox nn mix day\",i_p))"
222 ]
223 },
224 {
225 "cell_type": "code",
226 "execution_count": null,
5e838b3e
BA
227 "metadata": {
228 "collapsed": false,
229 "deletable": true,
230 "editable": true
231 },
ff5df8e3
BA
232 "outputs": [],
233 "source": [
234 "par(mfrow=c(1,2))\n",
235 "plotRelVar(data, f_np_exo); title(paste(\"StdDev nn exo day\",i_np))\n",
236 "plotRelVar(data, f_p_exo); title(paste(\"StdDev nn exo day\",i_p))\n",
237 "\n",
238 "plotRelVar(data, f_np_mix); title(paste(\"StdDev nn mix day\",i_np))\n",
239 "plotRelVar(data, f_p_mix); title(paste(\"StdDev nn mix day\",i_p))\n",
240 "\n",
241 "# Variabilité globale en rouge ; sur les 60 voisins (+ lendemains) en noir"
242 ]
243 },
244 {
245 "cell_type": "code",
246 "execution_count": null,
5e838b3e
BA
247 "metadata": {
248 "collapsed": false,
249 "deletable": true,
250 "editable": true
251 },
ff5df8e3
BA
252 "outputs": [],
253 "source": [
254 "par(mfrow=c(1,2))\n",
255 "plotSimils(p_nn_exo, i_np); title(paste(\"Weights nn exo day\",i_np))\n",
256 "plotSimils(p_nn_exo, i_p); title(paste(\"Weights nn exo day\",i_p))\n",
257 "\n",
258 "plotSimils(p_nn_mix, i_np); title(paste(\"Weights nn mix day\",i_np))\n",
d4841a3f 259 "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p))\n",
ff5df8e3
BA
260 "\n",
261 "# - pollué à gauche, + pollué à droite"
262 ]
263 },
264 {
265 "cell_type": "code",
266 "execution_count": null,
5e838b3e
BA
267 "metadata": {
268 "collapsed": false,
269 "deletable": true,
270 "editable": true
271 },
ff5df8e3
BA
272 "outputs": [],
273 "source": [
274 "# Fenêtres sélectionnées dans ]0,10] / endo à gauche, exo à droite\n",
275 "p_nn_exo$getParams(i_np)$window\n",
276 "p_nn_exo$getParams(i_p)$window\n",
277 "\n",
278 "p_nn_mix$getParams(i_np)$window\n",
279 "p_nn_mix$getParams(i_p)$window"
280 ]
281 },
282 {
283 "cell_type": "markdown",
5e838b3e
BA
284 "metadata": {
285 "deletable": true,
286 "editable": true
287 },
ff5df8e3
BA
288 "source": [
289 "\n",
290 "\n",
291 "<h2 style=\"color:blue;font-size:2em\">Pollution par épandage</h2>"
292 ]
293 },
294 {
295 "cell_type": "code",
296 "execution_count": null,
5e838b3e
BA
297 "metadata": {
298 "collapsed": false,
299 "deletable": true,
300 "editable": true
301 },
ff5df8e3
BA
302 "outputs": [],
303 "source": [
55639673
BA
304 "p_nn_exo = computeForecast(data, indices_ep, \"Neighbors\", \"Neighbors\",\n",
305 "\thorizon=3, simtype=\"exo\")\n",
306 "p_nn_mix = computeForecast(data, indices_ep, \"Neighbors\", \"Neighbors\",\n",
307 "\thorizon=3, simtype=\"mix\")\n",
308 "p_az = computeForecast(data, indices_ep, \"Average\", \"Zero\",\n",
309 "\thorizon=3)\n",
310 "p_pz = computeForecast(data, indices_ep, \"Persistence\", \"Zero\",\n",
311 "\thorizon=3, same_day=TRUE)"
ff5df8e3
BA
312 ]
313 },
314 {
315 "cell_type": "code",
316 "execution_count": null,
5e838b3e
BA
317 "metadata": {
318 "collapsed": false,
319 "deletable": true,
320 "editable": true
321 },
ff5df8e3
BA
322 "outputs": [],
323 "source": [
55639673
BA
324 "e_nn_exo = computeError(data, p_nn_exo, 3)\n",
325 "e_nn_mix = computeError(data, p_nn_mix, 3)\n",
326 "e_az = computeError(data, p_az, 3)\n",
327 "e_pz = computeError(data, p_pz, 3)\n",
ff5df8e3
BA
328 "options(repr.plot.width=9, repr.plot.height=7)\n",
329 "plotError(list(e_nn_mix, e_pz, e_az, e_nn_exo), cols=c(1,2,colors()[258], 4))\n",
330 "\n",
331 "# Noir: neighbors_mix, bleu: neighbors_exo, vert: moyenne, rouge: persistence\n",
332 "\n",
333 "i_np = which.min(e_nn_exo$abs$indices)\n",
334 "i_p = which.max(e_nn_exo$abs$indices)"
335 ]
336 },
337 {
338 "cell_type": "code",
339 "execution_count": null,
5e838b3e
BA
340 "metadata": {
341 "collapsed": false,
342 "deletable": true,
343 "editable": true
344 },
ff5df8e3
BA
345 "outputs": [],
346 "source": [
347 "options(repr.plot.width=9, repr.plot.height=4)\n",
348 "par(mfrow=c(1,2))\n",
349 "\n",
350 "plotPredReal(data, p_nn_exo, i_np); title(paste(\"PredReal nn exo day\",i_np))\n",
351 "plotPredReal(data, p_nn_exo, i_p); title(paste(\"PredReal nn exo day\",i_p))\n",
352 "\n",
353 "plotPredReal(data, p_nn_mix, i_np); title(paste(\"PredReal nn mix day\",i_np))\n",
354 "plotPredReal(data, p_nn_mix, i_p); title(paste(\"PredReal nn mix day\",i_p))\n",
355 "\n",
356 "plotPredReal(data, p_az, i_np); title(paste(\"PredReal az day\",i_np))\n",
357 "plotPredReal(data, p_az, i_p); title(paste(\"PredReal az day\",i_p))\n",
358 "\n",
359 "# Bleu: prévue, noir: réalisée"
360 ]
361 },
362 {
363 "cell_type": "code",
364 "execution_count": null,
5e838b3e
BA
365 "metadata": {
366 "collapsed": false,
367 "deletable": true,
368 "editable": true
369 },
ff5df8e3
BA
370 "outputs": [],
371 "source": [
372 "par(mfrow=c(1,2))\n",
373 "f_np_exo = computeFilaments(data, p_nn_exo, i_np, plot=TRUE); title(paste(\"Filaments nn exo day\",i_np))\n",
374 "f_p_exo = computeFilaments(data, p_nn_exo, i_p, plot=TRUE); title(paste(\"Filaments nn exo day\",i_p))\n",
375 "\n",
376 "f_np_mix = computeFilaments(data, p_nn_mix, i_np, plot=TRUE); title(paste(\"Filaments nn mix day\",i_np))\n",
377 "f_p_mix = computeFilaments(data, p_nn_mix, i_p, plot=TRUE); title(paste(\"Filaments nn mix day\",i_p))"
378 ]
379 },
380 {
381 "cell_type": "code",
382 "execution_count": null,
5e838b3e
BA
383 "metadata": {
384 "collapsed": false,
385 "deletable": true,
386 "editable": true
387 },
ff5df8e3
BA
388 "outputs": [],
389 "source": [
390 "par(mfrow=c(1,2))\n",
391 "plotFilamentsBox(data, f_np_exo); title(paste(\"FilBox nn exo day\",i_np))\n",
392 "plotFilamentsBox(data, f_p_exo); title(paste(\"FilBox nn exo day\",i_p))\n",
393 "\n",
394 "plotFilamentsBox(data, f_np_mix); title(paste(\"FilBox nn mix day\",i_np))\n",
395 "plotFilamentsBox(data, f_p_mix); title(paste(\"FilBox nn mix day\",i_p))"
396 ]
397 },
398 {
399 "cell_type": "code",
400 "execution_count": null,
5e838b3e
BA
401 "metadata": {
402 "collapsed": false,
403 "deletable": true,
404 "editable": true
405 },
ff5df8e3
BA
406 "outputs": [],
407 "source": [
408 "par(mfrow=c(1,2))\n",
409 "plotRelVar(data, f_np_exo); title(paste(\"StdDev nn exo day\",i_np))\n",
410 "plotRelVar(data, f_p_exo); title(paste(\"StdDev nn exo day\",i_p))\n",
411 "\n",
412 "plotRelVar(data, f_np_mix); title(paste(\"StdDev nn mix day\",i_np))\n",
413 "plotRelVar(data, f_p_mix); title(paste(\"StdDev nn mix day\",i_p))\n",
414 "\n",
415 "# Variabilité globale en rouge ; sur les 60 voisins (+ lendemains) en noir"
416 ]
417 },
418 {
419 "cell_type": "code",
420 "execution_count": null,
5e838b3e
BA
421 "metadata": {
422 "collapsed": false,
423 "deletable": true,
424 "editable": true
425 },
ff5df8e3
BA
426 "outputs": [],
427 "source": [
428 "par(mfrow=c(1,2))\n",
429 "plotSimils(p_nn_exo, i_np); title(paste(\"Weights nn exo day\",i_np))\n",
430 "plotSimils(p_nn_exo, i_p); title(paste(\"Weights nn exo day\",i_p))\n",
431 "\n",
432 "plotSimils(p_nn_mix, i_np); title(paste(\"Weights nn mix day\",i_np))\n",
d4841a3f 433 "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p))\n",
ff5df8e3
BA
434 "\n",
435 "# - pollué à gauche, + pollué à droite"
436 ]
437 },
438 {
439 "cell_type": "code",
440 "execution_count": null,
5e838b3e
BA
441 "metadata": {
442 "collapsed": false,
443 "deletable": true,
444 "editable": true
445 },
ff5df8e3
BA
446 "outputs": [],
447 "source": [
448 "# Fenêtres sélectionnées dans ]0,10] / endo à gauche, exo à droite\n",
449 "p_nn_exo$getParams(i_np)$window\n",
450 "p_nn_exo$getParams(i_p)$window\n",
451 "\n",
452 "p_nn_mix$getParams(i_np)$window\n",
453 "p_nn_mix$getParams(i_p)$window"
454 ]
455 },
456 {
457 "cell_type": "markdown",
5e838b3e
BA
458 "metadata": {
459 "deletable": true,
460 "editable": true
461 },
ff5df8e3
BA
462 "source": [
463 "\n",
464 "\n",
465 "<h2 style=\"color:blue;font-size:2em\">Semaine non polluée</h2>"
466 ]
467 },
468 {
469 "cell_type": "code",
470 "execution_count": null,
5e838b3e
BA
471 "metadata": {
472 "collapsed": false,
473 "deletable": true,
474 "editable": true
475 },
ff5df8e3
BA
476 "outputs": [],
477 "source": [
55639673
BA
478 "p_nn_exo = computeForecast(data, indices_np, \"Neighbors\", \"Neighbors\",\n",
479 "\thorizon=3, simtype=\"exo\")\n",
480 "p_nn_mix = computeForecast(data, indices_np, \"Neighbors\", \"Neighbors\",\n",
481 "\thorizon=3, simtype=\"mix\")\n",
482 "p_az = computeForecast(data, indices_np, \"Average\", \"Zero\",\n",
483 "\thorizon=3)\n",
484 "p_pz = computeForecast(data, indices_np, \"Persistence\", \"Zero\",\n",
485 "\thorizon=3, same_day=FALSE)"
ff5df8e3
BA
486 ]
487 },
488 {
489 "cell_type": "code",
490 "execution_count": null,
5e838b3e
BA
491 "metadata": {
492 "collapsed": false,
493 "deletable": true,
494 "editable": true
495 },
ff5df8e3
BA
496 "outputs": [],
497 "source": [
55639673
BA
498 "e_nn_exo = computeError(data, p_nn_exo, 3)\n",
499 "e_nn_mix = computeError(data, p_nn_mix, 3)\n",
500 "e_az = computeError(data, p_az, 3)\n",
501 "e_pz = computeError(data, p_pz, 3)\n",
ff5df8e3
BA
502 "options(repr.plot.width=9, repr.plot.height=7)\n",
503 "plotError(list(e_nn_mix, e_pz, e_az, e_nn_exo), cols=c(1,2,colors()[258], 4))\n",
504 "\n",
505 "# Noir: neighbors_mix, bleu: neighbors_exo, vert: moyenne, rouge: persistence\n",
506 "\n",
507 "i_np = which.min(e_nn_exo$abs$indices)\n",
508 "i_p = which.max(e_nn_exo$abs$indices)"
509 ]
510 },
511 {
512 "cell_type": "code",
513 "execution_count": null,
5e838b3e
BA
514 "metadata": {
515 "collapsed": false,
516 "deletable": true,
517 "editable": true
518 },
ff5df8e3
BA
519 "outputs": [],
520 "source": [
521 "options(repr.plot.width=9, repr.plot.height=4)\n",
522 "par(mfrow=c(1,2))\n",
523 "\n",
524 "plotPredReal(data, p_nn_exo, i_np); title(paste(\"PredReal nn exo day\",i_np))\n",
525 "plotPredReal(data, p_nn_exo, i_p); title(paste(\"PredReal nn exo day\",i_p))\n",
526 "\n",
527 "plotPredReal(data, p_nn_mix, i_np); title(paste(\"PredReal nn mix day\",i_np))\n",
528 "plotPredReal(data, p_nn_mix, i_p); title(paste(\"PredReal nn mix day\",i_p))\n",
529 "\n",
530 "plotPredReal(data, p_az, i_np); title(paste(\"PredReal az day\",i_np))\n",
531 "plotPredReal(data, p_az, i_p); title(paste(\"PredReal az day\",i_p))\n",
532 "\n",
533 "# Bleu: prévue, noir: réalisée"
534 ]
535 },
536 {
537 "cell_type": "code",
538 "execution_count": null,
5e838b3e
BA
539 "metadata": {
540 "collapsed": false,
541 "deletable": true,
542 "editable": true
543 },
ff5df8e3
BA
544 "outputs": [],
545 "source": [
546 "par(mfrow=c(1,2))\n",
547 "f_np_exo = computeFilaments(data, p_nn_exo, i_np, plot=TRUE); title(paste(\"Filaments nn exo day\",i_np))\n",
548 "f_p_exo = computeFilaments(data, p_nn_exo, i_p, plot=TRUE); title(paste(\"Filaments nn exo day\",i_p))\n",
549 "\n",
550 "f_np_mix = computeFilaments(data, p_nn_mix, i_np, plot=TRUE); title(paste(\"Filaments nn mix day\",i_np))\n",
551 "f_p_mix = computeFilaments(data, p_nn_mix, i_p, plot=TRUE); title(paste(\"Filaments nn mix day\",i_p))"
552 ]
553 },
554 {
555 "cell_type": "code",
556 "execution_count": null,
5e838b3e
BA
557 "metadata": {
558 "collapsed": false,
559 "deletable": true,
560 "editable": true
561 },
ff5df8e3
BA
562 "outputs": [],
563 "source": [
564 "par(mfrow=c(1,2))\n",
565 "plotFilamentsBox(data, f_np_exo); title(paste(\"FilBox nn exo day\",i_np))\n",
566 "plotFilamentsBox(data, f_p_exo); title(paste(\"FilBox nn exo day\",i_p))\n",
567 "\n",
568 "plotFilamentsBox(data, f_np_mix); title(paste(\"FilBox nn mix day\",i_np))\n",
569 "plotFilamentsBox(data, f_p_mix); title(paste(\"FilBox nn mix day\",i_p))"
570 ]
571 },
572 {
573 "cell_type": "code",
574 "execution_count": null,
5e838b3e
BA
575 "metadata": {
576 "collapsed": false,
577 "deletable": true,
578 "editable": true
579 },
ff5df8e3
BA
580 "outputs": [],
581 "source": [
582 "par(mfrow=c(1,2))\n",
583 "plotRelVar(data, f_np_exo); title(paste(\"StdDev nn exo day\",i_np))\n",
584 "plotRelVar(data, f_p_exo); title(paste(\"StdDev nn exo day\",i_p))\n",
585 "\n",
586 "plotRelVar(data, f_np_mix); title(paste(\"StdDev nn mix day\",i_np))\n",
587 "plotRelVar(data, f_p_mix); title(paste(\"StdDev nn mix day\",i_p))\n",
588 "\n",
589 "# Variabilité globale en rouge ; sur les 60 voisins (+ lendemains) en noir"
590 ]
591 },
592 {
593 "cell_type": "code",
594 "execution_count": null,
5e838b3e
BA
595 "metadata": {
596 "collapsed": false,
597 "deletable": true,
598 "editable": true
599 },
ff5df8e3
BA
600 "outputs": [],
601 "source": [
602 "par(mfrow=c(1,2))\n",
603 "plotSimils(p_nn_exo, i_np); title(paste(\"Weights nn exo day\",i_np))\n",
604 "plotSimils(p_nn_exo, i_p); title(paste(\"Weights nn exo day\",i_p))\n",
605 "\n",
606 "plotSimils(p_nn_mix, i_np); title(paste(\"Weights nn mix day\",i_np))\n",
d4841a3f 607 "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p))\n",
ff5df8e3
BA
608 "\n",
609 "# - pollué à gauche, + pollué à droite"
610 ]
611 },
612 {
613 "cell_type": "code",
614 "execution_count": null,
5e838b3e
BA
615 "metadata": {
616 "collapsed": false,
617 "deletable": true,
618 "editable": true
619 },
ff5df8e3
BA
620 "outputs": [],
621 "source": [
622 "# Fenêtres sélectionnées dans ]0,10] / endo à gauche, exo à droite\n",
623 "p_nn_exo$getParams(i_np)$window\n",
624 "p_nn_exo$getParams(i_p)$window\n",
625 "\n",
626 "p_nn_mix$getParams(i_np)$window\n",
627 "p_nn_mix$getParams(i_p)$window"
628 ]
629 },
630 {
631 "cell_type": "markdown",
5e838b3e
BA
632 "metadata": {
633 "deletable": true,
634 "editable": true
635 },
ff5df8e3
BA
636 "source": [
637 "\n",
638 "\n",
639 "<h2>Bilan</h2>\n",
640 "\n",
641 "Problème difficile : on ne fait guère mieux qu'une naïve moyenne des lendemains des jours\n",
642 "similaires dans le passé, ce qui n'est pas loin de prédire une série constante égale à la\n",
643 "dernière valeur observée (méthode \"zéro\"). La persistence donne parfois de bons résultats\n",
644 "mais est trop instable (sensibilité à l'argument <code>same_day</code>).\n",
645 "\n",
646 "Comment améliorer la méthode ?"
647 ]
648 }
649 ],
650 "metadata": {
651 "kernelspec": {
652 "display_name": "R",
653 "language": "R",
654 "name": "ir"
655 },
656 "language_info": {
657 "codemirror_mode": "r",
658 "file_extension": ".r",
659 "mimetype": "text/x-r-source",
660 "name": "R",
661 "pygments_lexer": "r",
662 "version": "3.3.3"
663 }
664 },
665 "nbformat": 4,
666 "nbformat_minor": 2
667}