SELECT day, sales,
PREDICTION(ts_model USING LAG(sales,1) OVER (ORDER BY day) as l1, LAG(sales,2) OVER (ORDER BY day) as l2, LAG(sales,3) OVER (ORDER BY day) as l3, LAG(sales,4) OVER (ORDER BY day) as l4, LAG(sales,5) OVER (ORDER BY day) as l5, LAG(sales,6) OVER (ORDER BY day) as l6, LAG(sales,7) OVER (ORDER BY day) as l7 ) pred FROM ts_data a; |
SELECT d day, s sales, p pred
FROM ts_data a MODEL DIMENSION BY (day d) MEASURES (sales s, CAST(NULL AS NUMBER) p) RULES( p[FOR d FROM 1 TO 14 INCREMENT 1] = PREDICTION(ts_model USING NVL(s[CV()-1], p[CV()-1]) as l1, NVL(s[CV()-2], p[CV()-2]) as l2, NVL(s[CV()-3], p[CV()-3]) as l3, NVL(s[CV()-4], p[CV()-4]) as l4, NVL(s[CV()-5], p[CV()-5]) as l5, NVL(s[CV()-6], p[CV()-6]) as l6, NVL(s[CV()-7], p[CV()-7]) as l7) ) ORDER BY d |
SELECT d day, s sales, p pred FROM ts_data a MODEL DIMENSION BY (day d) MEASURES (sales s, CAST(NULL AS NUMBER) ap, CAST(NULL AS NUMBER) p) RULES( ap [FOR d FROM 1 TO 7 INCREMENT 1] = s[CV()], p[FOR d FROM 1 TO 14 INCREMENT 1] = PREDICTION(ts_model USING NVL(ap[CV()-1], p[CV()-1]) as l1, NVL(ap[CV()-2], p[CV()-2]) as l2, NVL(ap[CV()-3], p[CV()-3]) as l3, NVL(ap[CV()-4], p[CV()-4]) as l4, NVL(ap[CV()-5], p[CV()-5]) as l5, NVL(ap[CV()-6], p[CV()-6]) as l6, NVL(ap[CV()-7], p[CV()-7]) as l7) ) ORDER BY d |
SELECT d day, s sales, p pred FROM ts_data a MODEL DIMENSION BY (day d) MEASURES (sales s, CAST(NULL AS NUMBER) ts, CAST(NULL AS NUMBER) tp, CAST(NULL AS NUMBER) np, CAST(NULL AS NUMBER) dp, CAST(NULL AS NUMBER) p) RULES( ts[FOR d FROM 1 TO 14 INCREMENT 1] = (LOG(10,s[CV()]) - LOG(10,s[CV()-1]) + 0.010578734)/0.193587249 , tp[FOR d FROM 1 TO 14 INCREMENT 1] = PREDICTION(ts_model USING NVL(ts[CV()-1], tp[CV()-1]) as l1, NVL(ts[CV()-2], tp[CV()-2]) as l2, NVL(ts[CV()-3], tp[CV()-3]) as l3, NVL(ts[CV()-4], tp[CV()-4]) as l4, NVL(ts[CV()-5], tp[CV()-5]) as l5, NVL(ts[CV()-6], tp[CV()-6]) as l6, NVL(ts[CV()-7], tp[CV()-7]) as l7), np[FOR d FROM 1 TO 14 INCREMENT 1] = 0.193587249 * tp[CV()] - 0.010578734 , dp[FOR d FROM 1 TO 14 INCREMENT 1] = np[CV()] + NVL(LOG(10,s[CV()-1]),dp[CV()-1]) , p[FOR d FROM 1 TO 14 INCREMENT 1] = POWER(10,dp[CV()]) ) ORDER BY d |
SELECT d day, s sales, p pred FROM ts_data a MODEL DIMENSION BY (day d) MEASURES (sales s, CAST(NULL AS NUMBER) ap, CAST(NULL AS NUMBER) ts, CAST(NULL AS NUMBER) tp, CAST(NULL AS NUMBER) np, CAST(NULL AS NUMBER) dp, CAST(NULL AS NUMBER) p) RULES( ap [FOR d FROM 1 TO 7 INCREMENT 1] = s[CV()], ts[FOR d FROM 1 TO 14 INCREMENT 1] = (LOG(10,ap[CV()]) - LOG(10,ap[CV()-1]) + 0.010578734)/0.193587249, tp[FOR d FROM 1 TO 14 INCREMENT 1] = PREDICTION(ts_model USING NVL(ts[CV()-1], tp[CV()-1]) as l1, NVL(ts[CV()-2], tp[CV()-2]) as l2, NVL(ts[CV()-3], tp[CV()-3]) as l3, NVL(ts[CV()-4], tp[CV()-4]) as l4, NVL(ts[CV()-5], tp[CV()-5]) as l5, NVL(ts[CV()-6], tp[CV()-6]) as l6, NVL(ts[CV()-7], tp[CV()-7]) as l7), np[FOR d FROM 1 TO 14 INCREMENT 1] = 0.193587249 * tp[CV()] - 0.010578734, dp[FOR d FROM 1 TO 14 INCREMENT 1] = np[CV()] + NVL(LOG(10,ap[CV()-1]),dp[CV()-1]), p[FOR d FROM 1 TO 14 INCREMENT 1] = POWER(10,dp[CV()]) ) ORDER BY d |
SELECT m month, p passengers, pred FROM airline a MODEL DIMENSION BY (month m) MEASURES (a.passengers p, CAST(NULL AS NUMBER) ap, CAST(NULL AS NUMBER) tp, CAST(NULL AS NUMBER) tpred, CAST(NULL AS NUMBER) npred, CAST(NULL AS NUMBER) dpred, CAST(NULL AS NUMBER) pred) RULES( ap [FOR m FROM 1 TO 131 INCREMENT 1] = p[CV()], tp[FOR m FROM 1 TO 131 INCREMENT 1] = (LOG(10,ap[CV()]) - LOG(10,ap[CV()-1]) - 0.003919158)/0.046271162, tpred[FOR m FROM 1 TO 144 INCREMENT 1] = PREDICTION(airline_SVM USING NVL(tp[CV()-1],tpred[CV()-1]) as l1, NVL(tp[CV()-2],tpred[CV()-2]) as l2, NVL(tp[CV()-3],tpred[CV()-3]) as l3, NVL(tp[CV()-4],tpred[CV()-4]) as l4, NVL(tp[CV()-5],tpred[CV()-5]) as l5, NVL(tp[CV()-6],tpred[CV()-6]) as l6, NVL(tp[CV()-7],tpred[CV()-7]) as l7, NVL(tp[CV()-8],tpred[CV()-8]) as l8, NVL(tp[CV()-9],tpred[CV()-9]) as l9, NVL(tp[CV()-10],tpred[CV()-10]) as l10, NVL(tp[CV()-11],tpred[CV()-11]) as l11, NVL(tp[CV()-12],tpred[CV()-12]) as l12), npred[FOR m FROM 1 TO 144 INCREMENT 1] = 0.003919158 + 0.046271162 * tpred[CV()], dpred[FOR m FROM 1 TO 144 INCREMENT 1] = npred[CV()] + NVL(LOG(10,p[CV()-1]),dpred[CV()-1]), pred[FOR m FROM 1 TO 144 INCREMENT 1] = POWER(10,dpred[CV()]) ) ORDER BY m; |
Model
|
RMSE Training
|
MAE Training
|
RMSE Test
|
MAE Test
|
SVM (one-step)
|
3.7
|
3.2
|
18.9
|
13.4
|
AR (one-step)
|
10.1
|
7.7
|
19.3
|
15.2
|
SVM (multi-step)
|
3.7
|
3.2
|
11.5
|
9.3
|
CREATE VIEW load_norm AS SELECT day_id, day, max_load, holiday, day_week, (max_load-464)/(876-464) tl FROM load_all |
BEGIN xcorr(p_in_table=> 'load_norm', p_out_table => 'my_corr', p_seq_col => 'day_id', p_base_col=> 'tl', p_lag_col => 'tl', p_max_lag => 20); END; / |
CREATE VIEW load_lag as SELECT day_id, day, max_load, tl, holiday, day_week, LAG(tl, 1)OVER (ORDER BY day) L1, LAG(tl, 2)OVER (ORDER BY day) L2, LAG(tl, 3)OVER (ORDER BY day) L3, LAG(tl, 4)OVER (ORDER BY day) L4, LAG(tl, 5)OVER (ORDER BY day) L5, LAG(tl, 6)OVER (ORDER BY day) L6, LAG(tl, 7)OVER (ORDER BY day) L7 FROM load_norm |
CREATE VIEW load_train AS SELECT day_id, day, max_load, tl, holiday, day_week, L1, L2, L3, L4, L5, L6, L7 FROM load_lag WHERE day_id < 731 and day_id > 7; |
BEGIN DBMS_DATA_MINING.CREATE_MODEL( model_name => 'load_SVM', mining_function => dbms_data_mining.regression, data_table_name => 'load_train', case_id_column_name => 'day_id', target_column_name=> 'tl'); END; |
SELECT m day_id, p max_load, pred FROM load_all a MODEL DIMENSION BY (day_id m) MEASURES (a.max_load p, a.day_week dw, a.holiday h, CAST(NULL AS NUMBER) ap, CAST(NULL AS NUMBER) tp, CAST(NULL AS NUMBER) tpred, CAST(NULL AS NUMBER) pred) RULES( ap [FOR m FROM 1 TO 730 INCREMENT 1] = p[CV()], h[FOR m FROM 731 TO 761 INCREMENT 1] = 0, tp[FOR m FROM 1 TO 730 INCREMENT 1] = (ap[CV()] - 464)/(876-464), tpred[FOR m FROM 1 TO 761 INCREMENT 1] = PREDICTION(load_SVM USING NVL(tp[CV()-1],tpred[CV()-1]) as l1, NVL(tp[CV()-2],tpred[CV()-2]) as l2, NVL(tp[CV()-3],tpred[CV()-3]) as l3, NVL(tp[CV()-4],tpred[CV()-4]) as l4, NVL(tp[CV()-5],tpred[CV()-5]) as l5, NVL(tp[CV()-6],tpred[CV()-6]) as l6, NVL(tp[CV()-7],tpred[CV()-7]) as l7, dw[CV()] as day_week, h[CV()] as holiday ), pred[FOR m FROM 1 TO 761 INCREMENT 1] = 464 + (876-464) * tpred[CV()] ) ORDER BY m; |
Model
|
MAPE Training
|
MAX Load Error Training
|
MAPE Test
|
MAX Load Error Test
|
SVM (one-step)
|
2.2
|
77.4
|
1.7
|
39.1
|
SVM (multi-step)
|
2.2
|
77.0
|
1.9
|
50.4
|