Skip to content
All lessons
AI Technical AptitudeAI Methods9-12.AITA.AIM.3

Data Writes the Function

9–12 CS / engineering50 minutes90 minutes (lab extension)

Standard quoted exactly

Discuss how a machine learning model generates classifications or predictions.

Clarification. Machine learning is different from classical programming in that data is used to 'write' functions that take inputs and return outputs.

Student-friendly learning targets

  • I can contrast a human-written IF rule with a function whose boundary came from labeled examples.
  • I can walk a tiny Idaho table and show how a threshold 'appears' from the data.
  • I can say that the model still returns an output for an input — the authorship of the function changed.

Essential questions

  1. Who writes the function in classical programming, and who writes it in machine learning?
  2. If the data is wrong, whose 'code' is wrong?
  3. What is a classification vs. a numeric prediction in this story?

Objectives

  1. Write a classical frost rule (IF temp ≤ 32 F THEN frost) and then derive a threshold from a labeled table that may not sit at 32.
  2. Describe classification (label) vs. prediction (number) using the same input columns.
  3. Discuss, with a diagram, that training searches for a function; inference uses it.
  4. Name one way this differs from AIM.1 (calling) and DA.3 (splitting): here we talk mechanism, not app wiring or CSV stations.

Key vocabulary

Classical programming
A person writes the rules: inputs go through code they authored, outputs come out. The data does not write the IF.
Function (in ML)
A mapping from inputs to outputs. In ML the mapping is chosen to fit examples, not typed by a programmer line by line.
Classification
Output is a category: frost / no frost, blight / healthy, smoke / not smoke.
Prediction (numeric)
Output is a number: expected yield, MW load, cfs tomorrow. Same idea of a learned function, different output type.
Labeled example
An input paired with the known output, used to shape the function (last night's temp and whether the orchard actually frosted).

Teacher background

The clarification is the whole lesson: data writes the function. Keep it tactile. Classical: IF temp <= 32 THEN frost_warning. ML: a table of Treasure Valley nights (temp, humidity, frost_yes). Count, sort, and watch a threshold emerge that might be 31 or 34 because of wind or humidity. Students should feel that the computer is still producing a function f(x)→y; the author is the dataset plus an algorithm, not a programmer's IF. Do not teach gradient descent. A paper scatter and a moveable horizontal bar are enough. Spreadsheet SORT and a hand-drawn line beat a neural-net animation. Connect to AIM.1 (we call f) and AIM.8 (how we prepare the data that writes f) without repeating those labs.

Materials and prep

Materials

  • Printed 16-row frost table: night_id, temp_f, humidity, frost (Y/N). Public-climate-style, no orchard owner names.
  • Moveable yarn or a ruler for a threshold on a scatter of temp vs. frost.
  • Two function cards: f_classical (IF …) and f_data (threshold learned = __).
  • Board diagram: data + algorithm → function; new input → function → output.
  • Optional spreadsheet of the same 16 rows.

Before class

  • Cook the 16 rows so a 32 F rule gets two mistakes (a 33 F frost with radiative cooling; a 30 F save with wind). The learned threshold discussion is then real.
  • Print classical vs. ML side-by-side without disparaging rules — AIM.4 will pick among them.

Instructional sequence

Who wrote this IF?

5 min
  1. Show IF temp <= 32 THEN 'frost'. Ask who authored it (NWS, a teacher, a grower).
  2. Ask: could last winter's nights author a different cutoff? That is the ML claim for today.

The function still exists

12 min
  1. Draw f(x)→y on the board twice. Left: human writes f. Right: labeled pairs shape f.
  2. Classification: y is a label. Numeric prediction: y is a number (yield). Same story.
  3. Walk two labeled points. The algorithm's job is to pick a boundary that gets most points right — we will do that by hand.
  4. Quote the clarification: data is used to 'write' functions that take inputs and return outputs.

16 nights, one bar

10 min
  1. Plot temp vs. frost (Y above a line, N below, or two colors). Slide a vertical threshold.
  2. Count errors at 32 F, then at 31 and 34. Pick a threshold that misses fewer.
  3. Write f_data: IF temp <= T* THEN frost. Circle that the table wrote T*, not the NWS definition.
  4. Ask what extra input (humidity) might explain the leftover errors — preview features, do not train a two-input model.

Say it both ways

10 min
  1. Students write a 5-sentence discussion: classical frost rule; how the table wrote a function; one leftover error; classification vs. a yield number; why bad labels write a bad function.
  2. Offline: the printed scatter is the whole lab.

Real-world examples

  • NWS freeze headlines are classical thresholds; an orchard model that fits Payette nights may 'write' a different cutoff.
  • Idaho Power load: a formula based on temperature is classical; a model fit on five winters of MW is data-written.
  • Sports: a coach's rule 'if opponent 3-point rate > 40% then zone' vs. a function fit on seasons of public play-by-play.
  • River flood stage: the official stage is a rule; a damage model fit on past crests is a learned function.

Hands-on activity

Function cards on the table

8 min
  1. Pairs fill f_classical and f_data cards and tape them under the scatter.
  2. They run two new nights (inputs only) through both functions and compare outputs.
  3. Stand and say one sentence: 'The data wrote T* = … because …'

Discussion questions

  1. If we add 200 wrongly labeled nights, who vandalized the function?
  2. Is a learned threshold 'truer' than 32 F, or just truer to this table?
  3. Where does a human still write something in ML (choice of inputs, choice of algorithm, choice to stop)?
  4. How is this different from an LLM completing a sentence? (Still a function, much larger, still data-authored.)

Differentiation

Support

  • Pre-plotted scatter; students only slide the bar and copy T*.
  • Sentence stems for the five-sentence discussion.

Challenge

  • Add humidity as a second axis and try a hand-drawn linear separator; connect to AIM.6 limits.
  • Write why 100% on these 16 rows is not the same as a good function (overfit preview).

Multilingual learners

  • function / classification / prediction with everyday glosses (regla vs. ejemplo).
  • Oral discussion accepted; the scatter is language-light.

IEP / 504

  • Large scatter, thick yarn, fewer rows (10).
  • Skip the written paragraph; a labeled diagram can be the discussion artifact.

Assessment

Formative

  • Error counts at 32 vs. T*.
  • Correct use of 'function' as input→output, not as 'a party.'

Summative

  • Five-sentence discussion plus completed f_classical / f_data cards.
  • Must include the idea that labeled data authored the cutoff.

Success criteria

  • Student contrasts human-written vs. data-written functions.
  • Student can run a new input through the learned threshold.
  • Student names classification vs. numeric prediction.

Responsible use, ethics, and privacy

Responsible use

Use the teacher table. Do not scrape student weather apps or home thermostats.

Ethics

If data writes the function, biased or sloppy data writes biased or sloppy law-like behavior. Authorship does not remove human responsibility.

Privacy

No farm owner, student address, or household thermostat IDs. Public-style climate rows only.

Reflection

  1. In one sentence, who wrote f_data?
  2. When would you still prefer the classical 32 F rule?
  3. How will you explain this to someone who thinks ML is 'the computer thinking'?

Homework

Take the printed 8-row mini-table. Draw a scatter, choose a threshold, write f_data, and compare it to IF temp <= 32. Two sentences on which errors each function makes. No tools required.

Closing

Same f(x)→y. Different author. Classical code is a person; machine learning lets labeled Idaho nights write the cutoff. Tomorrow we decide when we still want the person to write the rules.

Extensions and cross-curricular links

Go further

  • 90-minute block: a second table (numeric yield) where the 'function' is a hand-fit line, not a threshold; still no software trainer.
  • Python extension: sklearn logistic on the 16 rows and print the learned coefficient — optional illustration of 'data wrote f.'
  • Card-sort statements into classical vs. ML authorship.
  • Printed tracing of the scatter for subs.
Algebra
f(x) is the same object; ML estimates f from points instead of from a worded rule.
Physics / earth science
32 F is a phase-change fact; orchard frost is also wind and humidity — data can capture a local mix.
Philosophy / ELA
Authorship of a rule is a useful metaphor: who is responsible when the function fails?