smartyfy.mrindigi.com

AI Foundations for Students | 016. Predicting Numbers with a Simple Model

AI Foundations for Students · Lesson 16 of 36

Module 3: Machine Learning on Paper

In this lesson

Learning goal: Use a simple linear prediction rule, units and error measurements.

Predict a number instead of a category

Classification predicts a category such as small or large. Regression predicts a number, such as a duration or length. Both use information about an example, but the output and evaluation differ. A prediction of thirteen minutes can be close to an observed fourteen minutes even though it is not exactly equal. For a category, we usually begin by asking whether the predicted label matches the reference.

Our fictional craft station takes some setup time and then time for each paper badge. We will use the supplied model: predicted minutes = 4 + 2 × number of badges. This rule was chosen for teaching; it was not fitted by a live machine-learning tool. It lets us examine what a simple linear model means and how to measure its errors with arithmetic.

Understand the two parts of the rule

The constant 4 is the intercept: the model predicts four minutes when the badge count is zero. In this story we interpret it as setup time, but an intercept’s meaning depends on the task. The coefficient 2 is the slope: each additional badge increases the prediction by two minutes. The slope’s units are minutes per badge, while the intercept’s units are minutes.

For three badges, multiply 2 minutes per badge by 3 badges to get 6 minutes, then add 4 minutes of setup: predicted time is 10 minutes. Do the multiplication before the addition. The equation describes a straight-line relationship. A real process might not follow it exactly because materials, interruptions or batch size can change the time.

Compare predictions with observations

The complete fictional evaluation records are: one badge took 7 minutes; three badges took 9 minutes; five badges took 16 minutes. The model predicts 6, 10 and 14 minutes respectively. Define signed error here as prediction minus observation. The errors are −1, +1 and −2 minutes. A negative error means the model underestimated the observed time under this convention.

Absolute error ignores direction and measures distance from the observed value. The absolute errors are 1, 1 and 2 minutes. Their mean, or average, is (1 + 1 + 2) divided by 3 = 4/3 minutes, about 1.33 minutes. The denominator is the three evaluated examples. This mean absolute error summarizes this dataset; it is not a promise about every future craft session.

Why direction and size are both useful

Signed errors can cancel. If one prediction is five minutes too high and another five minutes too low, their signed average is zero despite both being wrong. Mean absolute error avoids that cancellation when describing error size. However, direction still matters for planning: repeated underestimation can leave too little time. Keep both the individual errors and a suitable summary.

The choice of error measure reflects the task. Here each minute of error is treated equally. In another setting, a large error might deserve much more attention than several small ones, or underestimation might be costlier than overestimation. Do not choose a metric merely because it gives the most flattering number. State what the measure captures and what it misses.

Stay inside the evidence range

Our evaluation covers one, three and five badges. Predicting for four badges stays within that observed range; predicting for one hundred goes far beyond it. The arithmetic still produces a number, but the relationship may no longer be suitable. At large scale, setup, equipment, fatigue or parallel work could change the pattern. A computable answer is not automatically a justified prediction.

A responsible report says which model was used, what data checked it, the units and the limits. It also distinguishes prediction from observation. Write “predicted fourteen minutes” and “observed sixteen minutes,” rather than replacing the observed record with the model’s result. Preserving that difference is essential for honest evaluation and for detecting when a simple model stops being useful.

Worked practice

Worked exercise 1: Use the linear rule

Task: Predict the time for four badges under predicted minutes = 4 + 2 × badge count. Name the units.

Worked solution: Two minutes per badge times four badges gives eight minutes. Add the four-minute intercept to obtain twelve predicted minutes. The badge units cancel in the multiplication, leaving minutes. This is a model prediction, not a measured completion time or a guarantee that a real group will finish in twelve minutes.

Worked exercise 2: Calculate mean absolute error

Task: Use predictions 6, 10 and 14 minutes with observations 7, 9 and 16 minutes. Find the signed and absolute errors, then their mean absolute error.

Worked solution: Prediction minus observation gives −1, +1 and −2 minutes. Taking absolute values gives 1, 1 and 2. Add to get four minutes of total absolute error across three examples, then divide by three: about 1.33 minutes. The signed average would be −2/3 minutes, which describes direction differently.

Worked exercise 3: Evaluate extrapolation

Task: The rule predicts 204 minutes for 100 badges. Can the class present that as a verified duration?

Worked solution: No. The arithmetic 4 + 2 × 100 = 204 is correct, but the evaluation covered only one to five badges. Report it as an unsupported extrapolation if discussing it at all. Gather appropriate evidence or use a more suitable planning method before relying on a large-batch estimate.

Check your understanding

MCQ 1: What does the slope 2 represent?

  1. Two badges of setup
  2. Two minutes added per badge
  3. A fixed two-minute total
  4. An error of two minutes on every example
Check the answer and explanation

Answer: B. The slope converts an additional badge into a two-minute change in prediction.

MCQ 2: What does the model predict for zero badges?

  1. 0 minutes
  2. 2 minutes
  3. 4 minutes
  4. 6 minutes
Check the answer and explanation

Answer: C. Substituting zero leaves the four-minute intercept.

MCQ 3: If prediction is 14 and observation is 16, what is prediction minus observation?

  1. −2 minutes
  2. +2 minutes
  3. 30 minutes
  4. −30 minutes
Check the answer and explanation

Answer: A. Subtracting the larger observed value gives a negative two-minute error.

MCQ 4: Why use absolute errors for average error size?

  1. To show the average direction of the errors
  2. To count only the examples with positive errors
  3. To give every example the same signed error
  4. To prevent positive and negative errors cancelling
Check the answer and explanation

Answer: D. Absolute values retain the size of each error regardless of direction.

MCQ 5: Which prediction is an extrapolation beyond the supplied evaluation range?

  1. Two badges
  2. Four badges
  3. One hundred badges
  4. Three badges
Check the answer and explanation

Answer: C. The checked examples span one to five badges, so one hundred is outside that range.

Sources and further reading