Prepare sensor observations, impute missing values and keep device groups separate.
The focus of this experiment is to identify missing values, feature scaling and leakage sources. Students then construct a training and evaluation split with correct preprocessing order, and verify that held-out observations do not influence fitting. 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
Identify missing values, feature scaling and leakage sources.
Construct a training and evaluation split with correct preprocessing order.
Verify that held-out observations do not influence fitting.
Identify the configured inputs (Fit scope; Held-out sensor offset (°C); Missing every N rows) 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 identify missing values, feature scaling and leakage sources, construct a training and evaluation split with correct preprocessing order, and verify that held-out observations do not influence fitting.
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 that held-out observations do not influence fitting. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the following catalogue prerequisites before starting. After completion, continue to Regression for sensor calibration.
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.
M01 · learning outcome
Understand the experiment
Scientific architecture · Sensor data preparation & leakage
Scientific concept map: Sensor rows — Device groups; Group split — Train vs held-out; Fit imputer — Training only; Transform — Apply fitted statistic; Evaluation — No leakage.
Scientific foundations and analytical reasoning
Preprocessing fitted on training data prevents held-out leakage. Group splits prevent records from one device appearing on both sides.
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 · Data preparation and leakage
Training estimates preprocessing parameters and model coefficients, while held-out evaluation measures generalization. Fitting imputation or scaling on the full data leaks information into training. Grouped splits are useful when observations from the same device are correlated, and temporal splits preserve forecast chronology.
Worked example and engineering interpretation
If training readings are 10,12,14, their mean is 12; impute a missing held-out reading with 12 rather than recomputing from test values. Verify device groups do not overlap if the experiment claims device-independent evaluation.
Engineering principles · additional worked teaching example
Preprocessing parameters must be fitted only on training rows. For training 8,12,16 the imputation mean is12; an evaluation set 50,missing is filled with12, not pooled mean21.5. Device-level split avoids correlated observations crossing sets.
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 Sensor data preparation & leakage
Prepare sensor observations, impute missing values and keep device groups separate.
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: Prepare sensor observations, impute missing values and keep device groups separate.
Set Fit scope = train-only; Held-out sensor offset (°C) = 8; Missing every N rows = 5. Observe the calculated results and trace.
Change Fit scope = leaky. Reference fits on observed training values only; the controlled change exposes held-out rows to fitting.
Restore the reference values. Compare fit row count and imputation mean; restore train-only before drawing conclusions.
Reference check:
Model boundary:
Independent task and submission evidence
2. Change Fit scope = leaky. Reference fits on observed training values only; the controlled change exposes held-out rows to fitting. 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.
Prepare sensor observations, impute missing values and keep device groups separate.
Method: train-only imputation vs deliberately invalid all-data fitting.
Prerequisites: None.
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: Fit scope = train-only; Held-out sensor offset (°C) = 8; Missing every N rows = 5. In the classroom model, Imputation mean = 29.192187 °C; Fit rows = 64; Missing test rows = 8; Leakage = NO. Fit preprocessing on the training set only; apply unchanged to held-out data. train-only imputation vs deliberately invalid all-data fitting
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.
Concept animation · progressive data plot
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 0
Observation 0
Original fixture
34.1
After imputation
29.192187
Observation 4
Original fixture
38.9
After imputation
38.9
Observation 8
Original fixture
43.7
After imputation
43.7
Observation 12
Original fixture
26.4
After imputation
26.4
Observation 15
Original fixture
46.8
After imputation
29.192187
Observation 19
Original fixture
28.6
After imputation
28.6
Observation 23
Original fixture
34.3
After imputation
34.3
Teaching example only; inspect live calculations or real practical evidence separately.
Recall the concept before revealing its explanation.
0 / 3 revealed
M01 · 01 / 08What must sensor data preparation preserve?Reveal explanation
Engineering explanation
Prepare sensor observations, impute missing values and keep device groups separate.
M01 · 02 / 08What imputation comparison is performed?Reveal explanation
Engineering explanation
train-only imputation vs deliberately invalid all-data fitting
M01 · 03 / 08What changes when held-out rows leak into fitting?Reveal explanation
Engineering explanation
Reference fits on observed training values only; the controlled change exposes held-out rows to fitting.
M01 · 04 / 08Why split by device before fitting preprocessing?Reveal explanation
Engineering reasoning
Rows from the same device may be correlated; holding out whole devices tests generalization and avoids held-out leakage.
M01 · 05 / 08Why fit the imputation mean on training observations only?Reveal explanation
Engineering reasoning
Held-out observations must not influence fitted preprocessing or the estimated generalization performance.
M01 · 06 / 08Sensor records from several devices are split for evaluation. Select every technically valid statement.
A. Keep evaluation groups separate from training.
B. Fit imputation parameters using training observations only.
C. Fit preprocessing on the entire dataset before splitting.
D. Randomly mixing adjacent samples always guarantees independence.Reveal explanation
Applied scenario
Correct: A. Keep evaluation groups separate from training.; B. Fit imputation parameters using training observations only.
M01 · 07 / 08In Sensor data preparation & leakage, which reference and changed settings are prescribed for Fit scope?Reveal explanation
Controlled configuration
Fit scope: train-only → leaky; hold the remaining settings fixed.
M01 · 08 / 08What expected result distinguishes the reference and changed trials in Sensor data preparation & leakage?Reveal explanation
Expected observation
Reference fits on observed training values only; the controlled change exposes held-out rows to fitting.
Loading live engineering instrument…Supplementary research apparatusLoading experiment-specific apparatus…Scientific model · primary investigation
Simulation task
Prepare sensor observations, impute missing values and keep device groups separate.
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 workbenchM01 · 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 training temperatures 20,22,missing,24, compute train mean imputation. For held-out 40,42,missing, apply the same value and compare with a pooled mean.
Engineering method — Preprocessing parameters must be fitted only on training rows. For training 8,12,16 the imputation mean is12; an evaluation set 50,missing is filled with12, not pooled mean21.5. Device-level split avoids correlated observations crossing sets. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
Design a device-group split for three devices with five records each; explain why adjacent records are correlated and cannot guarantee independence by random mixing.
Engineering method — Preprocessing parameters must be fitted only on training rows. For training 8,12,16 the imputation mean is12; an evaluation set 50,missing is filled with12, not pooled mean21.5. Device-level split avoids correlated observations crossing sets. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Debugging
Debugging · Independent work
Train values 3,9,missing; evaluation 30,missing. Calculate correct imputation and incorrect pooled mean, explain leakage.
Debugging — Preprocessing parameters must be fitted only on training rows. For training 8,12,16 the imputation mean is12; an evaluation set 50,missing is filled with12, not pooled mean21.5. Device-level split avoids correlated observations crossing sets. 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 · M01-01
Use the reference configuration (Fit scope = train-only; Held-out sensor offset (°C) = 8; Missing every N rows = 5), but change Missing every N rows = 7. The model reports Imputation mean = 29.217647 °C. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.
Intermediate · Quantitative comparison
Independent theoretical exercise · M01-02
Two model observations of Imputation mean are 29.192187 °C (reference) and 29.217647 °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 · M01-03
For Fit scope = leaky, the model supplies this excerpt from Calculated trace:
Item · Value · Explanation
Split · Train node-1/2; held-out node-3 ·
Missing values · Every 5th row; not zero-filled ·
Fit scope · leaky ·
Count rows whose Value value is exactly “Train node-1/2; held-out node-3”, and identify the displayed row numbers. Explain what the count describes.
Advanced · Reverse reasoning
Independent theoretical exercise · M01-04
An observation is Imputation mean = 31.701042 °C. Candidate A uses Fit scope = train-only; Held-out sensor offset (°C) = 8; Missing every N rows = 5. Candidate B changes the listed settings (Fit scope = leaky) 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 · M01-05
A student configures Fit scope = leaky while preserving all other reference settings, but copies the reference report of Imputation mean = 29.192187 °C. Evaluate whether the report is justified. Identify the first configuration/output check to perform.
Challenging · Design a controlled verification
Independent theoretical exercise · M01-06
Design a controlled comparison for Sensor data preparation & leakage using reference Fit scope = train-only; Held-out sensor offset (°C) = 8; Missing every N rows = 5 and test Missing every N rows = 7. Specify the changed setting(s), measured metric Imputation mean, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.
Step-by-step experimental procedure
Prepare sensor observations, impute missing values and keep device groups separate.
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.
Fit scopetrain-only
Held-out sensor offset (°C)8
Missing every N rows5
2 · Perform the investigation in order
Set Fit scope = train-only; Held-out sensor offset (°C) = 8; Missing every N rows = 5. Observe the calculated results and trace.
Change Fit scope = leaky. Reference fits on observed training values only; the controlled change exposes held-out rows to fitting.
Restore the reference values. Compare fit row count and imputation mean; restore train-only before drawing conclusions.
3 · Compare controlled trials
Trial
Independent change
Expected check
Observation
Reference
Use reference inputs above
Reference fits on observed training values only; the controlled change exposes held-out rows to fitting.
Record actual result
Controlled change
Fit scope = leaky
Reference fits on observed training values only; the controlled change exposes held-out rows to fitting.
Record actual result
4 · Analyze and report
Compare fit row count and imputation mean; restore train-only before drawing conclusions.
Required evidence: Record the sensor data preparation & leakage comparison and justify the changed outcome from the calculated trace.
Model boundary: train-only imputation vs deliberately invalid all-data fitting
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
Fit scope = leaky
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.
Open the live preparation instrument; keep train-only fitting and missing every fifth row. Step through at least 12 samples, recording fit count, mean and missing-value replacements.
Change held-out bias from 8 to 16 °C while keeping training-only fitting. Verify that the imputation mean is unchanged.
Reset and choose leaky fitting with the same bias and stride. Compare the fitted mean and row count; explain why this is invalid evaluation.
Export both histories; run the existing Python preparation experiment and compare the fixed reference configuration.
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. Compare fit row count and imputation mean; restore train-only before drawing conclusions.
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 M01 to the browser output.
Export actual observations and explain one limitation.
Inspect the id, device, x (temperature), v (vibration feature), y (regression target) and fault label. Device 1 and 2 are training; device 3 is held out. The labels are generated by a known rule, not a real diagnostic dataset.
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 P32 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
# m01 · Sensor data preparation & leakage
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## Introduction
Prepare sensor observations, impute missing values and keep device groups separate.
## 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
Prepare sensor observations, impute missing values and keep device groups separate.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Set Fit scope = train-only; Held-out sensor offset (°C) = 8; Missing every N rows = 5. Observe the calculated results and trace.
2. Change Fit scope = leaky. Reference fits on observed training values only; the controlled change exposes held-out rows to fitting.
3. Restore the reference values. Compare fit row count and imputation mean; restore train-only before drawing conclusions.
**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
# =====================================================================
# M01 | Code cell 01 | Sensor data preparation & leakage
# 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
# =====================================================================
# M01 | Code cell 02 | Sensor data preparation & leakage
# 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 statistics as st
def fixture():
rows=[]
for i in range(120):
x=18+(i*7%23)+((i*13%9)-4)/10; v=1+(i*11%17)/5
rows.append(dict(id=i,device=f'node-{1+i//40}',x=x,v=v,y=2.1*x+3+((i*19%13)-6)*.4,fault=int(x+3*v+((i*17%11)-5)/2>36)))
return rows
# Split by device group before learning the imputation statistic.
rows=fixture();train,test=rows[:80],rows[80:]
observed=[r['x'] for i,r in enumerate(train) if i%5]
mean=st.mean(observed)
### 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
# =====================================================================
# M01 | Code cell 03 | Sensor data preparation & leakage
# 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.
# =====================================================================
leaky=st.mean(observed+[r['x']+8 for i,r in enumerate(test) if i%5])
print('Training-only imputation',mean,'Leaky mean',leaky)
assert len(observed)==64 and mean!=leaky
assert not ({r['device'] for r in train}&{r['device'] for r in test})
## 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
```
```bash
python3 verification/ml168_practical.py dataset --output sensor-fixture.csv
```
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 Fit scope = leaky. Reference fits on observed training values only; the controlled change exposes held-out rows to fitting. 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