Skip to content
Exit presentation

How AI Learns I: From Rules to Data

Right out of how many

The program guessed. The seller knows the real word. How many guesses were right?

Loading lab…

Five kept-back crates: a guess and a real word each.
Step 1 of 4
  1. Five kept-back crates: a guess and a real word each.
  2. Pair 1: full, full. They agree. Tally: 1.
  3. Pairs 2 and 3 agree too. Tally: 3.
  4. Pairs 4 and 5 disagree. Final count: 3 of 5.

The rule

Check the pairs one at a time and count the matches. Here 3 of 5 match.

Walk both lists together. Add one when a pair agrees. Hand back the count. Two lists that agree on nothing give 0.

  • guesses — what the rule said about each kept-back crate.
  • labels — the seller's real word on each one.

The count of right guesses, out of all guesses, is the accuracy. Here it is 3 of 5.

Five kept-back crates: the rule guessed, the seller decided
CrateGuessReal wordAgree?
1fullfullyes
2cutcutyes
3cutcutyes
4cutfullno
5fullcutno

The function agreed(guesses, labels) starts a box, count, at 0. A while loop visits both lists, one pair per turn. Here i is the position, starting at 0. So position 0 is crate 1. An if checks guesses[i] === labels[i]. The sign === asks if two values are the same. On a match, the box adds one. The box goes 1, 2, 3, 3, 3. Then return count gives back the number in the box.

Jump to lesson

This track

  1. 0 Start here
  2. 1 A rule a person wrote, and a pile of examples
  3. 2 Keep some crates back
  4. 3 Right out of how many
  5. 4 Split it differently
  6. 5 Learning the examples instead of the pattern
  7. 6 Ask more than one
  8. 7 The order you do it in
  9. 8 Write the rule yourself
  10. 9 The big picture
  11. 10 Track quiz

Other tracks