Each fruit is two numbers, [size, redness]: size in cm, redness from 0 (green) to 10 (bright red). Write classify(point, known_points, labels): given a new fruit and the fruits you already know, return the label of the known fruit it’s most like.
You know four fruits by size and redness. A new fruit turns up. Which known fruit is it most like? Move the new fruit, or guess.
classify(point, known_points, labels)| point | a new fruit, [size, redness] | e.g. [7, 1] |
| known_points | fruits you already know, one [size, redness] each | e.g. [[2, 9], [8, 8], [7, 1], [12, 3]] |
| labels | their names, e.g. "apple" | e.g. ["cherry", "apple", "lemon", "grapefruit"] |
| returns | the label of the known fruit it's most like | |