Build rolling one-step temperature forecasts and compare against persistence.
The focus of this experiment is to construct causal time-series windows and one-step targets. Students then calculate forecast errors against a persistence baseline, and verify temporal separation and avoid future-data leakage. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.
Learning objectives
Construct causal time-series windows and one-step targets.
Calculate forecast errors against a persistence baseline.
Verify temporal separation and avoid future-data leakage.
Identify the configured inputs (Trailing window (samples); Temperature step (°C)) and record the corresponding observed outputs with units where applicable.
Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.
Expected learning outcomes
On completion, students can construct causal time-series windows and one-step targets, calculate forecast errors against a persistence baseline, and verify temporal separation and avoid future-data leakage.
Required deliverables
Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing verify temporal separation and avoid future-data leakage. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the following catalogue prerequisites before starting. After completion, continue to TinyML & INT8 arithmetic.
The supplied model, datasets and local Python or Colab notebook. Report the data partition and execution environment; do not claim physical edge-device performance from host measurements.
Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.
M05 · learning outcome
Understand the experiment
Causal forecasting · trailing windows
Predict t+1 using observations available through t, never the target itself
Scientific architecture · Time-series forecasting & causal windows
Scientific concept map: Past time series — Causal window; Forecast rule — Use past only; Predicted next value — No future leakage; Actual observation — Compare target; Error — MAE / time alignment.
Scientific foundations and analytical reasoning
Causal forecasts use only earlier samples; a persistence baseline predicts the latest observation. Error must be computed against future actual samples.
Before operating the equipment or executing the program, derive the expected outcome using the required theoretical work in Experiment. Use the diagram to identify the variables and system boundaries.
Scientific theory · Causal time-series prediction
A moving-average forecast uses a window of preceding observations; persistence predicts the latest observed value. The target at time k must not be included in the input window predicting k. Forecast errors are computed after the target is observed, and missing samples affect window policy.
Worked example and engineering interpretation
Given preceding samples 20,22,24, a three-sample moving-average forecast is 22 and persistence predicts 24. If the next actual value is 25, absolute errors are 3 and 1. Compare the same target times and causal windows across methods.
Engineering principles · additional worked teaching example
A causal trailing forecast uses only earlier samples. For 4,6,8 and window3, next prediction6; once actual 10 observed, next mean=(6+8+10)/3=8. Including the target in its own window leaks future data.
From theory to experiment
Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.
How to investigate Time-series forecasting & causal windows
Build rolling one-step temperature forecasts and compare against persistence.
Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.
Experiment-specific guided practice
Objective: Build rolling one-step temperature forecasts and compare against persistence.
Set Trailing window (samples) = 4; Temperature step (°C) = 8. Observe the calculated results and trace.
Restore the reference values. Inspect shock response and lag; compare against persistence (previous sample).
Reference check:
Model boundary:
Independent task and submission evidence
2. Change Trailing window (samples) = 16. All runs forecast exactly 40 targets; window size changes errors. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.
Trial
Changed setting
Fixed settings
Predicted result
Actual observation / units
Evidence / uncertainty
A: baseline
Reference
Record
Predict
Record
Record
B: one change
Record
Same as A
Predict
Record
Record
A: repeat
Restore
Same as A
Predict
Record
Record
Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.
Build rolling one-step temperature forecasts and compare against persistence.
Method: Trailing moving average; no future observations in input window.
Data provenance: deterministic generated teaching fixture or configured analytical model. No real sensor data, physical inference performance, or production deployment is claimed.
Worked engineering reasoning and boundary conditions
Engineering reference configuration: Trailing window (samples) = 4; Temperature step (°C) = 8. In the classroom model, Window MAE = 1.557865 °C; Persistence MAE = 0.632279 °C; Predictions = 40; Window = 4 samples. Rolling one-step forecasts use only previously observed samples, including earlier test observations; no future look-ahead. Trailing moving average; no future observations in input window
Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.
Mathematical representation and interpretation
One-step forecast error
y_i is an observed target and yhat_i a forecast generated without seeing the target. Compare against persistence on identical timestamps.
Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.
Step 1 of 7 · Observation 60
Observation 60
Observed target
25.190281
Causal forecast
24.038855
Observation 66
Observed target
29.056221
Causal forecast
27.469772
Observation 73
Observed target
38.524374
Causal forecast
36.563491
Observation 80
Observed target
35.53629
Causal forecast
36.804023
Observation 86
Observed target
33.8893
Causal forecast
34.230933
Observation 92
Observed target
36.056303
Causal forecast
34.7811
Observation 99
Observed target
40.361021
Causal forecast
38.993666
Teaching example only; inspect live calculations or real practical evidence separately.
Recall the concept before revealing its explanation.
0 / 3 revealed
M05 · 01 / 08What is the forecasting objective?Reveal explanation
Engineering explanation
Build rolling one-step temperature forecasts and compare against persistence.
Trailing moving average; no future observations in input window
M05 · 03 / 08Does changing window size change the number of forecast targets?Reveal explanation
Engineering explanation
All runs forecast exactly 40 targets; window size changes errors.
M05 · 04 / 08Why exclude the target observation from a rolling forecast window?Reveal explanation
Engineering reasoning
Including the target leaks future information relative to the prediction time.
M05 · 05 / 08Why use persistence as a baseline?Reveal explanation
Engineering reasoning
Predicting the previous observation is a simple causal comparator that a more complex forecast should justify improving upon.
M05 · 06 / 08A rolling one-step forecast is evaluated. Select every technically valid statement.
A. Use only observations available before the prediction time.
B. Compare with a persistence baseline under the same windows.
C. Use future measurements as predictors for earlier forecasts.
D. Shuffle all time stamps before constructing causal windows.Reveal explanation
Applied scenario
Correct: A. Use only observations available before the prediction time.; B. Compare with a persistence baseline under the same windows.
M05 · 07 / 08In Time-series forecasting & causal windows, which reference and changed settings are prescribed for Trailing window (samples)?Reveal explanation
Controlled configuration
Trailing window (samples): 4 → 16; hold the remaining settings fixed.
M05 · 08 / 08What expected result distinguishes the reference and changed trials in Time-series forecasting & causal windows?Reveal explanation
Expected observation
All runs forecast exactly 40 targets; window size changes errors.
Loading live engineering instrument…Supplementary research apparatusLoading experiment-specific apparatus…Scientific model · primary investigation
Simulation task
Build rolling one-step temperature forecasts and compare against persistence.
Explore the model using its own controls. Record a prediction before changing a condition. Compare the reference with a changed condition, then use the Experiment tab for the procedure, acceptance criteria and notebook. Model outputs and physical observations must remain separate.
Interactive engineering workbenchM05 · Scientific model
Readout from the original computational model; not physical measurements.
Loading instrument…
Awaiting model display.
Experimental instrumentation · A/B
Compare two model conditions
Capture a baseline, change one experimental condition, run the model if required and capture the comparison. Snapshots contain visible controls and display text, not physical sensor readings. Review before exporting.
Ask Dr. Mohammad locally, or prepare an experiment-aware prompt for ChatGPT, Gemini or Claude. The external providers open in their own tabs; nothing is automatically submitted.
Public course objective, displayed commands, source excerpts and procedure. Private assessment content is not collected.
Prepare a contextual AI prompt
0 characters
Common secret and email patterns are redacted on preparation; this is not a comprehensive privacy filter. Review the entire editable prompt, including student work and unpublished research, before sharing. The providers apply their own accounts, privacy settings and limits.
Prepare → review → copy & open your selected provider → paste and submit there.
Independent theoretical exercises
Before the simulation or practical, solve both experiment-specific tasks. List the given inputs, show the intermediate calculation or state trace, identify the expected observation, and state a limitation. Show formulas and intermediate calculations where relevant, or draw the requested state/sequence diagram. These are independent classroom fixtures; where they differ from the reference configuration below, do not treat them as measured values. Compare your predictions with the corresponding experiment afterwards.
01 · Predict and derive using the given inputs
For sequence 20,21,22,23,30,31, predict samples 5 and 6 using four-sample trailing mean and persistence.
Engineering method — A causal trailing forecast uses only earlier samples. For 4,6,8 and window3, next prediction6; once actual 10 observed, next mean=(6+8+10)/3=8. Including the target in its own window leaks future data. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
Calculate absolute errors and MAE for both; explain why including the target in its own window leaks information.
Engineering method — A causal trailing forecast uses only earlier samples. For 4,6,8 and window3, next prediction6; once actual 10 observed, next mean=(6+8+10)/3=8. Including the target in its own window leaks future data. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Trace
Trace · Independent work
Sequence 10,12,14,20,22; forecast values 4 and 5 with trailing window3 and persistence. Calculate absolute errors.
Trace — A causal trailing forecast uses only earlier samples. For 4,6,8 and window3, next prediction6; once actual 10 observed, next mean=(6+8+10)/3=8. Including the target in its own window leaks future data. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
Work is saved locally when browser storage is available. Export it for submission; no remote upload or automatic grade is assigned.
Expanded independent theoretical exercise bank
Progress from calculation and interpretation to diagnosis and controlled engineering design. Complete the questions without opening the simulation first; show intermediate steps.
Intermediate · Explain a changed-input result
Independent theoretical exercise · M05-01
Use the reference configuration (Trailing window (samples) = 4; Temperature step (°C) = 8), but change Trailing window (samples) = 6. The model reports Window MAE = 2.104925 °C. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.
Intermediate · Quantitative comparison
Independent theoretical exercise · M05-02
Two model observations of Window MAE are 1.557865 °C (reference) and 2.104925 °C (changed condition). Compute signed change and, when the reference is nonzero, percentage change. Explain why units matter.
Intermediate · Interpret a technical trace
Independent theoretical exercise · M05-03
For Temperature step (°C) = 8.2, the model supplies this excerpt from Calculated trace:
Item · Value · Explanation
First target · 60 ·
Last input for first target · 59 ·
Shock begins · 70 ·
Compute the range (maximum minus minimum) of the Value column in these rows. Identify the maximum observation. Do not extrapolate beyond these rows.
Advanced · Reverse reasoning
Independent theoretical exercise · M05-04
An observation is Window MAE = 1.570365 °C. Candidate A uses Trailing window (samples) = 4; Temperature step (°C) = 8. Candidate B changes the listed settings (Temperature step (°C) = 8.2) and keeps the remaining settings fixed. Which is consistent with the observation? If both can explain it, say what additional evidence is required.
Advanced · Diagnose a reported mismatch
Independent theoretical exercise · M05-05
A student configures Trailing window (samples) = 16 while preserving all other reference settings, but copies the reference report of Window MAE = 1.557865 °C. Evaluate whether the report is justified. Identify the first configuration/output check to perform.
Challenging · Design a controlled verification
Independent theoretical exercise · M05-06
Design a controlled comparison for Time-series forecasting & causal windows using reference Trailing window (samples) = 4; Temperature step (°C) = 8 and test Trailing window (samples) = 6. Specify the changed setting(s), measured metric Window MAE, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.
Step-by-step experimental procedure
Build rolling one-step temperature forecasts and compare against persistence.
1 · Reference workbench configuration
Use the named reference workbench and its reference inputs. Additional live instruments may have different controls; use the matching instrument. Record virtual and practical results separately.
Trailing window (samples)4
Temperature step (°C)8
2 · Perform the investigation in order
Set Trailing window (samples) = 4; Temperature step (°C) = 8. Observe the calculated results and trace.
Restore the reference values. Inspect shock response and lag; compare against persistence (previous sample).
3 · Compare controlled trials
Trial
Independent change
Expected check
Observation
Reference
Use reference inputs above
All runs forecast exactly 40 targets; window size changes errors.
Record actual result
Controlled change
Trailing window (samples) = 16
All runs forecast exactly 40 targets; window size changes errors.
Record actual result
4 · Analyze and report
Inspect shock response and lag; compare against persistence (previous sample).
Required evidence: Record the time-series forecasting & causal windows comparison and justify the changed outcome from the calculated trace.
Model boundary: Trailing moving average; no future observations in input window
Controlled investigation · reproducible evidence
Method. Use the existing reference workbench configuration and the named controlled changes below. A controlled variable stays fixed while the independent variable is intentionally changed; the dependent variable is the resulting observed output. First predict each trial from the Concepts page. Run the baseline, then change only the specified setting and record the outcome. For deterministic traces one execution per case and a repeated verification are sufficient; for timing or stochastic measurements repeat at least five times, recording each run, median and range. Reset to the reference state between independent comparisons.
Trial
Independent change
Dependent observation
Reference
Use reference inputs above
Record actual outcome and units
Controlled change
Trailing window (samples) = 16
Record actual outcome and units
Evidence: attach the completed comparison table, one trace or screenshot per condition, and actual practical terminal/hardware evidence where applicable. Explain any prediction mismatch and distinguish modeled behavior from measured results.
Loading laboratory-specific procedure…
Python / Google Colab notebook
Original Python reference, generated teaching fixture. Validated locally in a fresh Jupyter kernel. Download, then upload to Google Colab.
Set the environmental setpoint to 25 °C, window to 4 and additional step to 0. Advance 20 samples.
While playing, increase the additional step to 8 °C; observe the delayed forecast response while earlier history remains fixed.
Repeat from reset with window 16, injecting the step after exactly 20 samples. Compare errors over matching evaluated targets (export histories and use the overlapping range).
Compare trailing forecasts with persistence and explain why the current target is excluded from its own forecast.
Evidence: retain your prediction, configuration, observations and exported event history; distinguish calculated teaching-model results from physical measurements.
Complete practical procedure & acceptance
Read the method, enter a prediction and save the reference baseline.
Apply the controlled change and compare metrics and plot. Inspect shock response and lag; compare against persistence (previous sample).
Restore the reference and verify that the original metrics return. Enter an invalid parameter and confirm that export is disabled, then restore.
Run the independent local Python computation from the extracted portal root:
BASH · Command
python3 verification/ml168_practical.py all
Expected: ten passing checks and a result object for each lab. This uses Python standard library only. Compare the default result for M05 to the browser output.
Export actual observations and explain one limitation.
Student submission: include your prediction, exported baseline and controlled result, actual terminal output, and a short interpretation. Do not submit the build validation report as your own evidence.
Experimental notebook
Record your own results. Values are not prefilled or independently verified.
Record & discuss
Portfolio exports use related core lab P44 for compatibility. The supplementary experiment ID is preserved in the attachment. Local completion is self-reported.
Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
Perform the baseline and controlled changes. Save the notebook with actual outputs and your written interpretation.
Execution scope: Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# m05 · Time-series forecasting & causal windows
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## Introduction
Build rolling one-step temperature forecasts and compare against persistence.
## How to run
1. Download this notebook from the laboratory page. Open Google Colab → File → Upload notebook.
2. Select a Python CPU runtime. Run cells from top to bottom using Shift+Enter, or Runtime → Run all.
3. Read the printed observations and assertions. Change one parameter at a time and rerun the relevant cell.
4. Save your own outputs and compare them to the portal Experiment tab.
**Execution boundary:** Original Python reference, generated teaching fixture. Do not run the hardware or service commands in Colab. No real credentials are needed. The notebook is self-contained.
02Instructions · Markdown
## Experiment-specific preparation
Build rolling one-step temperature forecasts and compare against persistence.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Set Trailing window (samples) = 4; Temperature step (°C) = 8. Observe the calculated results and trace.
2. Change Trailing window (samples) = 16. All runs forecast exactly 40 targets; window size changes errors.
3. Restore the reference values. Inspect shock response and lag; compare against persistence (previous sample).
**Evidence:**
**Boundary:**
03Instructions · Markdown
## 1. Objectives and reference condition
- Reproduce the specific computational mechanism in this laboratory.
- Inspect the output, compare the reference condition with a changed or rejected condition where implemented, and explain any discrepancy.
- Distinguish actual local Python execution from mock, physical and external-service observations.
## 2. Environment check
04Python · executable cell
PYTHON · Code cell
# =====================================================================
# M05 | Code cell 01 | Time-series forecasting & causal windows
# Purpose: 1. Objectives and reference condition - Reproduce the specific computational mechanism in this laboratory. - Inspect the output, compare the reference condition with a changed or rejected condition where implem
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import sys
print("Python",sys.version.split()[0])
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert sys.version_info >= (3,10)
## 3. Implementation
Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
06Python · executable cell
PYTHON · Code cell
# =====================================================================
# M05 | Code cell 02 | Time-series forecasting & causal windows
# Purpose: implement only the mechanism named in this laboratory.
# Inputs: the explicit fictional fixture and reference parameters below.
# Output: printed observations and assertions for the controlled trial.
# =====================================================================
import math,statistics as st
# Generate a synthetic time series with a distribution change at index 70.
ts=[22+.08*i+3*math.sin(i/5)+(8 if i>=70 else 0) for i in range(100)]
def evaluate(window):
# Forecast t using only t-window through t-1; never use the target itself.
return st.mean(abs(st.mean(ts[t-window:t])-ts[t]) for t in range(60,100))
### Step 2 · Run the reference calculation
Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
08Python · executable cell
PYTHON · Code cell
# =====================================================================
# M05 | Code cell 03 | Time-series forecasting & causal windows
# Purpose: implement only the mechanism named in this laboratory.
# Inputs: the explicit fictional fixture and reference parameters below.
# Output: printed observations and assertions for the controlled trial.
# =====================================================================
for window in (1,4,8): print('Window',window,'MAE',evaluate(window))
assert evaluate(4)>=0 and len(ts[56:60])==4
## Original portal implementation (reference only)
These are the actual laboratory snippets. They are retained for comparison; follow the portal setup for WSL, hardware or services. They are **not** executed by Run all.
```bash
python3 verification/ml168_practical.py all
```
10Instructions · Markdown
## 4. Results and analysis
Record the actual output and whether the assertions pass. Identify a parameter to vary, state your prediction, repeat the reference calculation, then explain the changed result.
| Trial | Configuration | Observation | Interpretation |
|---|---|---|---|
| A | Reference | | |
| B | One controlled change | | |
| C | Reference repeat | | |
**Limitations:** Original Python reference, generated teaching fixture. Notebook success does not certify external equipment or services.
11Instructions · Markdown
## Guided reasoning and evidence
A controlled comparison changes one independent input while keeping the other relevant inputs fixed; the dependent variable is the recorded output. Use this lab’s reference condition above.
**Independent task:** 2. Change Trailing window (samples) = 16. All runs forecast exactly 40 targets; window size changes errors. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
| Trial | Input/configuration | Prediction | Observation | Evidence / limitation |
|---|---|---|---|---|
| A | Reference | | | |
| B | Changed input | | | |
| A repeat | Reference | | | |
A conclusion is supported only when it cites the recorded values or observed states and explains them with the experiment theory.
Shared research workbenches · network designer & advanced studiesConcurrent-device simulation & Monte Carlo research