Class prep · TJ Machine Learning

Read the label.Then apply the rule.

An independent course in machine learning. Practice residuals, an exact line, nearest neighbors, one entropy split, train and test counts, a confusion table, one perceptron step and one backup, and check every result by hand. Every problem has a full worked solution. Built by Neil Kothari, a TJ alumnus.

$395 covers the full school year. The first lesson is free.

Try one. This is a test-level question from the course.

Problem 1

  • Test level
  • Multiple choice
  • No calculator
  • 4 pts

A study records hours of sleep (the feature) and reaction time in milliseconds (the label) for three students:

rows = [[8, 250], [5, 310], [7, 270]]
flipped = [[y, x] for x, y in rows]

A model trained on flipped treats column 0 as its feature and column 1 as its label, just like any other table. What is flipped[1][1], and what role does it play in flipped?

Choose one answer

original problems, each with a worked answer
624
original problems, each with a worked answer
at test level or beyond
432
at test level or beyond
short lessons, one for every topic
48
short lessons, one for every topic
units, all open now
8
units, all open now

Free lesson

Lesson 1.1: A feature and a label

Each row of a data table is one example, where the first column is the feature you already know and the second column is the label you want to predict.

Start with one feature and one label. The next lesson subtracts a stated prediction from that label.

Start with a question

You are trying to get better at free throws. For five days you write down two numbers: how many minutes you practiced, and how many free throws you made out of 20 the next morning.

DayMinutes practicedFree throws made
1106
22511
354
43013
5158

Tomorrow you plan to practice for 20 minutes. How many free throws should you expect to make?

That is exactly the kind of question machine learning answers. A model is a rule that takes the number you know (minutes) and guesses the number you do not know yet (free throws made). Before you can build or test any rule, you have to be clear about two things: which column is the input, and which column is the answer. That is this whole lesson.

By the end of this lesson you will be able to:

  • name the feature and the label in a data table or a real situation,
  • read any entry of a table stored in code, like rows[3][1], counting rows from 0,
  • count the examples in a table and add up one column,
  • explain why swapping the two columns changes the question the table answers,
  • say what a prediction is and why it is not stored in the table.

Four words you need

Every machine learning table in this unit has the same shape. Here are the words, in plain language first.

  • An example is one row of the table: one thing you measured one time. In the free-throw table, one day is one example.
  • The feature is the number you know ahead of time. It is the input to the rule. Here it is minutes practiced. We call it xx.
  • The label is the number you want to predict. It is the true answer, the thing that really happened. Here it is free throws made. We call it yy.
  • A prediction is the model's guess for the label. We call it y^\hat{y}, which you read as "y-hat." The little hat means "a guess for yy."
WordPlain meaningIn the free-throw tableSymbol
exampleone row, one measurementone daya row
featurewhat you know first (the input)minutes practicedxx
labelwhat you want to guess (the true answer)free throws madeyy
predictionthe model's guess for the labelnot in the tabley^\hat{y}

The label and the prediction are easy to mix up, because both are about free throws. The label is what actually happened. The prediction is what the model guessed would happen. They can be different, and the rest of this unit is about measuring that difference.

How to tell the feature from the label

When you meet a new situation, use these steps.

  1. Ask: "At the moment I need an answer, which number do I already have?" That number is the feature.
  2. Ask: "Which number am I trying to guess?" That number is the label.
  3. Check: the label usually happens later, costs more to measure, or is the thing someone actually cares about.

Quick check 1. A phone app wants to predict your battery percentage at 3 p.m. from the number of minutes of screen time you have used since a full charge that morning. Which number is the feature and which is the label? Answers are at the end of the lesson.

Worked example 1: name the feature and the label

Situation. A teacher wants to predict each student's unit test score from the number of practice problems the student finished the week before.

  1. Which number do you have before the test? The number of practice problems. So the feature xx is practice problems finished.
  2. Which number are you trying to guess? The test score. So the label yy is the test score.
  3. One example (one row) is one student: [practice problems, test score], for instance [40, 88].

Check: at the moment the teacher wants a prediction, the test has not happened yet. So the test score cannot be the input. It has to be the label. That matches.

Problem 2

  • Core
  • True or false
  • No calculator
  • 2 pts

A swim coach records, for each swimmer, the hours of practice in a week (the feature) and the points that swimmer scored at the weekend meet (the label):

rows = [[12, 30], [7, 19], [20, 44]]

True or false: rows[2][0] is 20, the feature of the third swimmer in the list.

Is the statement true or false?

Problem 3

  • Core
  • Multiple choice
  • No calculator
  • 4 pts

A tutoring center records, for each student, the hours of tutoring (the feature) and the increase in quiz score (the label):

rows = [[3, 5], [13, 27], [8, 17], [10, 21], [1, 4]]

What is rows[3][1]?

Choose one answer

Open the rest of this lesson, free

The full lesson and all 13 of its problems, with every worked answer.

I am aI am a

Your free lesson opens right here, on this device for 30 days. We'll email you occasional TJ class prep updates. Unsubscribe anytime.

How it works

Class prep that works alongside class

A complete machine learning course for students taking Machine Learning at TJ. Work alongside class or study the material in sequence. Each lesson states a rule, runs it on a small table, and shows the check before you try the practice.

  • Original problems in several formats: true or false, multiple choice, multi-part and free response.
  • Each one is marked core, test level or beyond.
  • Residuals, an exact line, squared distance, an entropy code, train and test counts, a confusion table, one perceptron step and one backup.
  • A worked answer for every problem, ending with the mistake that most often costs points.
  • Integer division only where it is exact. Entropy codes are 0 or 1. Labels in the perceptron step are 1 and -1.

What is inside

  1. 1Features, labels, and residuals6 lessons · 78 problems
  2. 2Exact least squares6 lessons · 78 problems
  3. 3Nearest neighbors6 lessons · 78 problems
  4. 4Entropy and one split6 lessons · 78 problems
  5. 5Train error and test error6 lessons · 78 problems
  6. 6Accuracy from a confusion count6 lessons · 78 problems
  7. 7One perceptron step6 lessons · 78 problems
  8. 8One backup6 lessons · 78 problems
The front entrance of Thomas Jefferson High School for Science and Technology
Neil Kothari, co-founder of EduAvenues

Who built it

Neil Kothari

TJHSST alumnus · Co-founder, EduAvenues · 10+ years in TJ preparation

Neil is a TJ alumnus and has spent more than a decade working with TJ students and their families. He built this course so a student can run a learning rule on a small table and check the result by hand. Every problem is written for the course and every answer is checked before it goes in.

Tuition

$395for the full school year

One tuition covers every unit of the course. All 8 units are open now. The A feature and a label lesson stays free for everyone.

  • All 8 units: 48 lessons and 624 original problems
  • A worked answer for every problem
  • Access through the end of the school year
Enroll