Beta

Sync to cloud

Uses your current signed-in YoolVi account. A Learn profile is not required.

Upload a snapshot of this browser’s saved lesson work across all subjects, including notes, experiments, journal and review history. Existing guest work is included only when you confirm below. This does not upload account credentials or award XP.

Sync uploads to your private account; it does not automatically merge or replace this device’s work. On another device, download the cloud copy and use My Learning’s backup import. The previous cloud snapshot is retained when a new one replaces it.

Export or import this device’s work

No background uploads. Edits made after a snapshot need another sync. On shared devices, work is bound to the first account observed by cloud sync; another account must use a separate browser profile. Keep your own downloaded backup too.

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.

Back to Simple models and useful baselines

Shared AI lesson · Simple models and useful baselines

Explain: Line predictions

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: Interpret line coefficients and residuals, distinguish MSE from MAE, and explain why training fit and validation evidence have different roles.

The idea in everyday terms

Regression predicts a number. Here the input is a flower’s sepal length and the target is its petal length. A constant baseline predicts the training average; a line lets the prediction change with the input.

What to watch in the experiment

Inspect the vertical difference between each prediction and measurement. Fitting chooses the line from training data alone. Compare its errors with the constant baseline and try the training-target permutation to see what happens when the useful relationship is disrupted.

What this does not establish

A fitted line describes the supplied measurements; it does not establish causation. These reused Iris development examples do not validate deployment, and a constant input cannot identify a unique slope.

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.

Start with a prediction in centimetres

We observe sepal and petal lengths in the licensed Iris dataset. Suppose you know only a flower’s sepal length and want to estimate its petal length. A regression model predicts a number. It differs from predicting a species category, even though the same source can support both learning exercises.

The training-mean baseline always predicts the average training petal length. A line lets the prediction change with the input. Move the line in the lab, select a validation flower and follow the vertical segment from prediction to observation.

Two coefficients describe the line

For a small worked example, suppose the intercept is 1 cm and the slope is 0.5 cm of petal length per cm of sepal length. At sepal length 6 cm, the prediction is 1 + 0.5 × 6 = 4 cm.

y^=a+bx\hat y=a+bx

x is sepal length in cm; ŷ (“y hat”) is predicted petal length in cm. a is the intercept, in cm. b is the slope, in cm of predicted petal length per cm of sepal length. Read the formula as “prediction equals the starting value plus slope times input.” Changing a shifts the line vertically. Changing b changes how quickly its prediction rises or falls as x changes.

An intercept at x = 0 is a mathematical parameter. Zero sepal length lies outside these flower observations, so that intercept does not have a supported biological interpretation. A slope in observational data describes an association, not the causal effect of changing an input. In this dataset the mixture of species can contribute to the relationship.

Show an error before averaging it

If the actual petal length is 5 cm and the prediction is 4 cm, the residual is 1 cm, using actual minus predicted. If actual is 3 cm and predicted is 5 cm, the residual is −2 cm. Squaring gives 1 cm² and 4 cm². Their mean squared error is (1 + 4) / 2 = 2.5 cm².

ri=yi−y^i,MSE=1n∑i=1nri2r_i=y_i-\hat y_i,\qquad \mathrm{MSE}=\frac{1}{n}\sum_{i=1}^{n}r_i^2

i identifies a row; yᵢ is its observed value; ŷᵢ is its prediction; rᵢ is its residual; and n is the number of evaluated rows. The sum symbol means add one squared residual for each row. MSE is undefined for an empty sample, not zero. Squaring prevents opposite signs from cancelling and makes larger errors contribute disproportionately.

Mean absolute error, MAE, averages absolute residuals instead. The same two residuals give (1 + 2) / 2 = 1.5 cm. MAE retains the original output unit; MSE has squared units. A numerical value of 1 in these two metrics does not mean the same thing. An acceptable error should be connected to the task and measurement precision.

Fit using training data only

Least squares chooses the slope and intercept that minimize training MSE. You can search manually, but a one-input line with an intercept also has a direct solution. First find the training mean x and mean y. Subtract those means from each training pair to describe deviations from the center.

Optional: the centered-sum formula b=∑i(xi−xˉ)(yi−yˉ)∑i(xi−xˉ)2,a=yˉ−bxˉb=\frac{\sum_i (x_i-\bar x)(y_i-\bar y)}{\sum_i (x_i-\bar x)^2},\qquad a=\bar y-b\bar x

The bars in x̄ and ȳ mean training averages. The numerator adds products of paired deviations: it records whether larger x values tend to accompany larger y values. The denominator adds squared x deviations: it measures how much the training inputs vary. Divide to get the slope, then choose an intercept that makes the line pass through the two means.

If all training x values are identical, the denominator is zero and the slope is not identifiable from those observations. The lab’s fitting function reports that condition and returns a slope of zero with the mean prediction. A nonzero denominator identifies a least-squares slope, but does not establish causality or useful future performance.

The lab uses one representative per identical four-measurement group and fits on training groups only. Its deterministic stratified group assignment and small historical sample limit what can be claimed. These groups are a deduplication convention, not known specimen identities. The source measurements are unaltered in this regression view; the artificial missingness and mixed units belong to a different teaching lab.

Compare against a deliberately broken relationship

The label-shuffled control preserves the training inputs and the collection of training target values while rearranging which target belongs to which input. It fits a new line to that broken pairing. Validation labels remain original, so every candidate is judged against the same task. The displayed training metrics also use original targets for a common comparison; they are not the shuffled optimizer’s fitting objective.

Five reproducible permutations let you see that controls themselves vary. A single control outcome is not a statistical significance test. Do not select whichever shuffle makes your preferred conclusion look strongest. Report the setup and seek appropriate independent evidence.

Interpret the result within its scope

Compare the fitted line with the mean baseline, inspect one residual, and explain the units of both error measures. Then ask what the current evidence leaves out: other collections, different measurement practices, species proportions, outliers and possible nonlinear relationships.

The plot keeps fixed axes. A manual line can predict outside the visible range; its full prediction still appears in the arithmetic. A negative prediction is mathematically possible for a line but is not a physically meaningful petal length. Choosing a model or transformation to respect such constraints is part of model design.

This is repeated development evidence on a small licensed dataset, not final deployment validation. The downloadable comparison is practice.

Notes, help and related ideas
My notes and reflection
CURIOSITY JOURNAL

What will you take away?

Keep a private reminder for yourself.

Loading your journal…

Add a short reflection

Open your journal or back it up.

Prerequisites and related ideas

Key terms: Linear regression Prediction residual Mean squared error (MSE) Mean absolute error (MAE) Validation data