Module 3.2
How can a computer learn to classify objects from examples?
Living and Working with Artificial Intelligence
Developed for the AI4GA (Artificial Intelligence for Georgia) project funded by National Science Foundation awards DRL-2049029 and DRL-2048502.
Additional funding was provided by a gift from Google. This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-nc-sa/4.0/
2
Learning Objectives
Students should be able to:
Try It #1: Candy Land - Creating a Candy Classifier
Setup: (a) Get a handout for drawing your tree; (b) use candy or cut out pictures of candy that you can move around the nodes of your tree.
Step 1: Propose a bunch of features to distinguish between the candy types,
Step 2: Pick a feature that will split the candy into two roughly equal groups.
Step 3: Take the features, build the decision tree.
Step 4: Test this out and update the features and the tree.
Step 5: Convert the tree into a table.
3
4
Gummy Worm
Reese
skittles
Mentos
Cadbury Egg
Hershey Bar
lollipop
Candy Data Set
5
Features |
|
|
|
|
|
|
A feature is a property of a thing we are trying to describe.
Write features for the candies in our dataset.
Features |
|
|
|
|
|
|
Features |
|
|
|
|
|
|
Features |
|
|
|
|
|
|
Features |
|
|
|
|
|
|
Features |
|
|
|
|
|
|
Features |
|
|
|
|
|
|
6
A feature is a property of a thing we are trying to describe.
Pick a feature from your last slide that roughly half of your candy shares. Turn that feature into a question that can be answered with yes or no and write it in the red box. This is the root node, the beginning of your decision tree.��
Question 1
7
Question 1
Question 2
Question 3
Yes
No
Step 4: Create two children of the current node and split its candies between them based on the feature.
8
Question 1
Question 2
Question 3
Yes
No
Done?
Done?
Yes
No
Step 4: Create two children of the current node and split its candies between them based on the feature.
Now that we’ve created our classifier
We can describe candy using feature vectors.
A feature is a property of a thing we are trying to describe.
A featurE Vector is an ordered list of properties.
9
Candy Air Head | Is it round? N | | |
Our feature vector:
Feature Vector Description of Candy: Respond yes or no
10
Candy | Is it multicolor? | Is it round? | Is it chocolate? | | | | |
Gummy worm | | | | | | | |
Lollipop | | | | | | | |
Skittles | | | | | | | |
Cadbury egg | | | | | | | |
Hershey bar | | | | | | | |
Chocolate bunny | | | | | | | |
Mentos | | | | | | | |
Feature Vector Description of Candy: Respond yes or no
Possible Answers
11
Candy | Is it multicolor? | Is it round? | Is it chocolate? | | | | |
Gummy worm | yes | no | no | | | | |
Lollipop | yes | yes | no | | | | |
Skittles | yes | yes | no | | | | |
Cadbury egg | no | yes | yes | | | | |
Hershey bar | no | no | yes | | | | |
Chocolate bunny | no | no | yes | | | | |
Mentos | no | yes | no | | | | |
Use this test set to see how effective your features are at classifying a new set of candies
12
Baby Ruth
M & Ms
Candy Canes
runts
Sour Punch Straws
Whoppers
Pick 3 candies
Test Set - Data Collection Sheet
13
Candy | Correctly classified | Incorrectly classified |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
Feature Vector Description of Candy
Add more columns to fit all your features & more rows to fit all your candies
14
Candy | Is it multicolor | Is it round | Is it a quadrilateral |
M&M | | | |
Candy canes | | | |
Candy corn | | | |
Runts | | | |
Sour punch straws | | | |
Baby ruths | | | |
Whoppers | | | |
| | | |
| | | |
Feature Vector Description of Candy
Add more columns to fit all your features & more rows to fit all your candies
15
Candy | | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
Reflection
How well did your candy classifier do on this new test set? What candies did it classify incorrectly?
Were your features flexible enough to allow you to classify new candy? Why or why not?
How would you change your features to allow them to better classify a wider range of candies?
16
Takeaways
17
If your data is in a feature vector table like this then you don’t have to build the tree yourself
People don’t usually build decision trees by hand because for realistic tasks it can be hard.
For practical problems, people build a table that may have thousands of rows (examples) and dozens of columns (features). Each example is labeled with the correct decision (i.e., the class it belongs to).
Then they use a machine learning algorithm to create the decision tree.
18
Machine Learning is a process for constructing a reasoner (such as a decision tree classifier) using training data and a learning algorithm.
Let’s look at some real-world examples:
19
Try It #2: Think of a real-world example:
Step 1: Pick a situation in the real world where computers might make decisions
Step 2: Think about the attributes that would contribute to making good decisions ��Step 3: Reflection: Think about how your life is being affected by classifier systems (automated decision making).
Examples
20
Computers don’t learn the way people do.
21
How do people learn?
22
Discussion
Ways people learn:
23
Note: None of these are things that computers currently do well.
Ways Computers Learn
24