Lesson 28 of 2855 minutes

Learning from Labeled Examples

Start with the lesson question, connect the representations, and test the model with evidence.

supervised pairsthreshold fitsplit rolesgroup leakagesensor shiftevaluation limitsprediction authority

Learning objectives

  • Explain supervised, imitation, and reinforcement-learning roles in robotics.
  • Separate training performance from deployment evaluation.
  • Identify reward, data, distribution-shift, and sim-to-real risks.
Lesson flowHook, model, explanationShow guidance

Inspect the opening phenomenon

Predict what changes, then name the evidence.

Apply in the lab

Name the evidence before reading the answer.

Read only what helps

Then use the lab and recall check.

More when needed

Transcript and resources stay available below.

Course progress

AI & Robotics Foundations · Learning for Robotics · Lesson 28

Learning from Labeled Examples

In progress

Decision challenge

Observe the phenomenon. Then connect the representations.

Use the opening example to make a prediction, identify evidence, and explain which model supports it.

Why Can a Robot Ace Training but Fail? Supervised Learning

Why Can a Robot Ace Training but Fail? Supervised Learning

Why Can a Robot Ace Training but Fail? Supervised Learning

Reference drawerTranscript, source notes, scripts, and package status stay tucked away until you need them.7 files

Lesson reading

live

55 min

Video script

published

Transcript fallback

available

courses/ai-robotics/modules/10-learning-for-robotics/lessons/01-learning-from-labeled-examples/video-transcript.md

Fit, Freeze, and Challenge the Sorter

published

25 min

Mastery check

live

7 questions / 10 min

Book section:courses/ai-robotics/modules/10-learning-for-robotics/lessons/01-learning-from-labeled-examples/book-section.md
Transcript for accessibility and fallback

# Learning from Labeled Examples — complete non-video alternative All objects, labels and values are synthetic. This original animation does not demonstrate a deployed robot or safety-rated controller. ## 0:00 — Perfect training. Wrong bin. **Visual mechanism:** A wheeled sorting cart carries a narrow parcel toward a fork with N and W bins. The proposal points toward W; the cart stops before a visible hold gate. **Complete narration:** This robot sorter gets every training package right. Tomorrow, a narrow package heads toward the wide bin. Did the robot forget? Not necessarily. A changed measurement can break a learned rule without changing its code. ## 0:15 — Learn from labeled pairs **Visual mechanism:** A camera scans a parcel; a width bracket becomes x=4. A separate inspection card supplies label N. Both arrows feed a training pair, not a motor. **Complete narration:** Each example pairs an input feature with a reference label. Here, the feature is a simulated camera width, and the label is narrow or wide. People define the task and check the labels. The model does not discover what our categories ought to mean. ## 0:33 — Move a rule. Count errors. **Visual mechanism:** Six labeled points on a vertical width axis. The candidate threshold moves from 3.5 to 5; C changes prediction and the training-error counter moves from one to zero. **Complete narration:** Our model predicts narrow below a threshold and wide otherwise. Try the candidate thresholds on six training examples. At three point five, one label is wrong. At five, none are wrong. Fitting chooses five from the data. We engineered the model family; the threshold was learned. ## 0:55 — Three sets. Different jobs. **Visual mechanism:** Three stacked trays label training, validation and test roles. A second frame A2 approaches the test tray, meets a rejection mark and returns to the training group. The instruction is to freeze choices before final testing. **Complete narration:** Training fits the rule. Validation guides development choices. Freeze those choices before the final test. Keep related frames of one object together when testing new objects. Otherwise, a familiar package can leak into the test. Even two correct unseen examples cannot prove reliability. ## 1:17 — Inference does not retrain **Visual mechanism:** Two unseen objects pass a camera one at a time, a fixed t=5 rule produces N and W, and comparison cards record 2/2 nominal test. **Complete narration:** With the threshold frozen at five, a new width of three point five predicts narrow. Six point five predicts wide. Both match this tiny nominal test. Report two out of two and the conditions, not a guarantee. The labels check the predictions; they are not inputs to inference. ## 1:38 — Same object. Different x. **Visual mechanism:** The same narrow object is measured; a +3 bias pulse changes its readout from 3.5 to 6.5. The proposal changes N to W, and a reference N card exposes the error. **Complete narration:** Now add three to each measurement as a separate stress test. The narrow object reads six point five and is predicted wide. The labels and threshold stayed fixed, but accuracy fell to one out of two. More copies of yesterday's data do not represent this changed condition. ## 1:58 — Does a prediction permit motion? **Visual mechanism:** Prediction W card feeds a closed dispatch gate. Sensor checked = no. Cart remains stationary while four seconds of untimed-friendly retrieval countdown is shown. **Complete narration:** The classifier proposes wide, but the sensor condition has not been checked. Should the robot dispatch a new movement? Name the missing evidence before you continue. **Untimed retrieval prompt:** Pause here and give your own answer before reading the next section. The video allows four seconds, but this alternative has no time limit. ## 2:14 — Prediction is not permission **Visual mechanism:** Sensor and route checks remain separate from the model output. A held cart and crossed dispatch arrow clarify that this is only a simulation policy. Closing three-step summary is labeled fit, test, evidence. **Complete narration:** No. Keep new dispatch on hold while the sensor condition is unresolved. A class label does not verify a route or make motion safe. Try the sorter lab and paper alternative in the AI Robotics course. Fit the rule, protect the test, and explain a failure with evidence. The camera feature is in model units. N/W mean narrow/wide. The fitted rule is N if x < 5, W otherwise. The reference labels are independent of the injected measurement bias. A category prediction is not motion authority.

Reading lab

Core explanation

Connect the lesson's words, diagrams, graphs, evidence, and equations.

The sorter labels every training package correctly. A sensor changes, and the next narrow package goes toward the wide bin. Did the robot forget—or did we ask the wrong question when testing it?

Learning outcomes

  • Separate an input feature, a target label, a learned parameter and a control command.
  • Fit and inspect a tiny classifier using labeled training examples.
  • Plan training, validation and final testing without mixing related objects across sets.
  • Explain a failure under a changed measurement and preserve explicit intervention boundaries.

Prerequisites: module 6 perception errors and 9.3 evidence versus authority. Budget: 10 minutes concepts, 10 worked example, 25 lab, 10 quiz/reflection. No robot, paid service, package installation or video is needed.

Before / During / After

Before: Predict what “six out of six training examples correct” establishes. Is it enough to send motor commands?

During: Follow a package from camera measurement through a threshold to a proposed bin. Watch the threshold move only during fitting. Notice which observations are withheld.

After: Explain why adding three to a measurement can change a prediction without changing the trained model. Complete the same trace with the paper data below.

Watch the complete Humanoid Hub tutorial. The descriptive transcript and paper alternative cover the same learning without video.

1. What is learned?

A feature is an input available when making a prediction. A label is the target supplied with a training example. In our original simulation, the input is an extracted width, x, and the target is an inspected category: N for narrow or W for wide. The model is a threshold, t: predict N when x < t; otherwise W. Inference means applying the fixed rule to another input. Google's supervised-learning introduction describes these roles.

We deliberately engineer the model family, input representation and label definitions. Fitting selects t from data. A model need not be a neural network to be learned. A rule with a manually chosen t and a rule with a fitted t can have the same inference code; the source of the parameter differs.

The scalar is not a physical ground-truth dimension: it is a fictional camera-derived measurement in model units. We assume the inspection labels are the reference for this exercise. Ask who labeled real data, using what definition, and how disagreements and ambiguous cases were handled. A model can learn an annotation mistake.

2. Fit a rule you can inspect

Training objectABCDEF
Width feature x234678
Reference labelNNNWWW

Try each candidate threshold and count wrong predictions. We test midpoints between successive observed values plus one outer value at each end. Ties choose the lowest threshold.

Threshold t1.52.53.556.57.58.5
Training mistakes / 63210123

The selected t is 5. For C, 4 < 5, so predict N. For D, 6 < 5 is false, so predict W. Exactly 5 is W under our stated boundary convention. No validation or test label helped select this threshold. A constant-W baseline is only 3/6 on this balanced training set.

Retrieval pause: At threshold 3.5, which training object is wrong? Try before checking: C is predicted W despite label N.

3. Give each dataset a job

Use training for fitting. Use validation for development choices, such as whether a feature or model family is useful. Freeze those choices before final testing. Do not repeatedly change a model to improve the same test result while calling that result independent. Google's split guide explains the distinction.

RoleDifferent objectsFeatures and reference labelsResult at t = 5
ValidationG, H4.5 N; 5.5 W2/2 correct
Nominal final testI, J3.5 N; 6.5 W2/2 correct

These are deliberately tiny invented sets so you can check every calculation. Two successes do not measure real deployment reliability. Report the denominator and conditions, not just “100%.” If validation leads you to revise the design, that is development—not an untouched test.

Adjacent frames of the same package share information. A second frame of A is not a genuinely new object. For an unseen-object question, keep an object's frames in one split. Testing a new site or future session requires a split designed for that question. Group-aware and time-aware evaluation are discussed in scikit-learn's cross-validation guide.

If you learn a scaler or select features, learn those transformations only from training data and reuse them consistently. Computing a normalization value using the final test set leaks information into the pipeline. scikit-learn's pitfalls guide explains why fitting and transformation are different operations.

4. Change the sensor, not the labels

Freeze t = 5. As a separate stress scenario, add +3 to each nominal test measurement. Package I is still labeled N, but its reported width is now 6.5, so the model predicts W. J reports 9.5 and predicts W correctly. The result is 1/2, including an N-to-W error. The object labels and threshold did not change; the input relationship did.

This is a controlled counterexample, not a claim that every camera failure is a constant offset. More copies of the old training rows do not represent a new sensor condition. Collect and inspect relevant evidence, check preprocessing/calibration, develop with an appropriate validation set, and reserve new testing for the revised pipeline. Do not silently retrain on the failed test and reuse its score as independent evidence.

5. A prediction is not permission

Training pairs fit a threshold; unseen inputs produce predictions, and separate checks gate dispatch.

Open the learning and dispatch diagram. Equivalent text: training pairs fit t=5; a new width gets a category prediction; an independent reference label evaluates it; separate sensor and route checks decide whether this simulation may propose new dispatch.

Our diagram separates data/model evaluation from a proposed bin and an explicit dispatch check. A learned category alone does not check clearance, contact, braking, people nearby or sensor validity. MIT's manipulation notes describe combining learned perception with planning and control. Our simulator holds new dispatch when the sensor condition or route is unchecked; it never controls hardware.

The hold gate demonstrates separation of responsibilities, not certified protection. As in 9.3, a software state must not be mistaken for proof of a physically safe machine. No probability of correctness is computed by this one-threshold classifier.

Misconceptions and transfer

  • “Training perfection means understanding.” It only describes those labeled rows under that evaluation.
  • “Two camera frames are two independent objects.” Their shared object or session may leak information.
  • “More rows always help.” Repetition cannot supply absent conditions; wrong labels can reinforce errors.
  • “A high class score makes an action safe.” This model has no confidence score, and prediction and motion authority are distinct.

Try the lab, then the seven-question check. Submit a threshold calculation, a split rationale, a sensor-shift counterexample and a limitation. Takeaway: define the target → fit on training data → develop honestly → test on suitable unseen cases → keep control checks explicit. Next lesson distinguishes learning from demonstrations and rewards.

Full source/rights details are included below. Full non-video mechanism: descriptive transcript.

10.1 source and rights ledger

Fresh primary-source retrieval: 2026-10-12 UTC. Original synthesis, synthetic data and diagrams; no third-party figures, footage, datasets, exam questions or source code are copied.

KeyPrimary source and publisherClaim supportedRights and limits
google-supervisedSupervised Learning — Google DevelopersFeatures, target labels, fitting, evaluation and inference have different roles.Page states CC BY 4.0 except otherwise noted; link and short original paraphrase only. No diagrams or exercises reproduced.
google-splitDividing datasets — Google ML Crash CourseSeparate development and final testing; duplicate examples can inflate evidence; reused tests lose independence.Page states CC BY 4.0 except otherwise noted. Our split sizes are invented teaching choices, not a recommendation for practice.
sklearn-leakageCommon pitfalls — scikit-learnFit transformations on training data; apply the same fitted transformation to other data; avoid test-driven choices.Link and paraphrase only; no library code reproduced. Stable docs inspected as 1.9.1; lab has no scikit-learn dependency.
sklearn-groupsCross-validation — scikit-learnRelated observations need group-aware separation; chronological data can require temporal evaluation.GroupKFold and time-series sections inspected. Object/session grouping here is our application of the principle, not a universal split recipe.
mit-perception-learningDeep Perception for Manipulation — Russ Tedrake, MITLearned perception can be combined with explicitly engineered planning and control.Working notes, subject to change. Link and concise paraphrase; no copied images or unverified performance claims.

The supervised-learning index was inspected for orientation, not used as evidence for a particular algorithm. Two initially attempted Google Crash Course URLs returned tool errors; the working Intro-to-ML supervised page was inspected instead. No claim relies on failed retrieval.

Original example and checks

N and W are narrow/wide package categories assigned by a fictional inspection process. A simulated image extractor reports a scalar width feature in model units. Train rows A–F, validation G–H and test I–J are different object IDs. The threshold family and lowest-threshold tie policy are explicitly engineered; the fitted threshold is selected by training errors. This is supervised learning even though its model is one number.

Candidate midpoints: 1.5, 2.5, 3.5, 5, 6.5, 7.5, 8.5. Training error counts: 3, 2, 1, 0, 1, 2, 3. The constant-W baseline gets 3/6 on training and 1/2 on the balanced two-item test. Validation is 2/2 and untouched nominal test is 2/2 at threshold 5; these tiny constructed sets are arithmetic demonstrations, not empirical robot performance. A +3 sensor bias on test produces 6.5 and 9.5, both predicted W; one of two is wrong. This separate stress scenario does not replace the frozen nominal test.

The missing-label and wrong-label risks, explicit sensor/route checks, and synthetic sorter animation are original teaching constructions. No classifier confidence is computed. A HOLD decision is a simulated dispatch gate, not an emergency stop. Real perception, sensor calibration, actuation, braking, collision avoidance and safety are not validated.

Assessment alignment

Q1 feature/target; Q2 threshold fit; Q3 split roles; Q4 object-group leakage; Q5 changed measurements; Q6 evaluation limits; Q7 model versus control authority. Every option has a diagnostic explanation. The lab includes label quality and asks for prediction, numerical evidence, scope and a counterexample.

Practice labFit, Freeze, and Challenge the SorterOpen this when you are ready to apply the model, collect evidence, and check your explanation.25 min

Objective

Explain whether a fitted rule keeps working when input measurements change. Predict a threshold, a nominal test result and a shifted result using the lesson tables. All examples are synthetic model units; no hardware control or reliability certification.

Materials

Paper and the lesson tables meet every outcome. Optional: Node.js and model.mjs plus model.test.mjs in one folder. Run node model.test.mjs after predicting the seven cases; it checks the model and prints their summaries. No paid service, external dataset or robot is needed. Budget 25 minutes.

Steps

  1. For training A–F only, count errors for thresholds 1.5, 2.5, 3.5, 5, 6.5, 7.5 and 8.5. At equality predict W. Choose the fewest mistakes; ties choose the lower threshold.
  2. Trace Fit. Record the selected threshold, six predictions and comparison with always-W. Distinguish the chosen model family from the parameter selected by data.
  3. Predict G/H validation labels; trace Validation. If you changed the rule after seeing them, record that as development. Freeze the selected pipeline before tracing Nominal test on I/J.
  4. Trace Shift +3 as a separate stress case, with labels and threshold frozen. List each changed input, prediction and reference label. Identify the direction of the error instead of reporting only a percentage.
  5. Trace Wrong training label: C is annotated W rather than N. Fit that damaged training copy. Compare perfect training fit with validation performance. Restore the original dataset afterward; the code never mutates it.
  6. Trace Related-frame leakage: an extra test row is a second frame of object-A. Identify its original group and explain why a random row split answers a weaker question than a new-object split.
  7. Trace Hold on unchecked sensor. Explain why a model output must not bypass the independent sensor/route policy. This is a simulated proposal, not hardware stopping.

Expected Result

CaseExpected observationInterpretation
Fitt = 5; 6/6 trainingLowest empirical error among tested candidates
Validation2/2Tiny development check, not proof of reliability
Nominal test2/2Report denominator and constructed conditions
Shift +3I: 6.5 → W but N; J: 9.5 → W and W1/2; input bias exposes a counterexample
Wrong labelt = 3.5; 6/6 damaged training; 1/2 validationA perfect fit can reproduce a labeling error
Related frameobject-A appears in train and testGroup leakage detected
HoldHOLD; sensor condition uncheckedPrediction does not authorize dispatch

Paper alternative

Draw ten labeled cards from the lesson's tables and three envelopes named Train, Validation and Test. Slide a pencil threshold across a number line. Count predictions with x < t on the left, W otherwise. Keep I/J in the Test envelope until the design is fixed. Add three to their numbers for the separate stress case. No color, scissors, timing or animation is needed. Use the expected-results table to check every case without animation.

Troubleshooting

  • If threshold 3.5 appears on clean data, check C's label and the less-than comparison.
  • If test score looks perfect under +3, check that I remains N; do not recompute the reference from the biased measurement.
  • If import fails, keep both .mjs files together and use Node.js, or choose paper.
  • The optional model prints results only and does not save learner data.

Reflection Questions

  1. Why is six correct training rows not a reliability claim?
  2. What changes and what stays fixed in the +3 case?
  3. Why must related frames stay together for an unseen-object test?
  4. What remains unchecked by a class prediction?

Extension Challenge

Invent a new labeled example at x = 5 and state how an inspection rule could justify N or W. What does disagreement mean for the one-feature model? Do not add it to an already reported final test without versioning the test. Design a different split for a new camera session.

Submit: threshold/error table; two test traces; group-split rationale; one limitation; an explicit separation between classification and dispatch. Rubric: calculations 40%, experimental separation 30%, failure explanation 20%, limits 10%. No physical robot commands are permitted.