Matteo Bertini avatar Matteo Bertini committed 185d7ba

Commit oldmodified stuff

Comments (0)

Files changed (6)

Add a comment to this file

paperi/SeasonalKernel/back-cover.pdf

Binary file removed.

paperi/SeasonalKernel/seasonal-kernel.tex

 prima ne selezioni 45, le 16 con i dati migliori le usi nel test, poi nei usi 5
 per model selection. Le altre le scarti ?}
 
+% Model selection on stations: 716933, 717087, 717123, 717152, 717190
+
+\begin{table}[htdp]
+\caption{Stations for model selection (5 in bold) and test}
+\begin{center}
+\begin{tabular}{|c||c|c|}
+\hline
+Stations & Highway & Lanes \\
+\hline
+\hline
+% cat good-stations.info | awk '{print $1,"&",$2,$3,"\t&",$13,"\\\\"}' > good-stations.info.tex
+715916 & 5 S 	& 4 \\
+716312 & 91 E 	& 6 \\
+716551 & 134 W 	& 4 \\
+716841 & 605 N 	& 4 \\
+\textbf{716933} & 5 N 	& 5 \\
+\textbf{717087} & 10 W 	& 4 \\
+\textbf{717123} & 10 E 	& 4 \\
+\textbf{717152} & 10 E 	& 4 \\
+\textbf{717190} & 10 E 	& 4 \\
+717269 & 60 W 	& 5 \\
+718144 & 101 S 	& 4 \\
+737344 & 10 E 	& 4 \\
+763626 & 110 N 	& 4 \\
+764151 & 5 S 	& 4 \\
+767678 & 605 N 	& 4 \\
+768682 & 5 N 	& 5 \\
+\hline
+\end{tabular}
+\end{center}
+\label{table:stations}
+\end{table}
+
+
+
 We used 5 stations for the model selection and all the high quality stations
 for the test. For each station the first four months (Jan-Apr 2009) are used as
 training period, the following two months (May-Jun 2009) as a validation period
 \end{itemize}
 
 As for SARIMA, the two models employed differ in the algorithm which is used to
-fit the parameters\fxnote{Matteo: giusto ??}. While SARIMA$_{css}$ simply
+fit the parameters\fxnote{Matteo: giusto ??}\fxnote{Marco: in realtà differiscono anche nella predizione, visto che uno ha il filtro di Kalman e l'altro una semplice eq. ricorsiva}. While SARIMA$_{css}$ simply
 adopts a conditional sum of squares, in order to fit the Kalman state space
 model in SARIMA$_{Kal}$ we followed the two approaches described
 in~\cite{Gardner1980} and~\cite{Jones1980}: the first algorithm is used to
 For SVR$_{RBF}$ we performed a model selection on $C$ and $\gamma$, while for
 SVR$_{RBF}^{S}$ we also had to choose $\gamma^{S}$. SVR$_{lin}^{S}$ needs a
 model selection on $\lambda$ and $\sigma$\fxnote{Matteo: come si definisce
-$\sigma$ ??}, while for the NN the number of hidden neurons and the learning
+$\sigma$ ??}\fxnote{Marco: è come $\gamma^{S}$ regola quanto si influenzano due esempi in base alla distanza nel periodo (forse si capisce meglio dalla formula)}, while for the NN the number of hidden neurons and the learning
 rate were tuned in the validation phase as well. Table~\ref{table:parameters}
 shows the choice of parameters obtained by model selection for these machine
 learning algorithms.

seasonal/sandbox/timetest-mean.py

         for model in sorted(timetest['mean'], key=headers.get):
             res += [headers[model], ":\t" if len(headers[model])>7 else ":\t\t"]
             faces = []
-            for face in ['train', 'predict', 'err', 'size']: #timetest['mean'][model]:
+            for face in ['train', 'memory', 'predict', 'err', 'size']: #timetest['mean'][model]:
                 value = timetest['mean'][model][face]
                 if 'd1' in model and face != 'err':
                     value = value*5

seasonal/sh/lag-curve-months-pakeflow.sh

 set -o nounset
 set -o errexit
 
-function eecho {
-  echo "$*" 1>&2;
-}
-__counter=0
-function memo {
-  let __counter+=1
-  echo "$*";
-}
-
-memo_py=sandbox/pakeflow/memo.py
-
-eecho "DEBUG: Executing $BASH_SOURCE $@"
-
 conf=${1%.list}
 err=${2:-MAD}
 dest=${3:-lagcurve-$conf}
 
-STATIONS=$(cat $conf.list | egrep -v "717282|717306|717294|717285" | tr '\n' ' ')
+memo_py=sandbox/pakeflow/memo.py
 
+function eecho {
+  if [[ "$*" =~ "INFO:" ]]; then
+    echo "$*"
+  else
+    echo "$*" 1>&2
+  fi
+}
+function memo {
+  #$memo_py "$*"
+  echo $(echo "$*" | tr '\n' ' ' | sed 's/ \+/ /g')
+}
+
+eecho "DEBUG: Executing $BASH_SOURCE $@"
+start_date=`date`
+eecho "DEBUG: [$start_date] Starting $conf ..."
+
+function run {
+STATIONS=$(cat $conf.list | tr '\n' ' ')
 MONTHS="2009-06 2009-05 2009-04 2009-03 2009-02 2009-01"
-
-mconf=five-stations-dworkdays
-mlist=$(cat $mconf.list )
-
-rm -f mk/$mconf-$(hostname).Makefile
-$memo_py -v "'./dataset.py' pems/d07 data/$mconf $mlist --quantity flow --no-classify  -o" mk/$mconf-$(hostname).Makefile
-rm -f data/$mconf/$mconf-$(hostname).log
-$memo_py -v -i "make -j2 -f mk/$mconf-$(hostname).Makefile bestparms > data/$mconf/$mconf-$(hostname).log"
-rbfs_bestparms=data/$mconf/bestparms/all/dworkdays-flow-svr-rbf-seasonal.bestparms
-while read line; do eecho DEBUG: [RBF+S] $line; done < $rbfs_bestparms
-rbf_bestparms=data/$mconf/bestparms/all/dworkdays-flow-svr-rbf.bestparms
-while read line; do eecho DEBUG: [RBF] $line; done < $rbf_bestparms
-
-linear_bestparms=data/$mconf/grid/linear/all.bestparms
-$memo_py -i "sandbox/run-linear-grid.sh > /dev/null # $linear_bestparms"
-while read line; do eecho DEBUG: [Linear] $line; done < $linear_bestparms
+eecho "DEBUG: Looping on $(echo $STATIONS | wc -w) stations ..."
+eecho "DEBUG: Looping on $(echo $MONTHS | wc -w) months ..."
 
 results=()
-
-eecho "DEBUG: Looping on $MONTHS..."
+nstations=0
 for s in $STATIONS; do
-  eecho "DEBUG: Lag curve for station: $s..."
+  let nstations=nstations+1
+  eecho "DEBUG: Lag curve for station: [$nstations] $s..."
   train_months=""
   nmonths=0
 
   for month in $MONTHS; do
-    train_months=$(echo "$train_months $month" | awk '{print $(NF-1),$NF}')
-    if [ "$nmonths" -lt "1" ]; then
-      let nmonths=nmonths+1
-      continue;
-    fi
-    eecho "DEBUG: Lag curve months $s: [$nmonths] $train_months..."
+    let nmonths=nmonths+1
+    train_months="$month $train_months"
+    eecho "DEBUG: Lag curve months: [$nmonths] $train_months..."
     mkconf=lagcurve-$conf-nm$nmonths
-    lconf=$dest/nm$nmonths
-    mk=data/$lconf
+    lconf=$dest/$mkconf
     mkdir -p data/$lconf
     ln -f -s ../../stations/pemstables data/$lconf/
     memo "'./dataset.py' pems/d07 data/$lconf $STATIONS --vtrain $train_months --vtest --quantity flow --datasets train test --days d1 d2 d3 d4 d5 dworkdays --no-classify -o mk/$mkconf.Makefile"
     tsvtrain="$tsdir/$s.train.flow.dworkdays"
     tsvtest="$tsdir/$s.test.flow.dworkdays"
 
-    memo "make -f mk/$mkconf.Makefile $tsvtrain $tsvtest > $lagcurvedir/$mkconf.$__counter.log # +MKTARGETS $tsvtrain $tsvtest +TARGETS $lagcurvedir/$mkconf.$__counter.log"
+    memo "make -f mk/$mkconf.Makefile $tsvtrain $tsvtest # +MKTARGETS $tsvtrain $tsvtest"
     tstest=$lagcurvedir/lagcurve$nmonths-$(basename $tsvtest)
     memo "cat $tsvtest >" $tstest
 
     ###### RBF+Seasonal ######
-    # cat data/five-stations-dworkdays/*.grids | grep flow | grep svr | grep t4 | xargs sh/validation-perf.py
-    # [5]min(Avg:MAD)= 52.54 ~ 8.61	5	0.5	0.01	192	86400	w6	+mean
-    # [5]min(Std:MAD)= 62.62 ~ 7.47	1	0.5	0.01	96	604800	w3	plain
-    source $rbfs_bestparms
+    #MAPE100: 5.262 <-------------- BEST
+    #- {C: 5, MAPE100: '5.262', _num: 5, epsilon: 0.01, day: 'workdays', gamma: 1, period: 86400, quantity: flow, seas: mean2, seasonal_gamma: 192, wsize: 3}
+    wsize=3
+    seas=.mean2
+    t=4
+    gamma=1.0
+    C=5
+    period=86400
+    seasonal_gamma=192
+    epsilon=0.01
+    ker=rbf-seasonal
+
     vtrain="$svmdir/$s.train.flow.dworkdays.w$wsize$seas.svr"
     vtest="$svmdir/$s.test.flow.dworkdays.w$wsize$seas.svr"
-    memo "make -f mk/$mkconf.Makefile $vtrain $vtest > $lagcurvedir/$mkconf.$__counter.log # +MKTARGETS $vtrain $vtest +TARGETS $lagcurvedir/$mkconf.$__counter.log"
+    memo "make -f mk/$mkconf.Makefile $vtrain $vtest # +MKTARGETS $vtrain $vtest"
     rtrain=$lagcurvedir/lagcurve$nmonths-$(basename $vtrain)
     memo "cat $vtrain >" $rtrain
     rtest=$lagcurvedir/lagcurve$nmonths-$(basename $vtest)
     memo "'labels_timeseries.py' $rtest | cut -d' ' -f 1 | paste -d' ' - $rbfs_out | 'timeseries_scale.py' -i -m 1000 2000 - -o" $rbfs_fore
 
     ###### RBF ######
-    source $rbf_bestparms
+    #MAPE100: 5.360 <-------------- BEST
+    #- {C: 5, MAPE100: '5.360', _num: 5, epsilon: 0.01, day: 'workdays', gamma: 5, quantity: flow, seas: mean2, wsize: 3}
+    wsize=3
+    seas=.mean2
+    t=2
+    gamma=5.0
+    C=5
+    epsilon=0.01
+    ker=rbf
+
     vtrain="$svmdir/$s.train.flow.dworkdays.w$wsize$seas.svr"
     vtest="$svmdir/$s.test.flow.dworkdays.w$wsize$seas.svr"
-    memo "make -f mk/$mkconf.Makefile $vtrain $vtest > $lagcurvedir/$mkconf.$__counter.log # +MKTARGETS $vtrain $vtest +TARGETS $lagcurvedir/$mkconf.$__counter.log"
+    memo "make -f mk/$mkconf.Makefile $vtrain $vtest # +MKTARGETS $vtrain $vtest"
     rtrain=$lagcurvedir/lagcurve$nmonths-$(basename $vtrain)
     memo "cat $vtrain >" $rtrain
     rtest=$lagcurvedir/lagcurve$nmonths-$(basename $vtest)
     memo "'labels_timeseries.py' $rtest | cut -d' ' -f 1 | paste -d' ' - $rbf_out | 'timeseries_scale.py' -i -m 1000 2000 - -o" $rbf_fore
 
     ###### Linear ######
-    source $linear_bestparms
-    vtrain="$svmdir/$s.train.flow.dworkdays.w$wsize$seas.svr"
-    vtest="$svmdir/$s.test.flow.dworkdays.w$wsize$seas.svr"
-    memo "make -f mk/$mkconf.Makefile $vtrain $vtest > $lagcurvedir/$mkconf.$__counter.log # +MKTARGETS $vtrain $vtest +TARGETS $lagcurvedir/$mkconf.$__counter.log"
-    rtrain=$lagcurvedir/lagcurve$nmonths-$(basename $vtrain)
-    memo "cat $vtrain >" $rtrain
-    rtest=$lagcurvedir/lagcurve$nmonths-$(basename $vtest)
-    memo "cat $vtest >" $rtest
-    linear_model=$rtrain-$ker-l$lam-g$sigma-e$epsilon-p$period-i$iters.model
-    memo "'svrsgd_seasonal.py' -s 'EpsilonInsensitive($epsilon)' -l $lam -g $sigma -p $period -i $iters $rtrain -o" $linear_model 
-    linear_out=${linear_model%.model}.out
-    memo "'svrsgd_seasonal.py' -m $linear_model $rtest -o" $linear_out
-    linear_fore=${linear_out%.out}.fore
-    memo "'labels_timeseries.py' $rtest | cut -d' ' -f 1 | paste -d' ' - $linear_out | 'timeseries_scale.py' -i -m 1000 2000 - -o" $linear_fore
+    #MAPE100: 5.133
+    #- {MAPE100: '5.127', _num: 25, eps: 0.01, day: 'wdpart', iters: 150000, lam: 0.001, period: 96, quantity: flow, seas: mean2, sigma: 1.0, wsize: 3}
+    eps=0.01
+    lam=0.001
+    iters=150000
+    sigma=1.0
+    wsize=3.mean2
+    period=96
+    ker=linear
+
+    for d in 1 2 3 4 5; do
+      vtrain="$svmdir/$s.train.flow.d$d.w$wsize.svr"
+      vtest="$svmdir/$s.test.flow.d$d.w$wsize.svr"
+      memo "make -f mk/$mkconf.Makefile $vtrain $vtest # +MKTARGETS $vtrain $vtest"
+      rtrain=$lagcurvedir/lagcurve$nmonths-$(basename $vtrain)
+      memo "cat $vtrain >" $rtrain
+      rtest=$lagcurvedir/lagcurve$nmonths-$(basename $vtest)
+      memo "cat $vtest >" $rtest
+      linear_model=$rtrain-$ker-l$lam-g$sigma-e$epsilon-p$period-i$iters.model
+      memo "'svrsgd_seasonal.py' -s 'EpsilonInsensitive($epsilon)' -l $lam -g $sigma -p $period -i $iters $rtrain -o" $linear_model 
+      linear_out=${linear_model%.model}.out
+      memo "'svrsgd_seasonal.py' -m $linear_model $rtest -o" $linear_out
+      linear_fore=${linear_out%.out}.fore
+      memo "'labels_timeseries.py' $rtest | cut -d' ' -f 1 | paste -d' ' - $linear_out | 'timeseries_scale.py' -i -m 1000 2000 - -o" $linear_fore
+      fores+=("$linear_fore")
+    done
+    linear_fore=$(echo $linear_fore | sed "s/\.d[0-9]\./.dwdpart./g")
+    memo "cat ${fores[@]} | grep -v nan >" $linear_fore
 
     ###### LOESS ######
-    span=0.03
-    wsize=3.mean
-    degree=1
-    vtrain="$svmdir/$s.train.flow.dworkdays.w$wsize.svr"
-    vtest="$svmdir/$s.test.flow.dworkdays.w$wsize.svr"
-    memo "make -f mk/$mkconf.Makefile $vtrain $vtest > $lagcurvedir/$mkconf.$__counter.log # +MKTARGETS $vtrain $vtest +TARGETS $lagcurvedir/$mkconf.$__counter.log"
-    rtrain=$lagcurvedir/lagcurve$nmonths-$(basename $vtrain)
-    memo "cat $vtrain >" $rtrain
-    rtest=$lagcurvedir/lagcurve$nmonths-$(basename $vtest)
-    memo "cat $vtest >" $rtest
-    loess_model=$rtrain-sp$span-dg$degree.model
-    memo "'loess_learn.R' $span $degree $rtrain" $loess_model 
-    loess_out=${loess_model%.model}.out
-    memo "'loess_forecast.R' $loess_model $rtest" $loess_out
-    loess_fore=${loess_out%.out}.fore
-    memo "'labels_timeseries.py' $rtest | cut -d' ' -f 1 | paste -d' ' - $loess_out | 'timeseries_scale.py' -i -m 1000 2000 - -o" $loess_fore
+    #span=0.03
+    #wsize=3.mean
+    #degree=1
+    #vtrain="$svmdir/$s.train.flow.dworkdays.w$wsize.svr"
+    #vtest="$svmdir/$s.test.flow.dworkdays.w$wsize.svr"
+    #memo "make -f mk/$mkconf.Makefile $vtrain $vtest # +MKTARGETS $vtrain $vtest"
+    #rtrain=$lagcurvedir/lagcurve$nmonths-$(basename $vtrain)
+    #memo "cat $vtrain >" $rtrain
+    #rtest=$lagcurvedir/lagcurve$nmonths-$(basename $vtest)
+    #memo "cat $vtest >" $rtest
+    #loess_model=$rtrain-sp$span-dg$degree.model
+    #memo "'loess_learn.R' $span $degree $rtrain" $loess_model 
+    #loess_out=${loess_model%.model}.out
+    #memo "'loess_forecast.R' $loess_model $rtest" $loess_out
+    #loess_fore=${loess_out%.out}.fore
+    #memo "'labels_timeseries.py' $rtest | cut -d' ' -f 1 | paste -d' ' - $loess_out | 'timeseries_scale.py' -i -m 1000 2000 - -o" $loess_fore
 
     ###### RW and SM #####
     rw_fore=$lagcurvedir/$s.lagcurve.rw.fore
     kal_fore=${kal_model%.model}.fore
     memo arima_forecast.R $kal_model $tstest $kal_fore
 
-    ###### SARIMA ######
+    ###### SARIMA CSS ######
     p=480
     tstrain=$lagcurvedir/lagcurve$nmonths-$(basename $tsvtrain)
     memo "cat $tsvtrain > $tstrain"
     for d in d1 d2 d3 d4 d5; do
       dtsvtrain=${tsvtrain%.dworkdays}.$d
       dtsvtest=${tsvtest%.dworkdays}.$d
-      memo "make -f mk/$mkconf.Makefile $dtsvtrain $dtsvtest > $lagcurvedir/$mkconf-dN.$__counter.log # +MKTARGETS $dtsvtrain $dtsvtest +TARGETS $lagcurvedir/$mkconf-dN.$__counter.log"
+      memo "make -f mk/$mkconf.Makefile $dtsvtrain $dtsvtest # +MKTARGETS $dtsvtrain $dtsvtest"
       dtstest=$dtsvtest
       tstrain=$lagcurvedir/$s.lagcurve.$nmonths.$d.ts
       memo "cat $dtsvtrain >" $tstrain
       skal_model=${tstrain%.ts}.$sarima.model
-      memo arima_learn.R $p $tstrain $skal_model
+      memo 'arima_learn.R' $p $tstrain $skal_model
       skal_fore=${skal_model%.model}.fore
-      memo arima_forecast.R $skal_model $dtstest $skal_fore
+      memo 'arima_forecast.R' $skal_model $dtstest $skal_fore
       fores+=("$skal_fore")
     done
     skal_fore=$lagcurvedir/$s.lagcurve.$nmonths.dwdpart.$sarima.fore
     memo "cat ${fores[@]} | grep -v nan >" $skal_fore
 
     ###### Neural Networks ######
-    hiddens=5
-    iters=100
+    #MAPE100: 5.121 <-------------- BEST
+    #- {MAPE100: '5.112', _num: 22, day: 'wdpart', hiddens: 10, iterepochs: 1, lrate: 0.01, maxiters: 100, period: 96, quantity: flow, wsize: 3.mean2}
+    hiddens=10
+    iterepochs=100
+    maxiters=100
     wsize=3.mean2
-    lrate=0.001
+    lrate=0.01
+
     fores=()
     for d in 1 2 3 4 5; do
       vtrain="$svmdir/$s.train.flow.d$d.w$wsize.svr"
       vtest="$svmdir/$s.test.flow.d$d.w$wsize.svr"
-      memo "make -f mk/$mkconf.Makefile $vtrain $vtest > $lagcurvedir/$mkconf.$__counter.log # +MKTARGETS $vtrain $vtest +TARGETS $lagcurvedir/$mkconf.$__counter.log"
+      memo "make -f mk/$mkconf.Makefile $vtrain $vtest # +MKTARGETS $vtrain $vtest"
       rtrain=$lagcurvedir/lagcurve$nmonths-$(basename $vtrain)
       memo "cat $vtrain >" $rtrain
       rtest=$lagcurvedir/lagcurve$nmonths-$(basename $vtest)
       memo "cat $vtest >" $rtest
-      nn_model=${vtrain%.ts}.nn.model
-      memo 'nn_learn.R' $hiddens $iters $lrate $rtrain $nn_model
+      nn_model=$rtrain-h$hiddens-l$lrate-i$iters.nn.model
+      memo "'nn_learn.R' hiddens=$hiddens iterepochs=$iterepochs maxiters=$maxiters 'lrate=$lrate' \
+            $rtrain $nn_model $nn_model.val.ecurve $nn_model.val.iters # +TARGETS $nn_model $nn_model.val.ecurve $nn_model.val.iters"
       nn_out=${nn_model%.model}.out
-      memo 'nn_forecast.R' $nn_model $rtest $nn_out
+      memo 'nn_forecast.R' forecast $nn_model $rtest $nn_out
       nn_fore=${nn_out%.out}.fore
       memo "'labels_timeseries.py' $rtest | cut -d' ' -f 1 | paste -d' ' - $nn_out | 'timeseries_scale.py' -i -m 1000 2000 - -o" $nn_fore
       fores+=("$nn_fore")
     done
-    nn_fore=$lagcurvedir/$s.lagcurve.$nmonths.dwdpart.nn.fore
+    nn_fore=$(echo $nn_fore | sed "s/\.d[0-9]\./.dwdpart./g")
     memo "cat ${fores[@]} | grep -v nan >" $nn_fore
 
     #for model in sv rw sm css ml kal; do
     #  eval "model_fore=\$${model}_fore"
     #  eecho "DEBUG: $model_fore [$(cat $model_fore | wc -l)]"
     #done
-
-    models="rw sm css skal kal rbf rbfs linear loess nn"
+    
+    models="rw sm css skal kal rbf rbfs linear nn"
 
     #eecho "DEBUG: [full] $tstest [$(cat $tstest | wc -l)]"
     tstest_intersect=$lagcurvedir/$s.lagcurve.intersect.fore
     memo "cat ${results_month[@]} > data/$dest/lagcurve-$s-nm$nmonths-$model.$err.result"
     results+=(data/$dest/lagcurve-$s-nm$nmonths-$model.$err.result)
 
-    if [ "$nmonths" == "DISABLE" ]; then
+    if [ "$nmonths" == "3" ]; then
       results_hours=()
-      eecho "DEBUG: Station $s Test 24 hours..."
+      eecho "DEBUG:    detailed error for 24 hours..."
       for i in {0..23}; do
         let ip=i+1
         u=$i-$ip
       memo "cat ${results_hours[@]} > data/$dest/lagcurve-hours-$s-$model.$err.result"
       results+=(data/$dest/lagcurve-hours-$s-$model.$err.result)
     fi # nmonths == 3
-    let nmonths=nmonths+1
   done # months
 done # stations
 
 memo "for res in ${results[@]} ; do cat \$res; done > data/$dest/lagcurve-$err.results"
+}
+
+run | awk '!x[$0]++'

seasonal/sh/learning-curve-months-pakeflow.sh

     memo "cat ${results_month[@]} > data/$dest/lcurve-$s-nm$nmonths-$model.$err.result"
     results+=(data/$dest/lcurve-$s-nm$nmonths-$model.$err.result)
 
-    if [ "$nmonths" == "3" ]; then
+    if [ "$nmonths" == "3" ] || [ "$nmonths" == "6" ]; then
       results_hours=()
-      eecho "DEBUG:    detailed error for 24 hours..."
+      eecho "DEBUG:   nmonths=$nmonths detailed error for 24 hours..."
       for i in {0..23}; do
         let ip=i+1
         u=$i-$ip
       done # part of day
       memo "cat ${results_hours[@]} > data/$dest/lcurve-hours-$s-$model.$err.result"
       results+=(data/$dest/lcurve-hours-$s-$model.$err.result)
-    fi # nmonths == 3
+    fi # nmonths == 3 # 24h details
+    if [ "$nmonths" == "3" ]; then
+      for x in $STATIONS; do
+
+      done
+    fi # nmonths == 3 # xstation error
   done # months
 done # stations
 

seasonal/sh/timetest.sh

 set -o nounset
 set -o errexit
 
-lcurve_results=$1
-
 memo_py=sandbox/pakeflow/memo.py
 plow_py=sandbox/pakeflow/plow.py
 
   echo "$*";
 }
 
-basedir=data/lcurve-good-stations/lcurve-good-stations-nm3
+nm=6
+basedir=data/lcurve-good-stations/lcurve-good-stations-nm$nm
 
 mkdir -p $basedir/timetests/
 for station in $(cat good-stations.list); do
    # # # # # # # # # #
 
   ###### ARIMA ######
-  arima_rtrain=$basedir/lcurve3-$station.train.flow.dworkdays
-  arima_rtest=$basedir/lcurve3-$station.test.flow.dworkdays
+  arima_rtrain=$basedir/lcurve$nm-$station.train.flow.dworkdays
+  arima_rtest=$basedir/lcurve$nm-$station.test.flow.dworkdays
   arima_model=$basedir/timetests/learn-$station.dworkdays.arima_kalman.model
   memo "/usr/bin/time 'arima_learn.R' 1 $arima_rtrain $arima_model \
         2>&1 | tail -n2 > $arima_model.time # +TARGETS $arima_model $arima_model.time"
   memo "/usr/bin/time 'arima_learn.R' 96 $kal_rtrain $kal_model \
         2>&1 | tail -n2 > $kal_model.time # +TARGETS $kal_model $kal_model.time"
   ###### SARIMA CSS ######
-  css_rtrain=$basedir/lcurve3-$station.train.flow.dworkdays
-  css_rtest=$basedir/lcurve3-$station.test.flow.dworkdays
+  css_rtrain=$basedir/lcurve$nm-$station.train.flow.dworkdays
+  css_rtest=$basedir/lcurve$nm-$station.test.flow.dworkdays
   css_model=$basedir/timetests/learn-$station.dworkdays.sarima_css.model
   memo "/usr/bin/time 'sarima_css.py' -p 480 <(cut -d' ' -f 2 $css_rtrain ) -o $css_model \
         2>&1 | tail -n2 > $css_model.time # +TARGETS $css_model $css_model.time"
   C=5
   epsilon=0.01
   ker=rbf
-  rbf_rtrain="$basedir/lcurve3-$station.train.flow.dworkdays.w$wsize.svr"
-  rbf_rtest="$basedir/lcurve3-$station.test.flow.dworkdays.w$wsize.svr"
+  rbf_rtrain="$basedir/lcurve$nm-$station.train.flow.dworkdays.w$wsize.svr"
+  rbf_rtest="$basedir/lcurve$nm-$station.test.flow.dworkdays.w$wsize.svr"
   rbf_model=$basedir/timetests/learn-$station.dworkdays.rbf.model
   memo "/usr/bin/time svm_learn -m 1024 -z r -t $t -c $C -g $gamma -w $epsilon $rbf_rtrain $rbf_model \
         2>&1 | tail -n2 > $rbf_model.time # +TARGETS $rbf_model $rbf_model.time"
   seasonal_gamma=192
   epsilon=0.01
   ker=rbf-seasonal
-  rbfs_rtrain="$basedir/lcurve3-$station.train.flow.dworkdays.w$wsize.svr"
-  rbfs_rtest="$basedir/lcurve3-$station.test.flow.dworkdays.w$wsize.svr"
+  rbfs_rtrain="$basedir/lcurve$nm-$station.train.flow.dworkdays.w$wsize.svr"
+  rbfs_rtest="$basedir/lcurve$nm-$station.test.flow.dworkdays.w$wsize.svr"
   rbfs_model=$basedir/timetests/learn-$station.dworkdays.rbf-seasonal.model
   memo "/usr/bin/time svm_learn -m 1024 -z r -t $t -c $C -g $gamma -w $epsilon -s $seasonal_gamma -d $period $rbfs_rtrain $rbfs_model \
         2>&1 | tail -n2 > $rbfs_model.time # +TARGETS $rbfs_model $rbfs_model.time"
   wsize=3.mean2
   period=96
   ker=linear
-  lin_rtrain="$basedir/lcurve3-$station.train.flow.d1.w$wsize.svr"
-  lin_rtest="$basedir/lcurve3-$station.test.flow.d1.w$wsize.svr"
+  lin_rtrain="$basedir/lcurve$nm-$station.train.flow.d1.w$wsize.svr"
+  lin_rtest="$basedir/lcurve$nm-$station.test.flow.d1.w$wsize.svr"
   lin_model=$basedir/timetests/learn-$station.dworkdays.linear-seasonal.model
   memo "/usr/bin/time 'svrsgd_seasonal.py' -s 'EpsilonInsensitive($epsilon)' -l $lam -g $sigma -p $period -i $iters $lin_rtrain -o $lin_model \
          2>&1 | tail -n2 > $lin_model.time # +TARGETS $lin_model $lin_model.time"
   maxiters=100
   wsize=3.mean2
   lrate=0.01
-  nn_rtrain="$basedir/lcurve3-$station.train.flow.d1.w$wsize.svr"
-  nn_rtest="$basedir/lcurve3-$station.test.flow.d1.w$wsize.svr"
+  nn_rtrain="$basedir/lcurve$nm-$station.train.flow.d1.w$wsize.svr"
+  nn_rtest="$basedir/lcurve$nm-$station.test.flow.d1.w$wsize.svr"
   nn_model=$basedir/timetests/learn-$station.d1.nn.model
   memo "/usr/bin/time 'nn_learn.R' hiddens=$hiddens iterepochs=$iterepochs maxiters=$maxiters 'lrate=$lrate' \
         $nn_rtrain $nn_model $nn_model.val.ecurve $nn_model.val.iters \
   for model in dworkdays.arima_kalman d1.sarima_kalman dworkdays.sarima_css dworkdays.rbf dworkdays.rbf-seasonal dworkdays.linear-seasonal d1.nn; do
     echo " "$model: { \
          train: $(head -n1 "$basedir/timetests/learn-$station.$model.model.time" | sed 's/\([0-9]\+\.[0-9]\+\).*/\1/'), \
+         memory: $(head -n1 "$basedir/timetests/learn-$station.$model.model.time" | sed 's/.*data \([0-9]\+\)maxresident.*/\1/'), \
          size: $(stat -c"%s" "$basedir/timetests/learn-$station.$model.model"), \
          predict: $(head -n1 "$basedir/timetests/learn-$station.$model.predict.time" | sed 's/\([0-9]\+\.[0-9]\+\).*/\1/') }
   done
-  echo " "dworkdays.random-walk: { train: 0.1, size: 8.0, predict: 0.1 }
-  echo " "dworkdays.seasonal-mean: { train: 1.0, size: 3956.0, predict: 0.2 }
-done #| sandbox/timetest-mean.py $lcurve_results
+  echo " "dworkdays.random-walk: { train: 0.1, memory: 8.0, size: 8.0, predict: 0.1 }
+  echo " "dworkdays.seasonal-mean: { train: 1.0, memory: 3956.0, size: 3956.0, predict: 0.2 }
+done
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.