From: Benjamin Auder Date: Thu, 16 Mar 2017 17:40:48 +0000 (+0100) Subject: a few adjustments: TODO: bash script to re-reun reports X-Git-Url: https://git.auder.net/doc/html/pieces/%7B%7B%20targetUrl%20%7D%7D?a=commitdiff_plain;h=d4841a3f15f94ce0520559aed9466c9c3f259d68;p=talweg.git a few adjustments: TODO: bash script to re-reun reports --- diff --git a/pkg/R/plot.R b/pkg/R/plot.R index eb0c81a..4cafd7d 100644 --- a/pkg/R/plot.R +++ b/pkg/R/plot.R @@ -107,7 +107,7 @@ plotSimils <- function(pred, index) if (is.null(weights)) stop("plotSimils only works on 'Neighbors' forecasts") par(mar=c(4.7,5,1,1), cex.axis=1.5, cex.lab=1.5) - hist(pred$getParams(index)$weights, nclass=20, xlab="Poids", ylab="Effectif") + hist(pred$getParams(index)$weights, nclass=20, main="", xlab="Poids", ylab="Effectif") } #' Functional boxplot diff --git a/reports/report.Rmd b/reports/report.Rmd deleted file mode 100644 index b6e94cb..0000000 --- a/reports/report.Rmd +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: "talweg" -author: "Benjamin Auder" -date: "`r Sys.Date()`" -output: rmarkdown::html_vignette -vignette: > - %\VignetteIndexEntry{Vignette Title} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - - -## Introduction - -J'ai fait quelques essais dans différentes configurations pour la méthode "Neighbors" (la seule dont on a parlé).
Il semble que le mieux soit - - * simtype="exo" ou "mix" : similarités exogènes avec/sans endogènes (fenêtre optimisée par VC) - * same_season=FALSE : les indices pour la validation croisée ne tiennent pas compte des saisons - * mix_strategy="mult" : on multiplie les poids (au lieu d'en éteindre) - -J'ai systématiquement comparé à une approche naïve : la moyennes des lendemains des jours "similaires" dans tout le passé ; à chaque fois sans prédiction du saut (sauf pour Neighbors : prédiction basée sur les poids calculés). - -Ensuite j'affiche les erreurs, quelques courbes prévues/mesurées, quelques filaments puis les histogrammes de quelques poids. Concernant les graphes de filaments, la moitié gauche du graphe correspond aux jours similaires au jour courant, tandis que la moitié droite affiche les lendemains : ce sont donc les voisinages tels qu'utilisés dans l'algorithme. - -

Pollution par chauffage

- - -loop: indices_ch, ep, np et titres: Pollution par chauffage, Pollution par épandage, Semaine non polluée - - - -p_nn_exo = computeForecast(data, indices_ch, "Neighbors", "Neighbors", simtype="exo", horizon=H) -p_nn_mix = computeForecast(data, indices_ch, "Neighbors", "Neighbors", simtype="mix", horizon=H) -p_az = computeForecast(data, indices_ch, "Average", "Zero", horizon=H) #, memory=183) -p_pz = computeForecast(data, indices_ch, "Persistence", "Zero", horizon=H, same_day=TRUE) - -e_nn_exo = computeError(data, p_nn_exo) -e_nn_mix = computeError(data, p_nn_mix) -e_az = computeError(data, p_az) -e_pz = computeError(data, p_pz) -options(repr.plot.width=9, repr.plot.height=7) -plotError(list(e_nn_mix, e_pz, e_az, e_nn_exo), cols=c(1,2,colors()[258], 4)) - -#Noir: neighbors_mix, bleu: neighbors_exo, vert: moyenne, rouge: persistence - -i_np = which.min(e_nn_exo$abs$indices) -i_p = which.max(e_nn_exo$abs$indices) - -options(repr.plot.width=9, repr.plot.height=4) -par(mfrow=c(1,2)) - -plotPredReal(data, p_nn_exo, i_np); title(paste("PredReal nn exo day",i_np)) -plotPredReal(data, p_nn_exo, i_p); title(paste("PredReal nn exo day",i_p)) - -plotPredReal(data, p_nn_mix, i_np); title(paste("PredReal nn mix day",i_np)) -plotPredReal(data, p_nn_mix, i_p); title(paste("PredReal nn mix day",i_p)) - -plotPredReal(data, p_az, i_np); title(paste("PredReal az day",i_np)) -plotPredReal(data, p_az, i_p); title(paste("PredReal az day",i_p)) - -#Bleu: prévue, noir: réalisée - -par(mfrow=c(1,2)) -f_np_exo = computeFilaments(data, p_nn_exo, i_np, plot=TRUE); title(paste("Filaments nn exo day",i_np)) -f_p_exo = computeFilaments(data, p_nn_exo, i_p, plot=TRUE); title(paste("Filaments nn exo day",i_p)) - -f_np_mix = computeFilaments(data, p_nn_mix, i_np, plot=TRUE); title(paste("Filaments nn mix day",i_np)) -f_p_mix = computeFilaments(data, p_nn_mix, i_p, plot=TRUE); title(paste("Filaments nn mix day",i_p)) - -par(mfrow=c(1,2)) -plotFilamentsBox(data, f_np_exo); title(paste("FilBox nn exo day",i_np)) -plotFilamentsBox(data, f_p_exo); title(paste("FilBox nn exo day",i_p)) - -plotFilamentsBox(data, f_np_mix); title(paste("FilBox nn mix day",i_np)) -plotFilamentsBox(data, f_p_mix); title(paste("FilBox nn mix day",i_p)) - -par(mfrow=c(1,2)) -plotRelVar(data, f_np_exo); title(paste("StdDev nn exo day",i_np)) -plotRelVar(data, f_p_exo); title(paste("StdDev nn exo day",i_p)) - -plotRelVar(data, f_np_mix); title(paste("StdDev nn mix day",i_np)) -plotRelVar(data, f_p_mix); title(paste("StdDev nn mix day",i_p)) - -#Variabilité globale en rouge ; sur les 60 voisins (+ lendemains) en noir - -par(mfrow=c(1,2)) -plotSimils(p_nn_exo, i_np); title(paste("Weights nn exo day",i_np)) -plotSimils(p_nn_exo, i_p); title(paste("Weights nn exo day",i_p)) - -plotSimils(p_nn_mix, i_np); title(paste("Weights nn mix day",i_np)) -plotSimils(p_nn_mix, i_p); title(paste("Weights nn mix day",i_p) - -#- pollué à gauche, + pollué à droite - -#Fenêtres sélectionnées dans ]0,10] / endo à gauche, exo à droite -p_ch_nn_exo$getParams(i_np)$window -p_ch_nn_exo$getParams(i_p)$window - -p_ch_nn_mix$getParams(i_np)$window -p_ch_nn_mix$getParams(i_p)$window - - - - -## Bilan - -Problème difficile : on ne fait guère mieux qu'une naïve moyenne des lendemains des jours similaires dans le passé, ce qui n'est pas loin de prédire une série constante égale à la dernière valeur observée (méthode "zéro"). La persistence donne parfois de bons résultats mais est trop instable (sensibilité à l'argument same_day). - -Comment améliorer la méthode ? - - - - -Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The `html_vignette` output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The `html_vignette` format: - -- Never uses retina figures -- Has a smaller default figure size -- Uses a custom CSS stylesheet instead of the default Twitter Bootstrap style - -## Vignette Info - -Note the various macros within the `vignette` section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the `title` field and the `\VignetteIndexEntry` to match the title of your vignette. - -## Styles - -The `html_vignette` template includes a basic CSS theme. To override this theme you can specify your own CSS in the document metadata as follows: - - output: - rmarkdown::html_vignette: - css: mystyles.css - -## Figures - -The figure sizes have been customised so that you can easily put two images side-by-side. - -```{r, fig.show='hold'} -plot(1:10) -plot(10:1) -``` - -You can enable figure captions by `fig_caption: yes` in YAML: - - output: - rmarkdown::html_vignette: - fig_caption: yes - -Then you can use the chunk option `fig.cap = "Your figure caption."` in **knitr**. - -## More Examples - -You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using `knitr::kable()`. - -```{r, echo=FALSE, results='asis'} -knitr::kable(head(mtcars, 10)) -``` - -Also a quote using `>`: - -> "He who gives up [code] safety for [code] speed deserves neither." -([via](https://twitter.com/hadleywickham/status/504368538874703872)) diff --git a/reports/report.gj b/reports/report.gj index b901075..dc4cbd4 100644 --- a/reports/report.gj +++ b/reports/report.gj @@ -31,6 +31,8 @@ data = getData(ts_data, exo_data, input_tz = "Europe/Paris", working_tz="Europe/ indices_ch = seq(as.Date("2015-01-18"),as.Date("2015-01-24"),"days") indices_ep = seq(as.Date("2015-03-15"),as.Date("2015-03-21"),"days") indices_np = seq(as.Date("2015-04-26"),as.Date("2015-05-02"),"days") + +H = 17 #predict from 8am to 12pm % for i in range(3): -----

${list_titles[i]}

@@ -40,10 +42,10 @@ p_nn_mix = computeForecast(data, ${list_indices[i]}, "Neighbors", "Neighbors", s p_az = computeForecast(data, ${list_indices[i]}, "Average", "Zero", horizon=H) #, memory=183) p_pz = computeForecast(data, ${list_indices[i]}, "Persistence", "Zero", horizon=H, same_day=TRUE) -----r -e_nn_exo = computeError(data, p_nn_exo) -e_nn_mix = computeError(data, p_nn_mix) -e_az = computeError(data, p_az) -e_pz = computeError(data, p_pz) +e_nn_exo = computeError(data, p_nn_exo, H) +e_nn_mix = computeError(data, p_nn_mix, H) +e_az = computeError(data, p_az, H) +e_pz = computeError(data, p_pz, H) options(repr.plot.width=9, repr.plot.height=7) plotError(list(e_nn_mix, e_pz, e_az, e_nn_exo), cols=c(1,2,colors()[258], 4)) @@ -94,7 +96,7 @@ plotSimils(p_nn_exo, i_np); title(paste("Weights nn exo day",i_np)) plotSimils(p_nn_exo, i_p); title(paste("Weights nn exo day",i_p)) plotSimils(p_nn_mix, i_np); title(paste("Weights nn mix day",i_np)) -plotSimils(p_nn_mix, i_p); title(paste("Weights nn mix day",i_p) +plotSimils(p_nn_mix, i_p); title(paste("Weights nn mix day",i_p)) # - pollué à gauche, + pollué à droite -----r diff --git a/reports/report.ipynb b/reports/report.ipynb index 05f51de..bdf1723 100644 --- a/reports/report.ipynb +++ b/reports/report.ipynb @@ -38,11 +38,13 @@ "\n", "ts_data = read.csv(system.file(\"extdata\",\"pm10_mesures_H_loc_report.csv\",package=\"talweg\"))\n", "exo_data = read.csv(system.file(\"extdata\",\"meteo_extra_noNAs.csv\",package=\"talweg\"))\n", - "data = getData(ts_data, exo_data, input_tz = \"Europe/Paris\", working_tz=\"Europe/Paris\", predict_at=13)\n", + "data = getData(ts_data, exo_data, input_tz = \"Europe/Paris\", working_tz=\"Europe/Paris\", predict_at=7)\n", "\n", "indices_ch = seq(as.Date(\"2015-01-18\"),as.Date(\"2015-01-24\"),\"days\")\n", "indices_ep = seq(as.Date(\"2015-03-15\"),as.Date(\"2015-03-21\"),\"days\")\n", - "indices_np = seq(as.Date(\"2015-04-26\"),as.Date(\"2015-05-02\"),\"days\")" + "indices_np = seq(as.Date(\"2015-04-26\"),as.Date(\"2015-05-02\"),\"days\")\n", + "\n", + "H = 3 #predict from 2pm to 4pm" ] }, { @@ -76,10 +78,11 @@ }, "outputs": [], "source": [ - "e_nn_exo = computeError(data, p_nn_exo)\n", - "e_nn_mix = computeError(data, p_nn_mix)\n", - "e_az = computeError(data, p_az)\n", - "e_pz = computeError(data, p_pz)\n", + "e_nn_exo = computeError(data, p_nn_exo, H)\n", + "e_nn_mix = computeError(data, p_nn_mix, H)\n", + "e_az = computeError(data, p_az, H)\n", + "e_pz = computeError(data, p_pz, H)\n", + "\n", "options(repr.plot.width=9, repr.plot.height=7)\n", "plotError(list(e_nn_mix, e_pz, e_az, e_nn_exo), cols=c(1,2,colors()[258], 4))\n", "\n", @@ -175,7 +178,7 @@ "plotSimils(p_nn_exo, i_p); title(paste(\"Weights nn exo day\",i_p))\n", "\n", "plotSimils(p_nn_mix, i_np); title(paste(\"Weights nn mix day\",i_np))\n", - "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p)\n", + "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p))\n", "\n", "# - pollué à gauche, + pollué à droite" ] @@ -227,10 +230,10 @@ }, "outputs": [], "source": [ - "e_nn_exo = computeError(data, p_nn_exo)\n", - "e_nn_mix = computeError(data, p_nn_mix)\n", - "e_az = computeError(data, p_az)\n", - "e_pz = computeError(data, p_pz)\n", + "e_nn_exo = computeError(data, p_nn_exo, H)\n", + "e_nn_mix = computeError(data, p_nn_mix, H)\n", + "e_az = computeError(data, p_az, H)\n", + "e_pz = computeError(data, p_pz, H)\n", "options(repr.plot.width=9, repr.plot.height=7)\n", "plotError(list(e_nn_mix, e_pz, e_az, e_nn_exo), cols=c(1,2,colors()[258], 4))\n", "\n", @@ -326,7 +329,7 @@ "plotSimils(p_nn_exo, i_p); title(paste(\"Weights nn exo day\",i_p))\n", "\n", "plotSimils(p_nn_mix, i_np); title(paste(\"Weights nn mix day\",i_np))\n", - "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p)\n", + "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p))\n", "\n", "# - pollué à gauche, + pollué à droite" ] @@ -367,7 +370,7 @@ "p_nn_exo = computeForecast(data, indices_np, \"Neighbors\", \"Neighbors\", simtype=\"exo\", horizon=H)\n", "p_nn_mix = computeForecast(data, indices_np, \"Neighbors\", \"Neighbors\", simtype=\"mix\", horizon=H)\n", "p_az = computeForecast(data, indices_np, \"Average\", \"Zero\", horizon=H) #, memory=183)\n", - "p_pz = computeForecast(data, indices_np, \"Persistence\", \"Zero\", horizon=H, same_day=TRUE)" + "p_pz = computeForecast(data, indices_np, \"Persistence\", \"Zero\", horizon=H, same_day=FALSE)" ] }, { @@ -378,10 +381,10 @@ }, "outputs": [], "source": [ - "e_nn_exo = computeError(data, p_nn_exo)\n", - "e_nn_mix = computeError(data, p_nn_mix)\n", - "e_az = computeError(data, p_az)\n", - "e_pz = computeError(data, p_pz)\n", + "e_nn_exo = computeError(data, p_nn_exo, H)\n", + "e_nn_mix = computeError(data, p_nn_mix, H)\n", + "e_az = computeError(data, p_az, H)\n", + "e_pz = computeError(data, p_pz, H)\n", "options(repr.plot.width=9, repr.plot.height=7)\n", "plotError(list(e_nn_mix, e_pz, e_az, e_nn_exo), cols=c(1,2,colors()[258], 4))\n", "\n", @@ -477,7 +480,7 @@ "plotSimils(p_nn_exo, i_p); title(paste(\"Weights nn exo day\",i_p))\n", "\n", "plotSimils(p_nn_mix, i_np); title(paste(\"Weights nn mix day\",i_np))\n", - "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p)\n", + "plotSimils(p_nn_mix, i_p); title(paste(\"Weights nn mix day\",i_p))\n", "\n", "# - pollué à gauche, + pollué à droite" ] diff --git a/reports/report_2017-03-01.13h.ipynb b/reports/report_2017-03-01.13h.ipynb deleted file mode 100644 index c7c6a49..0000000 --- a/reports/report_2017-03-01.13h.ipynb +++ /dev/null @@ -1,486 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "library(talweg)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "ts_data = read.csv(system.file(\"extdata\",\"pm10_mesures_H_loc_report.csv\",package=\"talweg\"))\n", - "exo_data = read.csv(system.file(\"extdata\",\"meteo_extra_noNAs.csv\",package=\"talweg\"))\n", - "data = getData(ts_data, exo_data, input_tz = \"Europe/Paris\", working_tz=\"Europe/Paris\", predict_at=13)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction\n", - "\n", - "J'ai fait quelques essais dans différentes configurations pour la méthode \"Neighbors\" (la seule dont on a parlé).
Il semble que le mieux soit\n", - "\n", - " * simtype=\"mix\" : on utilise les similarités endogènes et exogènes (fenêtre optimisée par VC)\n", - " * same_season=FALSE : les indices pour la validation croisée ne tiennent pas compte des saisons\n", - " * mix_strategy=\"mult\" : on multiplie les poids (au lieu d'en éteindre)\n", - "\n", - "(valeurs par défaut).\n", - "\n", - "J'ai systématiquement comparé à deux autres approches : la persistence et la moyennes des lendemains des jours \"similaires\" dans tout le passé ; à chaque fois sans prédiction du saut (sauf pour Neighbors : prédiction basée sur les poids calculés).\n", - "\n", - "Ensuite j'affiche les erreurs, quelques courbes prévues/mesurées, quelques filaments puis les histogrammes de quelques poids. Concernant les graphes de filaments, la moitié gauche du graphe correspond aux jours similaires au jour courant, tandis que la moitié droite affiche les lendemains : ce sont donc les voisinages tels qu'utilisés dans l'algorithme.\n", - "\n", - "

Pollution par chauffage

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "indices_ch = seq(as.Date(\"2015-01-18\"),as.Date(\"2015-01-24\"),\"days\")\n", - "p_ch_nn = computeForecast(data, indices_ch, \"Neighbors\", \"Neighbors\", simtype=\"mix\")\n", - "p_ch_pz = computeForecast(data, indices_ch, \"Persistence\", \"Zero\", same_day=TRUE)\n", - "p_ch_az = computeForecast(data, indices_ch, \"Average\", \"Zero\") #, memory=183)\n", - "#p_ch_zz = computeForecast(data, indices_ch, \"Zero\", \"Zero\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "e_ch_nn = computeError(data, p_ch_nn)\n", - "e_ch_pz = computeError(data, p_ch_pz)\n", - "e_ch_az = computeError(data, p_ch_az)\n", - "#e_ch_zz = computeError(data, p_ch_zz)\n", - "options(repr.plot.width=9, repr.plot.height=7)\n", - "plotError(list(e_ch_nn, e_ch_pz, e_ch_az), cols=c(1,2,colors()[258]))\n", - "\n", - "#Noir: neighbors, rouge: persistence, vert: moyenne" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "options(repr.plot.width=9, repr.plot.height=4)\n", - "plotPredReal(data, p_ch_nn, 3)\n", - "plotPredReal(data, p_ch_nn, 4)\n", - "\n", - "#Bleu: prévue, noir: réalisée" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotPredReal(data, p_ch_az, 3)\n", - "plotPredReal(data, p_ch_az, 4)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "f3_ch = computeFilaments(data, p_ch_nn$getIndexInData(3), plot=TRUE)\n", - "f4_ch = computeFilaments(data, p_ch_nn$getIndexInData(4), plot=TRUE)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotFilamentsBox(data, f3_ch)\n", - "plotFilamentsBox(data, f4_ch)\n", - "\n", - "#À gauche : jour 3 + lendemain (4) ; à droite : jour 4 + lendemain (5)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotRelVar(data, f3_ch)\n", - "plotRelVar(data, f4_ch)\n", - "\n", - "#Variabilité globale en rouge ; sur nos 60 voisins (+ lendemains) en noir" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotSimils(p_ch_nn, 3)\n", - "plotSimils(p_ch_nn, 4)\n", - "\n", - "#Non pollué à gauche, pollué à droite" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "#Fenêtres sélectionnées dans ]0,10] / endo à gauche, exo à droite\n", - "p_ch_nn$getParams(3)$window\n", - "p_ch_nn$getParams(4)$window" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Pollution par épandage

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "indices_ep = seq(as.Date(\"2015-03-15\"),as.Date(\"2015-03-21\"),\"days\")\n", - "p_ep_nn = computeForecast(data,indices_ep, \"Neighbors\", \"Neighbors\", simtype=\"mix\")\n", - "p_ep_pz = computeForecast(data, indices_ep, \"Persistence\", \"Zero\", same_day=TRUE)\n", - "p_ep_az = computeForecast(data, indices_ep, \"Average\", \"Zero\") #, memory=183)\n", - "#p_ep_zz = computeForecast(data, indices_ep, \"Zero\", \"Zero\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "e_ep_nn = computeError(data, p_ep_nn)\n", - "e_ep_pz = computeError(data, p_ep_pz)\n", - "e_ep_az = computeError(data, p_ep_az)\n", - "#e_ep_zz = computeError(data, p_ep_zz)\n", - "options(repr.plot.width=9, repr.plot.height=7)\n", - "plotError(list(e_ep_nn, e_ep_pz, e_ep_az), cols=c(1,2,colors()[258]))\n", - "\n", - "#Noir: neighbors, rouge: persistence, vert: moyenne" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "options(repr.plot.width=9, repr.plot.height=4)\n", - "plotPredReal(data, p_ep_nn, 6)\n", - "plotPredReal(data, p_ep_nn, 3)\n", - "\n", - "#Bleu: prévue, noir: réalisée" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotPredReal(data, p_ep_az, 6)\n", - "plotPredReal(data, p_ep_az, 3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "f6_ep = computeFilaments(data, p_ep_nn$getIndexInData(6), plot=TRUE)\n", - "f3_ep = computeFilaments(data, p_ep_nn$getIndexInData(3), plot=TRUE)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotFilamentsBox(data, f6_ep)\n", - "plotFilamentsBox(data, f3_ep)\n", - "\n", - "#À gauche : jour 6 + lendemain (7) ; à droite : jour 3 + lendemain (4)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotRelVar(data, f6_ep)\n", - "plotRelVar(data, f3_ep)\n", - "\n", - "#Variabilité globale en rouge ; sur nos 60 voisins (+ lendemains) en noir" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotSimils(p_ep_nn, 6)\n", - "plotSimils(p_ep_nn, 3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "#Fenêtres sélectionnées dans ]0,10] / endo à gauche, exo à droite\n", - "p_ep_nn$getParams(6)$window\n", - "p_ep_nn$getParams(3)$window" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Semaine non polluée

" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "indices_np = seq(as.Date(\"2015-04-26\"),as.Date(\"2015-05-02\"),\"days\")\n", - "p_np_nn = computeForecast(data,indices_np, \"Neighbors\", \"Neighbors\", simtype=\"mix\")\n", - "p_np_pz = computeForecast(data, indices_np, \"Persistence\", \"Zero\", same_day=FALSE)\n", - "p_np_az = computeForecast(data, indices_np, \"Average\", \"Zero\") #, memory=183)\n", - "#p_np_zz = computeForecast(data, indices_np, \"Zero\", \"Zero\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "e_np_nn = computeError(data, p_np_nn)\n", - "e_np_pz = computeError(data, p_np_pz)\n", - "e_np_az = computeError(data, p_np_az)\n", - "#e_np_zz = computeError(data, p_np_zz)\n", - "options(repr.plot.width=9, repr.plot.height=7)\n", - "plotError(list(e_np_nn, e_np_pz, e_np_az), cols=c(1,2,colors()[258]))\n", - "\n", - "#Noir: neighbors, rouge: persistence, vert: moyenne" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "options(repr.plot.width=9, repr.plot.height=4)\n", - "plotPredReal(data, p_np_nn, 5)\n", - "plotPredReal(data, p_np_nn, 3)\n", - "\n", - "#Bleu: prévue, noir: réalisée" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotPredReal(data, p_np_az, 5)\n", - "plotPredReal(data, p_np_az, 3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "f5_np = computeFilaments(data, p_np_nn$getIndexInData(5), plot=TRUE)\n", - "f3_np = computeFilaments(data, p_np_nn$getIndexInData(3), plot=TRUE)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotFilamentsBox(data, f5_np)\n", - "plotFilamentsBox(data, f3_np)\n", - "\n", - "#À gauche : jour 5 + lendemain (6) ; à droite : jour 3 + lendemain (4)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotRelVar(data, f5_np)\n", - "plotRelVar(data, f3_np)\n", - "\n", - "#Variabilité globale en rouge ; sur nos 60 voisins (+ lendemains) en noir" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "par(mfrow=c(1,2))\n", - "plotSimils(p_np_nn, 5)\n", - "plotSimils(p_np_nn, 3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "#Fenêtres sélectionnées dans ]0,10] / endo à gauche, exo à droite\n", - "p_np_nn$getParams(5)$window\n", - "p_np_nn$getParams(3)$window" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Bilan\n", - "\n", - "Problème difficile : on ne fait guère mieux qu'une naïve moyenne des lendemains des jours similaires dans le passé, ce qui n'est pas loin de prédire une série constante égale à la dernière valeur observée (méthode \"zéro\"). La persistence donne parfois de bons résultats mais est trop instable (sensibilité à l'argument same_day).\n", - "\n", - "Comment améliorer la méthode ?" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "R", - "language": "R", - "name": "ir" - }, - "language_info": { - "codemirror_mode": "r", - "file_extension": ".r", - "mimetype": "text/x-r-source", - "name": "R", - "pygments_lexer": "r", - "version": "3.3.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/reports/report_2017-03-01.7h.ipynb b/reports/report_2017-03-01.7h.ipynb deleted file mode 100644 index f71de9b..0000000 --- a/reports/report_2017-03-01.7h.ipynb +++ /dev/null @@ -1,123 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "library(talweg)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "ts_data = read.csv(system.file(\"extdata\",\"pm10_mesures_H_loc_report.csv\",package=\"talweg\"))\n", - "exo_data = read.csv(system.file(\"extdata\",\"meteo_extra_noNAs.csv\",package=\"talweg\"))\n", - "data = getData(ts_data, exo_data, input_tz = \"Europe/Paris\", working_tz=\"Europe/Paris\", predict_at=7)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "indices_ch = seq(as.Date(\"2015-01-18\"),as.Date(\"2015-01-24\"),\"days\")\n", - "indices_ep = seq(as.Date(\"2015-03-15\"),as.Date(\"2015-03-21\"),\"days\")\n", - "indices_np = seq(as.Date(\"2015-04-26\"),as.Date(\"2015-05-02\"),\"days\")\n", - "H = 6" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "for (i in 1:3) {" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "#blabla\n", - "plot(function(x) cos(x+i))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction\n", - "\n", - "J'ai fait quelques essais dans différentes configurations pour la méthode \"Neighbors\" (la seule dont on a parlé).
Il semble que le mieux soit\n", - "\n", - " * simtype=\"exo\" ou \"mix\" : similarités exogènes avec/sans endogènes (fenêtre optimisée par VC)\n", - " * same_season=FALSE : les indices pour la validation croisée ne tiennent pas compte des saisons\n", - " * mix_strategy=\"mult\" : on multiplie les poids (au lieu d'en éteindre)\n", - "\n", - "J'ai systématiquement comparé à une approche naïve : la moyennes des lendemains des jours \"similaires\" dans tout le passé ; à chaque fois sans prédiction du saut (sauf pour Neighbors : prédiction basée sur les poids calculés).\n", - "\n", - "Ensuite j'affiche les erreurs, quelques courbes prévues/mesurées, quelques filaments puis les histogrammes de quelques poids. Concernant les graphes de filaments, la moitié gauche du graphe correspond aux jours similaires au jour courant, tandis que la moitié droite affiche les lendemains : ce sont donc les voisinages tels qu'utilisés dans l'algorithme.\n", - "\n", - "

Pollution par chauffage

" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Bilan\n", - "\n", - "Problème difficile : on ne fait guère mieux qu'une naïve moyenne des lendemains des jours similaires dans le passé, ce qui n'est pas loin de prédire une série constante égale à la dernière valeur observée (méthode \"zéro\"). La persistence donne parfois de bons résultats mais est trop instable (sensibilité à l'argument same_day).\n", - "\n", - "Comment améliorer la méthode ?" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "R", - "language": "R", - "name": "ir" - }, - "language_info": { - "codemirror_mode": "r", - "file_extension": ".r", - "mimetype": "text/x-r-source", - "name": "R", - "pygments_lexer": "r", - "version": "3.3.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/reports/run.sh b/reports/run_notebook.sh similarity index 100% rename from reports/run.sh rename to reports/run_notebook.sh