Download index.html from bardd/water: direct link, hf CLI and curl.
- Browser
- Download file 50.4 kB
-
https://huggingface.co/spaces/bardd/water/resolve/main/index.html
- Command line
-
hf download hf://spaces/bardd/water/index.html
-
curl -L -o index.html https://huggingface.co/spaces/bardd/water/resolve/main/index.html
50.4 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <meta name="description" content="A five-minute visual briefing on forecasting bottled-water sales in Oman with Timestral and LightGBM."> | |
| <title>Predicting Water Demand More Accurately</title> | |
| <style> | |
| :root { --paper:#f9faf8;--white:#fff;--ink:#102740;--muted:#516476;--line:#dce5e9;--blue:#386bd7;--teal:#087e78;--red:#c34853;--amber:#ad6700;--soft-blue:#eaf0ff;--soft-teal:#e5f4f1;--soft-red:#fcebed;--soft-amber:#fff1db;--navy:#0b2944;--shadow:0 15px 45px rgba(16,39,64,.06);--sans:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;--serif:"Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif; } | |
| *{box-sizing:border-box} html{scroll-behavior:smooth} body{margin:0;background:var(--paper);color:var(--ink);font:16px/1.65 var(--sans)} svg{display:block;width:100%;height:auto} svg text{font-family:var(--sans)} .wrap{width:min(1080px,calc(100% - 48px));margin-inline:auto} p{margin:0 0 15px} h1,h2,h3{margin:0} h2{font:normal clamp(2.1rem,4.1vw,3.25rem)/1.13 var(--serif);letter-spacing:-.045em} h3{font-size:clamp(1.11rem,1.7vw,1.35rem);line-height:1.3;letter-spacing:-.02em} .kicker{margin:0 0 13px;font-size:11px;font-weight:850;letter-spacing:.18em;text-transform:uppercase;color:var(--teal)} .sub{color:var(--muted);font-size:clamp(16px,2vw,19px);max-width:650px;line-height:1.62} .small{font-size:13px;color:var(--muted);line-height:1.6} .tiny{font-size:11px;color:var(--muted);line-height:1.55} .num{font-variant-numeric:tabular-nums} .teal{color:var(--teal)} .blue{color:var(--blue)} .red{color:var(--red)} .amber{color:var(--amber)} .sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap} | |
| .mast{padding:21px 0;border-bottom:1px solid var(--line);background:var(--white)} .mast .wrap{display:flex;justify-content:space-between;align-items:center;gap:15px}.brand{font-size:11px;font-weight:900;letter-spacing:.15em;text-transform:uppercase;color:var(--navy)}.brand:before{content:"≈";display:inline-grid;place-items:center;margin-right:10px;width:27px;height:27px;border-radius:9px;background:var(--teal);color:white;font-size:18px;vertical-align:-7px}.mast .small{margin:0;font-size:11px} | |
| .hero{padding:clamp(58px,9vw,116px) 0 74px;background:radial-gradient(circle at 93% 6%,#d7f0ea 0%,transparent 34%),var(--paper)}.hero h1{font:normal clamp(3rem,7vw,5.65rem)/1.03 var(--serif);letter-spacing:-.06em;max-width:900px;margin:0 0 21px;text-wrap:balance}.hero h1 em{font-style:normal;color:var(--teal)}.hero-grid{display:grid;grid-template-columns:1fr 1.15fr;align-items:center;gap:55px;margin-top:45px}.hero-copy p{font-size:16px}.tag{display:inline-flex;align-items:center;gap:8px;padding:7px 11px;border-radius:99px;background:var(--soft-teal);color:var(--teal);font-size:11px;font-weight:800}.tag:before{content:"";width:7px;height:7px;background:currentColor;border-radius:50%}.hero-note{margin:20px 0 0;font-size:13px;color:var(--muted)}.figure{background:var(--white);border:1px solid var(--line);border-radius:19px;padding:clamp(19px,3vw,31px);box-shadow:var(--shadow);min-width:0}.figure-title{font-size:11px;text-transform:uppercase;letter-spacing:.13em;color:var(--muted);font-weight:800;margin:0 0 14px}.caption{font-size:12px;line-height:1.6;color:var(--muted);margin:13px 0 0}.section{padding:clamp(69px,8vw,108px) 0;border-top:1px solid var(--line)}.section.alt{background:var(--white)}.section .lead{max-width:820px;color:var(--muted);font-size:17px;margin:17px 0 31px}.section-head{margin-bottom:30px}.section-head h2{max-width:820px}.cols{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}.cols-3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}.panel{background:var(--white);border:1px solid var(--line);border-radius:17px;padding:24px;min-width:0}.alt .panel{background:#f8faf9}.panel p:last-child{margin-bottom:0}.notebox{padding:16px 19px;border-radius:12px;background:var(--soft-amber);font-size:13px;line-height:1.65;color:var(--ink)}.notebox strong{color:var(--amber)}.gridline{border-top:1px solid var(--line);margin:24px 0}.pill{display:inline-block;font-size:10px;letter-spacing:.11em;font-weight:850;text-transform:uppercase;padding:5px 8px;border-radius:5px;background:var(--soft-teal);color:var(--teal)}.pill.blue{background:var(--soft-blue);color:var(--blue)}.formula{display:inline-block;padding:12px 17px;background:var(--soft-teal);border-radius:9px;color:var(--teal);font-weight:850;font-variant-numeric:tabular-nums}.big-number{display:block;font-size:clamp(36px,5vw,62px);letter-spacing:-.06em;line-height:1.1;font-weight:830;font-variant-numeric:tabular-nums}.stat-row{display:flex;flex-wrap:wrap;gap:12px}.stat{flex:1 1 155px;border:1px solid var(--line);border-radius:13px;padding:16px 18px;background:var(--white)}.stat strong{display:block;font-size:clamp(23px,3vw,35px);letter-spacing:-.055em;line-height:1.12;font-variant-numeric:tabular-nums}.stat span{display:block;font-size:11px;color:var(--muted);line-height:1.4;margin-top:8px} | |
| .model{padding:25px;min-width:0;border-radius:18px;border:1px solid var(--line);background:var(--white);box-shadow:var(--shadow)}.model p{font-size:14px;color:var(--muted);line-height:1.65}.model h3{margin:13px 0 9px}.model svg{margin:19px 0 12px}.model .signal{font-size:12px;line-height:1.55;color:var(--ink);border-radius:9px;padding:11px 13px;background:var(--soft-blue);font-weight:700}.model.timestral .signal{background:var(--soft-teal)}.tensor-note{margin-top:20px;background:var(--navy);color:#e3eff2;border-radius:17px;padding:21px 25px;display:flex;justify-content:space-between;align-items:center;gap:24px}.tensor-note strong{font-size:15px}.tensor-note code{color:#9debdc;font-size:12px;overflow-wrap:anywhere}.tensor-note p{margin:5px 0 0;color:#cad8df;font-size:12px}.tensor-note .context{flex:0 0 auto;color:#a2eee0;text-align:right;font-weight:850;font-size:22px;font-variant-numeric:tabular-nums;letter-spacing:-.045em} | |
| .calendar-box{padding:21px 25px}.calendar-box svg{max-height:390px}.teach-row{display:flex;flex-wrap:wrap;gap:14px;margin:20px 0 0}.teach-row>*{flex:1 1 230px}.teach-row .panel{background:var(--soft-teal);border:0}.teach-row .panel:last-child{background:var(--soft-amber)}.teach-row strong{display:block;margin:4px 0 5px}.worked{display:flex;align-items:baseline;flex-wrap:wrap;gap:7px;font-size:17px;font-weight:800;letter-spacing:-.02em;font-variant-numeric:tabular-nums}.worked strong{color:var(--teal);font-size:24px}.vs-table{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums}.vs-table th,.vs-table td{text-align:right;padding:13px 14px;border-bottom:1px solid var(--line);font-size:14px}.vs-table th{font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);font-weight:800}.vs-table tr:last-child td{border:0}.vs-table th:first-child,.vs-table td:first-child{text-align:left}.vs-table .selected{background:var(--soft-teal)}.vs-table td:first-child{font-weight:800}.table-outer{overflow-x:auto;border:1px solid var(--line);border-radius:13px}.table-outer table{min-width:530px}.chart-grid{display:grid;gap:15px}.chart-card{border:1px solid var(--line);background:var(--white);border-radius:15px;padding:20px 24px;min-width:0}.chart-card h3{margin:0 0 5px}.chart-card svg{margin-top:9px}.chart-card .small{margin:0}.comparison-foot{display:flex;align-items:center;gap:12px;margin-top:18px}.comparison-foot strong{font-size:25px;color:var(--teal);white-space:nowrap;font-variant-numeric:tabular-nums}.comparison-foot span{font-size:13px;color:var(--muted)}.legend{display:flex;gap:17px;flex-wrap:wrap;font-size:11px;color:var(--muted)}.legend i{display:inline-block;width:16px;height:3px;margin-right:6px;vertical-align:3px;border-radius:2px}.sample{margin-top:22px}.sample svg{margin-top:14px}.sample .caption{margin-top:6px} | |
| .million{background:#0d2944;color:#f5fbfb}.million .kicker{color:#7fe0d0}.million .lead,.million .caption{color:#c1d3da}.million .figure{background:#173650;border-color:#36546b;box-shadow:none}.million .formula{background:#254f55;color:#a9f0de}.million .figure-title{color:#bdd5df}.million .notebox{margin-top:19px;background:#314351;color:#f5eee3}.million .notebox strong{color:#ffcb79}.million .spotlight{font:normal clamp(26px,4vw,44px)/1.16 var(--serif);letter-spacing:-.04em;margin:3px 0 18px;color:#adf4dd}.million .cols{margin-top:20px}.million .panel{background:#173650;border-color:#36546b}.million .panel p{color:#e2ecee}.million .panel .small{color:#c3d5db}.million .panel strong{color:#a9f0de}.million .panel h3{margin-bottom:7px}.million .numbers{font-size:13px;color:#d3e1e4;font-variant-numeric:tabular-nums} | |
| .bias-layout{display:grid;grid-template-columns:1fr 1.1fr;gap:22px;align-items:stretch}.bias-layout .figure{box-shadow:none}.bias-layout .figure svg{max-height:350px}.tradeoff{margin-top:22px}.tradeoff svg{max-height:345px}.tradeoff .caption{margin-top:4px}.p50p60{margin:0 0 18px}.p50p60 .panel{box-shadow:none}.p50p60 .panel p{margin:9px 0 0}.plain-math{font-size:12px;color:var(--muted);line-height:1.65;margin-top:17px}.decision{background:radial-gradient(circle at 85% 10%,#d8f2eb 0,transparent 40%),var(--paper)}.decision .cols{margin-bottom:25px}.decision .panel{box-shadow:var(--shadow);background:var(--white)}.decision .panel h3{margin:11px 0 5px}.decision .panel p{font-size:14px;color:var(--muted)}.decision .panel.main{border-color:#9bd8c9;background:var(--soft-teal)}.decision .panel.main p{color:#315d5e}.decision .figure{padding:21px 26px}.decision .figure svg{max-height:155px}.footer{padding:26px 0 36px;background:#10283f;color:#cfdbdf;font-size:12px}.footer .wrap{display:flex;align-items:flex-start;justify-content:space-between;gap:25px}.footer p{max-width:710px;margin:0}.footer strong{color:white} | |
| .mobile-illustration,.mobile-scores{display:none}.mobile-scores{gap:9px}.mobile-scores article{background:var(--white);border:1px solid var(--line);border-radius:12px;padding:14px 16px}.mobile-scores article:nth-child(2){background:var(--soft-teal)}.mobile-scores strong{display:block;margin-bottom:8px;font-size:14px}.mobile-scores dl{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin:0}.mobile-scores dt{font-size:9px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);font-weight:750}.mobile-scores dd{font-size:14px;font-variant-numeric:tabular-nums;font-weight:850;margin:0} | |
| @media(max-width:780px){.hero-grid,.bias-layout{grid-template-columns:1fr;gap:22px}.model{grid-column:1/-1}.hero{padding-bottom:64px}.tensor-note{flex-direction:column;align-items:start;gap:9px}.tensor-note .context{text-align:left}.footer .wrap{display:block}.footer .brand{margin-bottom:12px}}@media(max-width:620px){.wrap{width:calc(100% - 32px)}.mast .small{display:none}.hero{padding-top:63px}.hero h1{font-size:clamp(43px,13vw,67px)}.section{padding:68px 0}.cols,.cols-3{grid-template-columns:1fr}.model{padding:20px}.figure{padding:17px}.calendar-box{padding:17px}.vs-table th,.vs-table td{padding:12px 10px;font-size:12px}.table-outer{display:none}.mobile-scores{display:grid}.chart-card{padding:17px}.stat{flex-basis:130px}.million .panel{padding:20px}.hero-grid .figure>svg:not(.mobile-illustration),.model>svg:not(.mobile-illustration),.decision .figure>svg:not(.mobile-illustration){display:none}.mobile-illustration{display:block}.decision .figure svg{max-height:none}.footer{line-height:1.6}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation:none!important;transition:none!important}}@media print{@page{size:A4;margin:13mm}html,body{background:#fff!important;color:#102740!important;font-size:10pt}.wrap{width:100%}.mast{padding:6px 0}.mast .small{display:none}.hero{padding:24px 0 27px;background:white!important}.hero h1{font-size:34pt}.hero-grid{gap:18px;margin-top:19px}.section{padding:22px 0;break-inside:auto}.section-head{margin-bottom:13px}.section-head h2{font-size:25pt}.model,.figure,.panel,.chart-card,.tensor-note{box-shadow:none!important;break-inside:avoid}.million{background:white!important;color:#102740!important}.million .figure,.million .panel{background:white!important;color:#102740!important;border-color:#c1cdd1}.million .spotlight,.million .panel strong{color:#087e78!important}.million .lead,.million .caption,.million .panel p,.million .panel .small,.million .numbers{color:#516476!important}.million .kicker{color:#087e78}.million .figure-title{color:#516476}#million-chart svg text{fill:#102740!important}.million .notebox{background:#fff1db;color:#102740}.million .notebox strong{color:#855200!important}.footer{padding:15px 0;break-inside:avoid}.decision{background:white!important}svg{max-height:235px}.chart-card svg{max-height:160px}.calendar-box svg{max-height:230px}.model svg{max-height:132px}.sample{break-inside:avoid}} | |
| </style> | |
| </head> | |
| <body> | |
| <header class="mast"><div class="wrap"><span class="brand">Oman / Forecasting Brief</span><p class="small">A five-minute decision document</p></div></header> | |
| <main> | |
| <section class="hero" aria-labelledby="title"><div class="wrap"> | |
| <p class="kicker">01 / The business problem</p> | |
| <h1 id="title">Predicting Water Demand <em>More Accurately</em></h1> | |
| <p class="sub">Comparing LightGBM with Timestral to improve daily and weekly sales forecasting.</p> | |
| <div class="hero-grid"> | |
| <div class="hero-copy"><span class="tag">5 major Oman regions × 2 products = 10 sales series</span><p style="margin-top:19px">For each region and bottle size (200ML or 330ML), we estimate the next 28 days of recorded sales. The factory can use that forward view to anticipate demand and reduce the risk of planning for too little.</p><p class="hero-note">Forecasts help planning. We cannot claim fewer actual stock-outs: historical stock records were not available.</p></div> | |
| <div class="figure"><p class="figure-title">The idea in one picture</p><svg viewBox="0 0 550 236" role="img" aria-label="Historical recorded sales pass through a forecasting model and become daily forecasts and weekly totals"><title>Historical sales become forecasts</title><defs><linearGradient id="pipe-g" x1="0" x2="1"><stop stop-color="#e5f4f1"/><stop offset="1" stop-color="#eaf0ff"/></linearGradient></defs><rect width="550" height="236" rx="15" fill="url(#pipe-g)"/><g stroke="#92a7af" stroke-width="2" fill="none"><path d="M159 111h36m146 0h32"/><path d="M188 105l7 6-7 6m178-12 7 6-7 6"/></g><rect x="18" y="62" width="141" height="98" rx="13" fill="white" stroke="#bad9d0"/><text x="88" y="91" text-anchor="middle" fill="#087e78" font-size="11" font-weight="850">HISTORY</text><path d="M31 129l13-13 13 6 11-27 14 22 13-11 15 10 14-24 19 17" fill="none" stroke="#087e78" stroke-width="2.6"/><rect x="199" y="62" width="143" height="98" rx="13" fill="#102740"/><text x="270" y="108" text-anchor="middle" fill="white" font-size="14" font-weight="800">Forecasting</text><text x="270" y="131" text-anchor="middle" fill="#a7e9db" font-size="12">LightGBM / Timestral</text><rect x="377" y="51" width="155" height="55" rx="12" fill="white" stroke="#bad9d0"/><rect x="377" y="118" width="155" height="55" rx="12" fill="white" stroke="#bad9d0"/><text x="454" y="76" text-anchor="middle" fill="#087e78" font-size="14" font-weight="850">28 days</text><text x="454" y="145" text-anchor="middle" fill="#087e78" font-size="14" font-weight="850">4 weeks</text><text x="275" y="210" text-anchor="middle" fill="#516476" font-size="12">One forecast origin · ten region–product series</text></svg></div> | |
| </div> | |
| </div></section> | |
| <section class="section alt" aria-labelledby="models-title"><div class="wrap"> | |
| <div class="section-head"><p class="kicker">02 / How the forecast is made</p><h2 id="models-title">Two different ways to read sales history.</h2><p class="lead">Both models start with past recorded sales and produce the next 28 daily estimates for each of the ten series. Neither gets to see future actual sales when making the forecast.</p></div> | |
| <div class="cols"> | |
| <article class="model"><span class="pill blue">Trained on local history</span><h3 class="blue">LightGBM</h3><p>Learns from the factory’s past sales: recent sales, lagged values, region, product and calendar patterns. Its latest design also learns how a weekly level is distributed across days.</p><svg viewBox="0 0 450 175" role="img" aria-label="Historical sales and calendar features enter trained LightGBM trees; a weekly level and daily-share layer produce 28 daily forecasts"><title>LightGBM forecasting architecture</title><rect x="5" y="34" width="130" height="108" rx="12" fill="#eaf0ff"/><text x="70" y="67" text-anchor="middle" fill="#2756bb" font-size="11" font-weight="850">PAST SALES</text><text x="70" y="90" text-anchor="middle" fill="#102740" font-size="12">Lags · weekday</text><text x="70" y="113" text-anchor="middle" fill="#102740" font-size="12">Region · product</text><path d="M136 88h28m-6-5 7 5-7 5M293 88h25m-6-5 7 5-7 5" stroke="#8196af" stroke-width="2" fill="none"/><rect x="166" y="34" width="128" height="108" rx="12" fill="#386bd7"/><text x="230" y="69" text-anchor="middle" fill="white" font-size="15" font-weight="850">Trained trees</text><text x="230" y="94" text-anchor="middle" fill="#dfe9ff" font-size="11">Weekly demand</text><text x="230" y="115" text-anchor="middle" fill="#dfe9ff" font-size="11">+ daily shares</text><rect x="321" y="34" width="124" height="108" rx="12" fill="#eaf0ff"/><text x="383" y="80" text-anchor="middle" fill="#2756bb" font-size="13" font-weight="850">10 × 28</text><text x="383" y="105" text-anchor="middle" fill="#102740" font-size="12">daily forecasts</text><text x="225" y="165" text-anchor="middle" fill="#516476" font-size="11">Seven daily shares sum to each weekly level</text></svg><div class="signal">Local training learns the factory’s sales patterns.</div></article> | |
| <article class="model timestral"><span class="pill">Pretrained; no local fine-tuning</span><h3 class="teal">Timestral-209M</h3><p>A pretrained time-series model. We pass in ten historical daily sales sequences together; its weights are not fine-tuned on our Oman data. One forecast cutoff produces 28 future days per series, including P50 and P60 estimates.</p><svg viewBox="0 0 450 175" role="img" aria-label="Ten historical sales sequences enter pretrained Timestral-209M and produce 28 future days per series including P50 and P60"><title>Timestral forecasting architecture</title><g stroke="#79c5b9" fill="#e5f4f1"><rect x="7" y="32" width="121" height="93" rx="9"/><rect x="14" y="40" width="121" height="93" rx="9"/><rect x="21" y="48" width="121" height="93" rx="9"/></g><text x="82" y="91" fill="#087e78" text-anchor="middle" font-size="13" font-weight="850">10 histories</text><path d="M144 88h21m-7-5 7 5-7 5M295 88h22m-7-5 7 5-7 5" stroke="#8196af" stroke-width="2" fill="none"/><rect x="167" y="34" width="128" height="108" rx="12" fill="#087e78"/><text x="231" y="73" text-anchor="middle" fill="white" font-size="15" font-weight="850">Timestral</text><text x="231" y="98" text-anchor="middle" fill="#d6f8ee" font-size="12">209M · pretrained</text><text x="231" y="118" text-anchor="middle" fill="#d6f8ee" font-size="11">weights unchanged</text><rect x="320" y="34" width="125" height="108" rx="12" fill="#e5f4f1"/><text x="382" y="76" text-anchor="middle" fill="#087e78" font-size="13" font-weight="850">10 × 28 days</text><text x="382" y="103" text-anchor="middle" fill="#102740" font-size="12">P50 + P60</text><text x="225" y="165" text-anchor="middle" fill="#516476" font-size="11">All 28 days forecast from the same cutoff</text></svg><div class="signal">Frozen pretrained model, applied to our historical sales.</div></article> | |
| </div> | |
| <div class="tensor-note"><div><strong>What Timestral actually receives</strong><p>One batch × ten series × the available historical days. Nothing from after the forecast cutoff is included.</p><code id="tensor-shape">—</code></div><div class="context"><span id="context-range">—</span><span style="display:block;color:#cbdae0;font-size:11px;font-weight:650;letter-spacing:0">days of context across matched origins</span></div></div> | |
| </div></section> | |
| <section class="section" aria-labelledby="calendar-title"><div class="wrap"> | |
| <div class="section-head"><p class="kicker">03 / From days to weeks</p><h2 id="calendar-title">Forecast 28 days. Add them in groups of seven.</h2><p class="lead">Days 1–7 become Week 1; Days 8–14 become Week 2; Days 15–21 become Week 3; Days 22–28 become Week 4. Each model predicts all 28 days from the same starting point.</p></div> | |
| <div class="figure calendar-box"><p class="figure-title">One product in one region · 28 future days</p><div id="calendar" aria-label="Four rows of seven daily forecast tiles, each row adding to one weekly forecast"></div><p class="caption">Four rows × seven days = four weekly forecast totals. This happens separately for each of the ten region–product series.</p></div> | |
| <div class="teach-row"><div class="panel"><span class="pill">Illustrative seven-day example</span><p class="worked" style="margin-top:10px">100 + 120 + 105 + 90 + 80 + 115 + 110 <strong>= 720 units</strong></p><p class="tiny">These teaching values are invented; the benchmark comparisons below use saved historical forecasts.</p></div><div class="panel"><span class="pill" style="background:#fff1db;color:#ad6700">Why weekly error can be smaller</span><p style="margin:9px 0 0;font-size:13px">Actual 100 + 200; predicted 150 + 150. Daily errors total 100 units, but both weekly totals are 300: weekly error is zero. Opposite daily misses can cancel after aggregation.</p></div></div> | |
| </div></section> | |
| <section class="section alt" aria-labelledby="accuracy-title"><div class="wrap"> | |
| <div class="section-head"><p class="kicker">04 / The matched comparison</p><h2 id="accuracy-title">Timestral makes the smaller absolute error.</h2><p class="lead">Same actual sales, ten series and 13 non-overlapping historical 2024 forecast starts for each model. <strong>WAPE</strong> means total absolute forecast error divided by total recorded sales. Lower is better.</p></div> | |
| <div class="table-outer"><table class="vs-table" aria-label="Matched daily and weekly WAPE and signed bias for LightGBM, Timestral P50 and Timestral P60"><thead><tr><th>Forecast</th><th>Daily WAPE ↓</th><th>Weekly WAPE ↓</th><th>Signed bias</th></tr></thead><tbody id="scores-table"></tbody></table></div> | |
| <div id="mobile-scores" class="mobile-scores" aria-label="Matched daily WAPE, weekly WAPE and signed bias by forecast"></div> | |
| <div class="chart-grid" style="margin-top:19px"><div class="chart-card"><h3>Daily forecasting error</h3><p class="small">Total daily absolute error ÷ total recorded sales</p><div id="daily-chart"></div></div><div class="chart-card"><h3>Weekly forecasting error</h3><p class="small">Sum seven days first; then measure weekly absolute error</p><div id="weekly-chart"></div></div></div> | |
| <div class="comparison-foot"><strong id="weekly-reduction">—</strong><span>less weekly absolute error for Timestral P50 versus LightGBM; the relative reduction in daily error is <b id="daily-reduction" class="teal">—</b>. These are reductions relative to LightGBM’s error, not percentage-point changes.</span></div> | |
| <div class="figure sample"><p class="figure-title">One real historical forecast · selected near the typical error level</p><div class="legend"><span><i style="background:#102740"></i>Actual sales</span><span><i style="background:#386bd7"></i>LightGBM</span><span><i style="background:#087e78"></i>Timestral P50</span></div><div id="example-chart"></div><p class="caption" id="example-caption">—</p></div> | |
| <p class="small" style="margin-top:17px">P60 keeps similar measured daily and weekly WAPE, but shifts the forecast upward. These are historical comparisons, not guaranteed future performance.</p> | |
| </div></section> | |
| <section class="section million" aria-labelledby="million-title"><div class="wrap"> | |
| <div class="section-head"><p class="kicker">05 / Put the errors in business units</p><h2 id="million-title">Imagine 1,000,000 actual sales units.</h2><p class="lead">Scale the measured error rates to an easy-to-read, hypothetical volume. This is <strong>not</strong> a claim that the factory sold exactly one million units.</p></div> | |
| <div class="formula">Absolute forecast error = actual sales × WAPE</div> | |
| <div class="cols" style="margin-top:21px"><div class="panel"><h3>Weekly absolute forecast error</h3><div class="numbers">LightGBM <b id="million-week-l">—</b> · Timestral P50 <b id="million-week-t">—</b></div><div class="gridline"></div><p class="spotlight"><span id="million-week-gap">—</span> fewer error units</p><p class="small">Cumulative absolute error measured after forecasts are added into weeks.</p></div><div class="panel"><h3>Daily absolute forecast error</h3><div class="numbers">LightGBM <b id="million-day-l">—</b> · Timestral P50 <b id="million-day-t">—</b></div><div class="gridline"></div><p class="spotlight"><span id="million-day-gap">—</span> fewer error units</p><p class="small">Cumulative absolute error measured before weekly aggregation.</p></div></div> | |
| <div class="figure" style="margin-top:20px"><p class="figure-title">Same illustrative sales volume · two different error resolutions</p><div id="million-chart"></div><p class="caption">Bar lengths represent cumulative absolute forecast deviations in sales units. Weekly and daily errors are different ways of scoring the same forecasts, not volumes to add together.</p></div> | |
| <div class="notebox"><strong>What this does not mean.</strong> Fewer forecast-error units do not automatically equal saved inventory, avoided waste, extra sales or financial savings. Those claims require real stock and operating data.</div> | |
| </div></section> | |
| <section class="section alt" aria-labelledby="bias-title"><div class="wrap"> | |
| <div class="section-head"><p class="kicker">06 / Choosing the right forecast level</p><h2 id="bias-title">P50 is central. P60 leans slightly higher.</h2><p class="lead">P50 is the model’s median estimate, and the best central forecast here. P60 is its 60th percentile — <strong>not</strong> “60% more demand” — and trades fewer underforecast deviations for more overforecast deviations.</p></div> | |
| <div class="cols p50p60"><div class="panel"><span class="pill">Timestral P50</span><h3 style="margin-top:11px">Best central estimate</h3><p>Net signed bias <b id="p50-bias" class="red num">—</b> · underforecast volume <b id="p50-under" class="red num">—</b> · overforecast volume <b id="p50-over" class="amber num">—</b>.</p></div><div class="panel"><span class="pill">Timestral P60</span><h3 style="margin-top:11px">Optional modest upper estimate</h3><p>Net signed bias <b id="p60-bias" class="amber num">—</b> · underforecast volume <b id="p60-under" class="red num">—</b> · overforecast volume <b id="p60-over" class="amber num">—</b>.</p></div></div> | |
| <div class="bias-layout"><div class="figure"><p class="figure-title">Signed bias · direction of net error</p><div id="bias-chart"></div><p class="caption">Left: forecast totals below recorded sales. Right: above. P60 crosses zero into mild net overforecasting.</p></div><div class="figure"><p class="figure-title">At 1,000,000 illustrative sales units</p><span class="big-number red" id="million-under-gap">—</span><p style="margin-top:6px">fewer units of cumulative <strong>underforecast error</strong> with P60 versus P50.</p><div class="gridline"></div><span class="big-number amber" id="million-over-gap">—</span><p style="margin-top:6px">additional units of cumulative <strong>overforecast error</strong>. Both are deviations from observed sales, not physical shortages or leftovers.</p></div></div> | |
| <div class="figure tradeoff"><p class="figure-title">Where the error goes · illustrative one-million-unit scale</p><div id="tradeoff-chart"></div><p class="caption"><span class="red">■ Underforecast</span> <span class="amber">■ Overforecast</span>. Divide either deviation total by actual sales to get its percentage. The percentages add to daily WAPE; their difference is signed bias. Near-zero bias does not guarantee low absolute error.</p></div> | |
| </div></section> | |
| <section class="section decision" aria-labelledby="decision-title"><div class="wrap"> | |
| <div class="section-head"><p class="kicker">07 / The decision</p><h2 id="decision-title">Approve Timestral-209M v1 as the forecasting baseline.</h2><p class="lead">It produced the best matched central daily and weekly results among the models compared. Keep the forecast separate from the eventual decision about how much to produce.</p></div> | |
| <div class="cols"><div class="panel main"><span class="pill">Default</span><h3>P50 · expected sales view</h3><p>Use the central 28-day forecast and its four weekly totals as the starting point for demand planning.</p></div><div class="panel"><span class="pill">Optional</span><h3>P60 · moderately higher view</h3><p>Show alongside P50 when a higher estimate is useful, with its increased overforecast error made explicit. Both native levels come from the same supported Timestral inference.</p></div></div> | |
| <div class="figure"><p class="figure-title">The proposed planning flow</p><svg viewBox="0 0 960 161" role="img" aria-label="Historical daily sales flow to Timestral, then P50 and P60 daily forecasts, then four weekly totals and business planning"><title>Proposed forecasting flow</title><g fill="none" stroke="#91a9b1" stroke-width="2"><path d="M171 81h36m-7-6 7 6-7 6M342 81h36m-7-6 7 6-7 6M564 81h37m-7-6 7 6-7 6M768 81h34m-7-6 7 6-7 6"/></g><rect x="10" y="36" width="160" height="90" rx="12" fill="#eaf0ff"/><text x="90" y="73" text-anchor="middle" fill="#102740" font-size="14" font-weight="800">Historical</text><text x="90" y="97" text-anchor="middle" fill="#102740" font-size="13">daily sales</text><rect x="209" y="36" width="132" height="90" rx="12" fill="#087e78"/><text x="275" y="85" text-anchor="middle" fill="white" font-size="15" font-weight="850">Timestral</text><rect x="380" y="36" width="183" height="90" rx="12" fill="#e5f4f1"/><text x="471" y="73" text-anchor="middle" fill="#087e78" font-size="14" font-weight="850">P50 / P60</text><text x="471" y="97" text-anchor="middle" fill="#102740" font-size="12">28 daily estimates</text><rect x="603" y="36" width="164" height="90" rx="12" fill="#e5f4f1"/><text x="685" y="73" text-anchor="middle" fill="#087e78" font-size="14" font-weight="850">Four weekly</text><text x="685" y="97" text-anchor="middle" fill="#102740" font-size="12">totals per series</text><rect x="803" y="36" width="148" height="90" rx="12" fill="#102740"/><text x="877" y="73" text-anchor="middle" fill="white" font-size="14" font-weight="800">Business</text><text x="877" y="97" text-anchor="middle" fill="#bfede3" font-size="12">planning</text></svg><p class="caption">A forecast can support a planning decision. Determining an inventory-optimal production quantity requires operational information this research did not have.</p></div> | |
| </div></section> | |
| </main> | |
| <footer class="footer"><div class="wrap"><p><strong>Before operational use:</strong> Results are historical, not live-2026 validation. Friday and peak-day swings remain difficult. Actual production-quantity optimization requires stock, capacity and cost information not available here. The source’s physical sales unit is not unambiguously defined, so all volumes here are called <em>sales units</em>.</p><span class="brand" style="color:#e4eef1">Oman / Forecasting</span></div></footer> | |
| <script id="brief-data" type="application/json">{"schema":"cto-brief-five-minute/1","scope":{"regions":["CAPITAL","Batinah","Dhofar","Sharqiyah","Al Dakhiliyah"],"products":["200ML","330ML"],"series":10,"unit":"recorded sales units","origins":13,"first_target":"2024-01-08","last_target":"2025-01-05"},"input":{"shape":[1,10,"T"],"context_min":1101,"context_max":1437,"variates":10,"horizon":28},"scores":{"lightgbm":{"daily_wape_pct":20.703764,"weekly_wape_pct":11.945783,"bias_pct":-6.972449,"under_pct":13.838107,"over_pct":6.865657},"p50":{"daily_wape_pct":19.030776,"weekly_wape_pct":9.398871,"bias_pct":-3.730081,"under_pct":11.380428,"over_pct":7.650347},"p60":{"daily_wape_pct":19.08964,"weekly_wape_pct":9.402702,"bias_pct":2.215387,"under_pct":8.437127,"over_pct":10.652514}},"example":{"series":"Batinah 200ML","origin":"2024-01-07","description":"Closest P50 daily WAPE to the benchmark-wide 19.03% among series-origins with at least 30,000 actual units.","days":[{"date":"2024-01-08","weekday":"Monday","actual":837.0,"p50":1314.682129,"lightgbm":1440.400441},{"date":"2024-01-09","weekday":"Tuesday","actual":1292.0,"p50":1261.925781,"lightgbm":1399.335361},{"date":"2024-01-10","weekday":"Wednesday","actual":708.0,"p50":1358.418945,"lightgbm":1411.720002},{"date":"2024-01-11","weekday":"Thursday","actual":1498.0,"p50":1294.724976,"lightgbm":1405.822858},{"date":"2024-01-12","weekday":"Friday","actual":370.0,"p50":576.772705,"lightgbm":871.891428},{"date":"2024-01-13","weekday":"Saturday","actual":1416.0,"p50":1362.458496,"lightgbm":1464.476348},{"date":"2024-01-14","weekday":"Sunday","actual":1201.0,"p50":1462.11377,"lightgbm":1463.108153},{"date":"2024-01-15","weekday":"Monday","actual":1533.0,"p50":1426.026978,"lightgbm":1511.60372},{"date":"2024-01-16","weekday":"Tuesday","actual":1002.0,"p50":1310.449585,"lightgbm":1468.508671},{"date":"2024-01-17","weekday":"Wednesday","actual":1518.0,"p50":1386.808105,"lightgbm":1481.505522},{"date":"2024-01-18","weekday":"Thursday","actual":1323.0,"p50":1323.033203,"lightgbm":1475.316864},{"date":"2024-01-19","weekday":"Friday","actual":706.0,"p50":579.338135,"lightgbm":927.0138},{"date":"2024-01-20","weekday":"Saturday","actual":1455.0,"p50":1369.87085,"lightgbm":1536.86977},{"date":"2024-01-21","weekday":"Sunday","actual":995.0,"p50":1485.941772,"lightgbm":1535.433942},{"date":"2024-01-22","weekday":"Monday","actual":1119.0,"p50":1435.093872,"lightgbm":1401.19948},{"date":"2024-01-23","weekday":"Tuesday","actual":1326.0,"p50":1322.769043,"lightgbm":1360.89521},{"date":"2024-01-24","weekday":"Wednesday","actual":1657.0,"p50":1386.0896,"lightgbm":1373.050402},{"date":"2024-01-25","weekday":"Thursday","actual":1155.0,"p50":1304.852783,"lightgbm":1367.262514},{"date":"2024-01-26","weekday":"Friday","actual":605.0,"p50":569.923035,"lightgbm":854.466831},{"date":"2024-01-27","weekday":"Saturday","actual":1686.0,"p50":1358.609619,"lightgbm":1414.439328},{"date":"2024-01-28","weekday":"Sunday","actual":1631.0,"p50":1469.474365,"lightgbm":1423.486489},{"date":"2024-01-29","weekday":"Monday","actual":868.0,"p50":1408.252075,"lightgbm":1221.11412},{"date":"2024-01-30","weekday":"Tuesday","actual":997.0,"p50":1301.779297,"lightgbm":1185.477344},{"date":"2024-01-31","weekday":"Wednesday","actual":1352.0,"p50":1365.715088,"lightgbm":1196.224886},{"date":"2024-02-01","weekday":"Thursday","actual":1560.0,"p50":1289.769043,"lightgbm":1194.563424},{"date":"2024-02-02","weekday":"Friday","actual":540.0,"p50":566.382874,"lightgbm":747.538399},{"date":"2024-02-03","weekday":"Saturday","actual":1443.0,"p50":1347.236328,"lightgbm":1242.662481},{"date":"2024-02-04","weekday":"Sunday","actual":2313.0,"p50":1467.615479,"lightgbm":1274.069412}]}}</script> | |
| <script> | |
| (() => { | |
| 'use strict'; | |
| const $=id=>document.getElementById(id); | |
| let d; | |
| try { d=JSON.parse($('brief-data').textContent); if(d.schema!=='cto-brief-five-minute/1')throw Error('Rebuild embedded metrics'); } | |
| catch(err){ console.error('Briefing data unavailable',err); $('scores-table').textContent='Verified metrics unavailable; rebuild the offline briefing.';return; } | |
| const S=d.scores, N=(v,n=0)=>Number(v).toLocaleString('en-US',{minimumFractionDigits:n,maximumFractionDigits:n}), P=(v,n=2)=>`${N(v,n)}%`, sign=v=>`${v<0?'−':v>0?'+':''}${P(Math.abs(v))}`, approx=v=>`≈${N(Math.round(v/100)*100)}`, C={ink:'#102740',muted:'#516476',line:'#dce5e9',blue:'#386bd7',teal:'#087e78',red:'#c34853',amber:'#ad6700'}; | |
| const svg=(id,w,h,label,content)=>{$(id).innerHTML=`<svg viewBox="0 0 ${w} ${h}" role="img" aria-label="${label}" xmlns="http://www.w3.org/2000/svg"><title>${label}</title>${content}</svg>`;}; | |
| const mobile=()=>matchMedia('(max-width:620px)').matches; | |
| function basics(){ | |
| $('tensor-shape').textContent=`Input [batch=${d.input.shape[0]}, series=${d.input.shape[1]}, historical days=T] → 10 series × 28 future days`; | |
| $('context-range').textContent=`${N(d.input.context_min)}–${N(d.input.context_max)}`; | |
| $('weekly-reduction').textContent=P(100*(S.lightgbm.weekly_wape_pct-S.p50.weekly_wape_pct)/S.lightgbm.weekly_wape_pct,1); | |
| $('daily-reduction').textContent=P(100*(S.lightgbm.daily_wape_pct-S.p50.daily_wape_pct)/S.lightgbm.daily_wape_pct,1); | |
| $('scores-table').innerHTML=[['LightGBM',S.lightgbm],['Timestral P50',S.p50],['Timestral P60',S.p60]].map(([name,x])=>`<tr${name==='Timestral P50'?' class="selected"':''}><td>${name}</td><td>${P(x.daily_wape_pct)}</td><td>${P(x.weekly_wape_pct)}</td><td>${sign(x.bias_pct)}</td></tr>`).join(''); | |
| $('mobile-scores').innerHTML=[['LightGBM',S.lightgbm],['Timestral P50',S.p50],['Timestral P60',S.p60]].map(([name,x])=>`<article><strong>${name}</strong><dl><div><dt>Daily WAPE</dt><dd>${P(x.daily_wape_pct)}</dd></div><div><dt>Weekly WAPE</dt><dd>${P(x.weekly_wape_pct)}</dd></div><div><dt>Signed bias</dt><dd>${sign(x.bias_pct)}</dd></div></dl></article>`).join(''); | |
| for (const [key,x] of [['p50',S.p50],['p60',S.p60]]){ $(`${key}-bias`).textContent=sign(x.bias_pct);$(`${key}-under`).textContent=P(x.under_pct);$(`${key}-over`).textContent=P(x.over_pct); } | |
| $('million-week-l').textContent=approx(S.lightgbm.weekly_wape_pct*10000);$('million-week-t').textContent=approx(S.p50.weekly_wape_pct*10000);$('million-week-gap').textContent=approx((S.lightgbm.weekly_wape_pct-S.p50.weekly_wape_pct)*10000); | |
| $('million-day-l').textContent=approx(S.lightgbm.daily_wape_pct*10000);$('million-day-t').textContent=approx(S.p50.daily_wape_pct*10000);$('million-day-gap').textContent=approx((S.lightgbm.daily_wape_pct-S.p50.daily_wape_pct)*10000); | |
| $('million-under-gap').textContent=approx((S.p50.under_pct-S.p60.under_pct)*10000);$('million-over-gap').textContent=approx((S.p60.over_pct-S.p50.over_pct)*10000); | |
| $('example-caption').textContent=`${d.example.series}, forecast from ${d.example.origin}: actual sales compared with the saved 28-day predictions. Selected by a representative-error rule, not for a model win. One example does not replace the matched comparison above.`; | |
| } | |
| function mobileDiagrams(){ | |
| // The desktop diagrams are intentionally replaced, not miniaturized, on a phone. | |
| const card=(y,fill,title,sub)=>`<rect x="8" y="${y}" width="324" height="55" rx="10" fill="${fill}"/><text x="170" y="${y+23}" text-anchor="middle" fill="${[C.ink,C.teal,C.blue].includes(fill)?'white':C.ink}" font-size="15" font-weight="850">${title}</text><text x="170" y="${y+42}" text-anchor="middle" fill="${[C.ink,C.teal,C.blue].includes(fill)?'#d9f3ee':C.muted}" font-size="11">${sub}</text>`; | |
| const arr=y=>`<path d="M170 ${y}v17m-5-5 5 5 5-5" stroke="#8099a5" stroke-width="2" fill="none"/>`; | |
| const add=(target,label,w,h,body)=>{const html=`<svg class="mobile-illustration" viewBox="0 0 ${w} ${h}" role="img" aria-label="${label}" xmlns="http://www.w3.org/2000/svg"><title>${label}</title>${body}</svg>`;target.insertAdjacentHTML('afterend',html);}; | |
| add(document.querySelector('.hero-grid .figure>svg'),'Mobile diagram: historical sales enter a model and become 28 daily and four weekly sales forecasts',340,268,`<rect width="340" height="268" rx="12" fill="#f1f8f6"/>${card(12,'white','Historical recorded sales','5 regions · 2 products')}${arr(68)}${card(88,C.ink,'Forecasting model','LightGBM or Timestral')}${arr(144)}${card(164,'white','28 daily estimates','sum days 1–7, 8–14, 15–21, 22–28')}<text x="170" y="246" text-anchor="middle" fill="${C.teal}" font-size="13" font-weight="850">→ 4 weekly totals per series</text>`); | |
| add(document.querySelector('.model:not(.timestral)>svg'),'Mobile LightGBM diagram: past sales and calendar features become a weekly level, then daily shares distribute it into 28 days',340,224,`${card(0,'#eaf0ff','Past sales + calendar','lags · region · product')}${arr(56)}${card(76,C.blue,'Trained LightGBM trees','weekly level + daily-share model')}${arr(132)}${card(152,'#eaf0ff','28 daily forecasts','seven normalized shares per week')}`); | |
| add(document.querySelector('.model.timestral>svg'),'Mobile Timestral diagram: ten historical sequences enter the pretrained, frozen model and produce P50 and P60 daily predictions for 28 days',340,224,`${card(0,'#e5f4f1','10 historical sequences','one for each region × product')}${arr(56)}${card(76,C.teal,'Pretrained Timestral','frozen weights · no local fine-tuning')}${arr(132)}${card(152,'#e5f4f1','10 × 28 daily forecasts','native P50 and P60 estimates')}`); | |
| add(document.querySelector('.decision .figure>svg'),'Mobile planning flow: historical sales to Timestral to P50/P60 daily forecasts to four weekly totals to business planning',340,400,`${card(0,'#eaf0ff','Historical daily sales','as of the forecast cutoff')}${arr(56)}${card(76,C.teal,'Timestral-209M v1','one inference setup')}${arr(132)}${card(152,'#e5f4f1','P50 / P60','28 daily forecasts per series')}${arr(208)}${card(228,'#e5f4f1','Four weekly totals','add the daily forecasts')}${arr(284)}${card(304,C.ink,'Business planning','production needs separate data')}`); | |
| } | |
| function calendar(){ | |
| const sm=mobile(),w=sm?364:930,h=sm?322:362,left=sm?43:128,top=sm?34:36,tile=sm?41:98,gap=sm?3:9,row=sm?66:74; | |
| let out=''; | |
| ['MON','TUE','WED','THU','FRI','SAT','SUN'].forEach((day,i)=>out+=`<text x="${left+i*(tile+gap)+tile/2}" y="21" fill="${i===4?C.red:C.muted}" font-size="${sm?9:11}" text-anchor="middle" font-weight="850">${day}</text>`); | |
| for(let week=0;week<4;week++){ | |
| let y=top+row*week;out+=`<text x="${sm?1:17}" y="${y+(sm?27:29)}" fill="${C.teal}" font-size="${sm?13:17}" font-weight="850">W${week+1}</text>`; | |
| for(let j=0;j<7;j++){ | |
| let x=left+j*(tile+gap),n=week*7+j+1,fill=j===4?'#fcebed':week%2?'#eaf0ff':'#e5f4f1'; | |
| out+=`<rect x="${x}" y="${y}" width="${tile}" height="${sm?42:48}" rx="${sm?5:8}" fill="${fill}"/><text x="${x+tile/2}" y="${y+(sm?25:29)}" text-anchor="middle" fill="${j===4?C.red:C.ink}" font-size="${sm?12:15}" font-weight="850">${n}</text>`; | |
| } | |
| out+=`<text x="${left}" y="${y+(sm?58:66)}" fill="${C.muted}" font-size="${sm?9:11}" font-weight="700">${sm?'7 daily forecasts → 1 weekly total':`D${week*7+1}–D${week*7+7} → Week ${week+1} total = sum of these seven days`}</text>`; | |
| } | |
| svg('calendar',w,h,'A 28-day calendar: four rows of seven days, each row summed into its corresponding week',out); | |
| } | |
| function wapeBars(id,key){ | |
| const sm=mobile(),w=sm?360:930,h=sm?222:208,left=sm?116:188,right=sm?38:104,W=w-left-right,max=key==='daily'?24:14; | |
| const rows=[['LightGBM',S.lightgbm,C.blue],['Timestral P50',S.p50,C.teal],['Timestral P60',S.p60,'#63b5aa']];let out=''; | |
| for(let i=0;i<rows.length;i++){ | |
| let [name,x,color]=rows[i],val=x[`${key}_wape_pct`],y=22+i*(sm?62:57),width=W*val/max; | |
| out+=`<text x="${left-10}" y="${y+22}" fill="${color}" text-anchor="end" font-size="${sm?12:15}" font-weight="850">${name}</text><rect x="${left}" y="${y}" width="${W}" height="29" rx="5" fill="#edf2f3"/><rect x="${left}" y="${y}" width="${width}" height="29" rx="5" fill="${color}"/><text x="${Math.min(w-4,left+width+9)}" y="${y+20}" fill="${C.ink}" font-size="${sm?11:15}" font-weight="850" ${sm&&left+width+42>w?'text-anchor="end"':''}>${P(val)}</text>`; | |
| } | |
| svg(id,w,h,`${key} WAPE comparison, LightGBM, Timestral P50 and P60; lower is better`,out); | |
| } | |
| function example(){ | |
| const sm=mobile(),w=sm?364:930,h=sm?230:285,left=sm?42:56,right=sm?8:25,top=18,bottom=sm?40:40,W=w-left-right,H=h-top-bottom,days=d.example.days,cap=Math.ceil(Math.max(...days.flatMap(x=>[x.actual,x.p50,x.lightgbm]))/400)*400; | |
| const x=i=>left+i*W/27,y=v=>top+H-v*H/cap; | |
| let out=`<text x="${left}" y="12" fill="${C.muted}" font-size="${sm?10:11}">Recorded sales units / day</text>`; | |
| [0,.5,1].forEach(f=>{let yy=y(f*cap);out+=`<path d="M${left} ${yy}H${w-right}" stroke="${C.line}"/><text x="${left-6}" y="${yy+4}" text-anchor="end" fill="${C.muted}" font-size="${sm?10:11}">${N(cap*f)}</text>`;}); | |
| days.forEach((day,i)=>{if(day.weekday==='Friday')out+=`<rect x="${x(i)-W/54}" y="${top}" width="${W/27*.8}" height="${H}" fill="#fcebed"/>`;}); | |
| for(let [key,color,stroke] of [['actual',C.ink,2.9],['lightgbm',C.blue,2.35],['p50',C.teal,2.6]]){ | |
| const path=days.map((v,i)=>`${i?'L':'M'}${x(i).toFixed(1)} ${y(v[key]).toFixed(1)}`).join('');out+=`<path d="${path}" fill="none" stroke="${color}" stroke-width="${stroke}" stroke-linecap="round" stroke-linejoin="round"/>`; | |
| days.forEach((day,i)=>{out+=`<circle cx="${x(i)}" cy="${y(day[key])}" r="${sm?1.7:2.6}" fill="${color}"><title>${day.date}: ${key==='p50'?'Timestral P50':key==='lightgbm'?'LightGBM':'Actual'} ${N(day[key])} sales units</title></circle>`;}); | |
| } | |
| [0,6,13,20,27].filter(i=>!sm||[0,13,27].includes(i)).forEach(i=>{out+=`<text x="${x(i)+(sm&&i===27?-5:0)}" y="${h-15}" text-anchor="middle" fill="${C.muted}" font-size="${sm?10:11}">D${i+1}</text>`;}); | |
| svg('example-chart',w,h,`Real ${d.example.series} sales and 28-day predictions starting ${d.example.origin}: actual, LightGBM and Timestral P50`,out); | |
| } | |
| function million(){ | |
| const sm=mobile(),w=sm?364:930,h=sm?357:296,left=sm?90:157,right=sm?19:95,W=w-left-right,max=230000; | |
| const rows=[['WEEKLY',S.lightgbm.weekly_wape_pct*10000,S.p50.weekly_wape_pct*10000],['DAILY',S.lightgbm.daily_wape_pct*10000,S.p50.daily_wape_pct*10000]]; | |
| let out=''; | |
| rows.forEach(([group,lg,t],j)=>{let base=j*(sm?170:141);out+=`<text x="${sm?0:12}" y="${base+17}" fill="#c8dce2" font-size="${sm?11:13}" font-weight="850">${group} ABSOLUTE ERROR</text>`; | |
| [[lg,'LightGBM',C.blue],[t,'Timestral',C.teal]].forEach(([val,label,color],i)=>{let y=base+37+i*(sm?45:47);out+=`<text x="${left-9}" y="${y+19}" text-anchor="end" fill="#e8f2f4" font-size="${sm?11:13}" font-weight="800">${label}</text><rect x="${left}" y="${y}" width="${W*val/max}" height="28" rx="5" fill="${color}"/><text x="${Math.min(w-4,left+W*val/max+7)}" y="${y+19}" fill="#fff" font-size="${sm?10:12}" font-weight="850" ${sm&&left+W*val/max+72>w?'text-anchor="end"':''}>${approx(val)}</text>`;}); | |
| if(!sm)out+=`<text x="${left}" y="${base+135}" fill="#c8dce2" font-size="11">P50 reduces ${group.toLowerCase()} error by ${approx(lg-t)} units on this scale.</text>`; | |
| }); | |
| svg('million-chart',w,h,'At one million illustrative actual sales units: LightGBM versus Timestral P50 weekly and daily absolute forecast errors',out); | |
| } | |
| function bias(){ | |
| const sm=mobile(),w=sm?364:510,h=sm?245:251,left=sm?104:137,right=sm?17:27,W=w-left-right,lo=-9,hi=5,x=v=>left+(v-lo)/(hi-lo)*W; | |
| let out=`<text x="${left}" y="19" fill="${C.red}" font-size="${sm?9:11}" font-weight="850">UNDER</text><text x="${w-right}" y="19" text-anchor="end" fill="${C.amber}" font-size="${sm?9:11}" font-weight="850">OVER</text><path d="M${left} 34H${w-right}" stroke="${C.line}" stroke-width="2"/>`; | |
| [-8,-4,0,4].forEach(v=>{out+=`<path d="M${x(v)} 38V222" stroke="${v===0?C.ink:C.line}" ${v===0?'stroke-width="2"':'stroke-dasharray="3 3"'}/><text x="${x(v)}" y="241" fill="${C.muted}" text-anchor="middle" font-size="${sm?10:11}">${v}%</text>`;}); | |
| [['LightGBM',S.lightgbm,C.blue],['Timestral P50',S.p50,C.teal],['Timestral P60',S.p60,C.amber]].forEach(([name,score,color],i)=>{const yy=79+55*i;out+=`<text x="${left-8}" y="${yy+4}" text-anchor="end" fill="${color}" font-size="${sm?11:12}" font-weight="850">${name}</text><path d="M${x(0)} ${yy}H${x(score.bias_pct)}" stroke="${color}" stroke-width="3"/><circle cx="${x(score.bias_pct)}" cy="${yy}" r="7" fill="${color}"/><text x="${Math.min(w-27,x(score.bias_pct)+11)}" y="${yy-12}" fill="${color}" font-size="${sm?10:12}" font-weight="850">${sign(score.bias_pct)}</text>`;}); | |
| svg('bias-chart',w,h,'Signed bias axis with LightGBM at minus 6.97 percent, Timestral P50 at minus 3.73 percent and P60 at plus 2.22 percent',out); | |
| } | |
| function tradeoff(){ | |
| const sm=mobile(),w=sm?364:930,h=sm?222:204,left=sm?56:122,right=sm?12:115,W=w-left-right,max=210000; | |
| let out='';[['P50',S.p50],['P60',S.p60]].forEach(([name,score],i)=>{ | |
| const under=score.under_pct*10000,over=score.over_pct*10000,y=34+i*(sm?74:75),uw=W*under/max,ow=W*over/max; | |
| out+=`<text x="${left-10}" y="${y+24}" text-anchor="end" fill="${C.teal}" font-size="${sm?15:17}" font-weight="850">${name}</text><rect x="${left}" y="${y}" width="${uw}" height="34" rx="5" fill="${C.red}"/><rect x="${left+uw}" y="${y}" width="${ow}" height="34" rx="5" fill="${C.amber}"/><text x="${left+uw/2}" y="${y+22}" text-anchor="middle" fill="white" font-size="${sm?10:12}" font-weight="850">${approx(under)}</text><text x="${left+uw+ow/2}" y="${y+22}" text-anchor="middle" fill="white" font-size="${sm?10:12}" font-weight="850">${approx(over)}</text>`; | |
| }); | |
| out+=sm?`<text x="${left}" y="${h-27}" fill="${C.red}" font-size="11">■ Underforecast deviation</text><text x="${left}" y="${h-11}" fill="${C.amber}" font-size="11">■ Overforecast deviation</text>`:`<text x="${left}" y="${h-12}" fill="${C.muted}" font-size="11">Red = underforecast deviation · Amber = overforecast deviation</text>`; | |
| svg('tradeoff-chart',w,h,'Underforecast and overforecast error at one million illustrative actual sales units for Timestral P50 versus P60',out); | |
| } | |
| basics();mobileDiagrams(); | |
| function redraw(){calendar();wapeBars('daily-chart','daily');wapeBars('weekly-chart','weekly');example();million();bias();tradeoff();} | |
| redraw();let resize; | |
| window.addEventListener('resize',()=>{clearTimeout(resize);resize=setTimeout(redraw,120);},{passive:true}); | |
| document.documentElement.dataset.ready='true'; | |
| })(); | |
| </script> | |
| </body> | |
| </html> |