Skip to content

Commit d184c73

Browse files
authored
Merge pull request #18 from scalation/dev_Yousef
Added example_ILITest11
2 parents 4fe8b77 + 08dbdcd commit d184c73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+159
-47
lines changed

.idea/workspace.xml

Lines changed: 52 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/scala/scalation/modeling/forecasting/ARX.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ARX (x: MatrixD, y: VectorD, hh: Int, n_exo: Int, fname: Array [String],
4646
tForms: TransformMap = Map ("tForm_y" -> null))
4747
extends Forecaster_Reg (x, y, hh, fname, tRng, hparam, bakcast):
4848

49-
private val debug = debugf ("ARX", true) // debug function
49+
private val debug = debugf ("ARX", false) // debug function
5050
protected val p = hparam("p").toInt // use the last p endogenous values (p lags)
5151
protected val q = hparam("q").toInt // use the last q exogenous values (q lags)
5252
protected val spec = hparam("spec").toInt // trend terms: 0 - none, 1 - constant, 2 - linear, 3 - quadratic

src/main/scala/scalation/modeling/forecasting/Example_ILI.scala

Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ end example_ILITest9
313313
*/
314314
@main def example_ILITest10 (): Unit =
315315

316-
import AR.hp
316+
import MakeMatrix4TS.hp
317317

318318
val exo_vars = Array ("%WEIGHTED ILI", "%UNWEIGHTED ILI")
319319
val (xe, y) = loadData (exo_vars, response)
@@ -325,7 +325,6 @@ end example_ILITest9
325325
val pp = 1.5
326326
hp("p") = p // endo lags
327327
hp("q") = q // exo lags
328-
hp("pp") = pp // power to raise lags to
329328
hp("spec") = 1 // trend specification: 0, 1, 2, 3, 5
330329
hp("lwave") = 20 // wavelength (distance between peaks)
331330
hp("cross") = 1
@@ -364,3 +363,107 @@ end example_ILITest9
364363

365364
end example_ILITest10
366365

366+
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
367+
/** The `example_ILITest10` main function test the `Example_ILI` object.
368+
* This test compares the several models for several values of p and q.
369+
* > runMain scalation.modeling.forecasting.example_ILITest11
370+
*/
371+
@main def example_ILITest11 (): Unit =
372+
373+
import MakeMatrix4TS.hp
374+
375+
// val exo_vars = Array ("%WEIGHTED ILI", "%UNWEIGHTED ILI")
376+
val exo_vars = Array("OT")
377+
378+
val (xe, y) = loadData (exo_vars, response)
379+
println (s"xe.dims = ${xe.dims}, y.dim = ${y.dim}")
380+
381+
val hh = 6 // maximum forecasting horizon
382+
val p = 6
383+
val q = 6
384+
hp("p") = p // endo lags
385+
hp("q") = q // exo lags
386+
hp("spec") = 1 // trend specification: 0, 1, 2, 3, 5
387+
hp("lwave") = 20 // wavelength (distance between peaks)
388+
hp("cross") = 0
389+
hp("lambda") = 1.0
390+
391+
392+
banner("RandomWalkS")
393+
val mod1 = RandomWalkS(y, hh) // create model for time series data
394+
banner(s"In-ST Forecasts: ${mod1.modelName} on ILI Dataset")
395+
mod1.trainNtest()() // train and test on full dataset
396+
mod1.forecastAll() // forecast h-steps ahead (h = 1 to hh) for all y
397+
mod1.diagnoseAll(mod1.getY, mod1.getYf)
398+
399+
println("rollValidate")
400+
mod1.setSkip(0)
401+
mod1.rollValidate() // TnT with Rolling Validation
402+
mod1.diagnoseAll(mod1.getY, mod1.getYf, Forecaster.teRng(y.dim), 0)
403+
404+
405+
banner("AR")
406+
val mod2 = AR(y, hh) // create model for time series data
407+
banner(s"In-ST Forecasts: ${mod2.modelName} on ILI Dataset")
408+
mod2.trainNtest()() // train and test on full dataset
409+
mod2.forecastAll() // forecast h-steps ahead (h = 1 to hh) for all y
410+
mod2.diagnoseAll(mod2.getY, mod2.getYf)
411+
412+
println("rollValidate")
413+
mod2.setSkip(0)
414+
mod2.rollValidate() // TnT with Rolling Validation
415+
mod2.diagnoseAll(mod2.getY, mod2.getYf, Forecaster.teRng(y.dim), 0)
416+
417+
418+
banner("ARX")
419+
val mod3 = ARX(xe, y, hh) // create model for time series data
420+
banner(s"In-ST Forecasts: ${mod3.modelName} on ILI Dataset")
421+
mod3.trainNtest_x()() // train and test on full dataset
422+
mod3.forecastAll() // forecast h-steps ahead (h = 1 to hh) for all y
423+
mod3.diagnoseAll(mod3.getY, mod3.getYf)
424+
425+
println("rollValidate")
426+
mod3.setSkip(0)
427+
mod3.rollValidate() // TnT with Rolling Validation
428+
mod3.diagnoseAll(mod3.getY, mod3.getYf, Forecaster.teRng(y.dim), 0)
429+
430+
431+
banner("ARX_D")
432+
val mod4 = ARX_D(xe, y, hh) // create model for time series data
433+
banner(s"In-ST Forecasts: ${mod4.modelName} on ILI Dataset")
434+
mod4.trainNtest_x()() // train and test on full dataset
435+
mod4.forecastAll() // forecast h-steps ahead (h = 1 to hh) for all y
436+
mod4.diagnoseAll(mod4.getY, mod4.getYf)
437+
438+
println("rollValidate")
439+
mod4.setSkip(0)
440+
mod4.rollValidate() // TnT with Rolling Validation
441+
mod4.diagnoseAll(mod4.getY, mod4.getYf, Forecaster.teRng(y.dim), 0)
442+
443+
444+
banner("ARX_Quad")
445+
val mod5 = ARX_Quad(xe, y, hh) // create model for time series data
446+
banner(s"In-ST Forecasts: ${mod5.modelName} on ILI Dataset")
447+
mod5.trainNtest_x()() // train and test on full dataset
448+
mod5.forecastAll() // forecast h-steps ahead (h = 1 to hh) for all y
449+
mod5.diagnoseAll(mod5.getY, mod5.getYf)
450+
451+
println("rollValidate")
452+
mod5.setSkip(0)
453+
mod5.rollValidate() // TnT with Rolling Validation
454+
mod5.diagnoseAll(mod5.getY, mod5.getYf, Forecaster.teRng(y.dim), 0)
455+
456+
457+
banner("ARX_Quad_D")
458+
val mod6 = ARX_Quad_D(xe, y, hh) // create model for time series data
459+
banner(s"In-ST Forecasts: ${mod6.modelName} on ILI Dataset")
460+
mod6.trainNtest_x()() // train and test on full dataset
461+
mod6.forecastAll() // forecast h-steps ahead (h = 1 to hh) for all y
462+
mod6.diagnoseAll(mod6.getY, mod6.getYf)
463+
464+
println("rollValidate")
465+
mod6.setSkip(0)
466+
mod6.rollValidate() // TnT with Rolling Validation
467+
mod6.diagnoseAll(mod6.getY, mod6.getYf, Forecaster.teRng(y.dim), 0)
468+
469+
end example_ILITest11

src/main/scala/scalation/modeling/forecasting/Forecaster_Reg.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ abstract class Forecaster_Reg (x: MatrixD, y: VectorD, hh: Int, fname: Array [St
4040
extends Forecaster (y, hh, tRng, hparam, bakcast)
4141
with FeatureSelection:
4242

43-
private val debug = debugf ("Forecaster_Reg", true) // debug function
43+
private val debug = debugf ("Forecaster_Reg", false) // debug function
4444
private val flaw = flawf ("Forecaster_Reg") // debug function
4545
protected val reg = new REGRESSION (x, y, fname, hparam) // delegate training to regression
4646
protected val nneg = hparam("nneg").toInt == 1 // 0 => unrestricted, 1 => predictions must be non-negative
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)