Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Lesson 4 of 10 in this unit

Understand Neural Networks · ORIGINAL LEARN AI LESSON

Repair data without leaking answers.

Audit real flower measurements, separate related rows, and turn a tempting score into a defensible claim.

By the end: Build a training-only preprocessing pipeline, compare it with a leaked baseline, and explain what the evaluation supports.

Start with the exampleJump to the experimentRead the explanation
Prerequisites and path options

Why learn this? Repair a dataset without letting answers leak into training and make evaluation look better than it is.

01 · TRY

Start with something concrete.

A flower app scores 100% on its development data. Some flower measurements were copied twice. If one copy trained the model and the other tested it, would you trust that score on a new flower? Start by tracing one row, not by buying a larger model.

Try the interactive model
02 · PREDICT
Before you experiment

Two readings of the same item land in different splits. What is the first repair?

Two readings of the same item land in different splits. What is the first repair?
03 · EXPERIMENT

Change one thing. Watch what follows.

Loading this browser experiment…

04 · UNDERSTAND
READ & CONNECT

Understand what changed.

Back to the experiment

A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.

Same learning goal in both modes: Build a training-only preprocessing pipeline, compare it with a leaked baseline, and explain what the evaluation supports.

The idea in everyday terms

A model should learn from training data and be checked using data that did not supply its fitting answers. Leakage happens when information crosses that boundary, such as using validation values to choose preprocessing or putting duplicate measurements on both sides.

What to watch in the experiment

Inspect the original Iris measurements and the declared teaching alterations. Track measurement groups rather than assuming every row is a different specimen. Compare clean and leaky processing and ask which information produced the apparently better score.

What this does not establish

A higher score after leakage is not stronger evidence. Repeatedly inspecting the development set makes it part of selection, and grouped measurements are not verified specimen identities.

Open the full worked examples, calculations and limitations

This is the same reference used in Technical mode. Expand it whenever you need the exact numbers, assumptions or further explanation.

The score answers the split’s question

A nearest-neighbor model copies the label of the closest training row. A duplicate in validation can therefore make the task almost trivial. That measures recognizing a repeated measurement, not predicting a new flower.

The local Iris source has 150 examples, four measurements in centimetres and three species. Our teaching view deliberately creates duplicates, missing petal lengths and some sepal lengths recorded in millimetres. Inspect the original view before attributing those issues to the source. The manifest records its license, hashes and transformations.

Choose the split to match the intended use. For a new person or site, keep that identity in one split. For future events at existing sites, hold out later times. For both new sites and future times, both boundaries matter. The Iris groups here use identical measurements; they are not verified specimen identities.

Repair one measurement, then fit the transformation

Suppose a recorded length is 60 mm. Divide by 10 to get 6 cm. If the training mean is 5 cm and its standard deviation is 0.5 cm, the standardized value is 2: two standard deviations above the training mean.

z=x−μtrainstrain=6−50.5=2z = \frac{x-\mu_{train}}{s_{train}} = \frac{6-5}{0.5}=2

Here x is the converted measurement, μ is the training average, s is the training standard deviation (a measure of spread), and z is a unitless coordinate. Treating 60 mm as 60 cm would produce 110 instead of 2 and distort which flower appears nearby.

Fit the mean using observed training cells. Fill missing cells with that mean, then calculate the standard deviation of the filled training column. Apply those same fitted values to validation. An entirely missing feature has no defined mean; stop rather than invent a number. A constant feature uses scale 1 to avoid dividing by zero.

Why the nearest flower wins

For each of four standardized measurements, subtract the candidate training value from the validation value. Square each difference, add them, then take a square root. The smallest distance wins; ties use the first training row. Labels do not enter these distances.

d(a,b)=∑j=14(za,j−zb,j)2d(a,b)=\sqrt{\sum_{j=1}^{4}(z_{a,j}-z_{b,j})^2}

a and b are two rows, j identifies a measurement, and d is their distance. For differences 1, 0, 2, 0, squared distance is 5 and distance is about 2.236. Compare the model with a majority-label baseline: a complicated procedure must justify its added value.

Report a limited claim

A clean pipeline can score lower because it asks a harder question. Changing splits also changes the training and validation examples, so the difference is not a controlled estimate of one repair’s effect. Repeatedly inspecting validation makes it development evidence. It is not an untouched final test or a guarantee about future populations.

For the project, capture the default run and a grouped, training-only, unit-corrected run. State counts, baseline, repairs and a limitation. Then attempt the sensor-site and future-period assessment cases without consulting the worked arithmetic. The project records first submissions separately from practice retries.

Optional depth: why filling with a mean changes spread

Mean imputation inserts values exactly at the center, so those cells contribute zero squared deviation. This usually reduces the estimated spread and hides uncertainty. It is a simple teaching baseline, not a universally appropriate missing-data model. Investigate why measurements are missing before using this repair in a real study.

05 · APPLY
Check your understanding

A training feature contains 4 cm, missing, and 8 cm. Validation contains 100 cm. Which training mean should fill the missing cell?

A training feature contains 4 cm, missing, and 8 cm. Validation contains 100 cm. Which training mean should fill the missing cell?
06 · CONTINUE

Take this idea with you.

Split according to the claim, fit preprocessing on training only, compare a baseline and record the remaining limits. Complete the linked audit project and new sensor/time-split cases for separate assessment evidence.

My Learning

Put the lesson into practice: Open the hands-on project and independent transfer assessment. Lesson completion and this practice check are separate from project submission and assessment results.

Explore related topics and the topic map

How this topic connects

Explore this topic on the interactive map

Use these connections to review a foundation or choose where to go next. You can open any topic without completing the others.

What it builds on

  • Averages

    Combine outcomes with their frequencies or probabilities, keeping the denominator explicit when interpreting this lesson’s evidence.

  • Generalization and validation

    Avoid choosing a model that memorizes examples but fails on new ones.

You are hereRepair data without leaking answers

Audit real flower measurements, separate related rows, and turn a tempting score into a defensible claim.

What it enables

Show 4 more connections
Original Learn AI lesson ·Iris source, license and provenance