1 of 24

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 of 24

2

Learning Objectives

Students should be able to:

  • Explain how to use a decision tree to classify an object.
  • Demonstrate how to extend a decision tree to include a new class.

3 of 24

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.

  • Doing this every time will give you the smallest number of nodes.
  • This is similar to how real machine learning algorithms decide which feature to use for the next node.

Step 3: Take the features, build the decision tree.

  • Make sure every one of your types of candy is a leaf.
  • You may not have enough features - if you end up with two types of candy on the same leaf.

Step 4: Test this out and update the features and the tree.

Step 5: Convert the tree into a table.

  • The columns are the features (red - replace question).
  • The rows are the leaves.
  • If the feature doesn’t apply, put N/A.

3

4 of 24

4

Gummy Worm

Reese

skittles

Mentos

Cadbury Egg

Hershey Bar

lollipop

Candy Data Set

5 of 24

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 of 24

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 of 24

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 of 24

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.

9 of 24

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:

10 of 24

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

11 of 24

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

12 of 24

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

13 of 24

Test Set - Data Collection Sheet

13

Candy

Correctly classified

Incorrectly classified

14 of 24

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

15 of 24

Feature Vector Description of Candy

Add more columns to fit all your features & more rows to fit all your candies

15

Candy

16 of 24

Reflection

How well did your candy classifier do on this new test set? What candies did it classify incorrectly?

  • Ex. If it classified everything correctly the candy classifier did really well.

Were your features flexible enough to allow you to classify new candy? Why or why not?

  • Ex. I had to change a question to make it work but it all worked out in the end.

How would you change your features to allow them to better classify a wider range of candies?

  • Ex. I would change the color question.

16

17 of 24

Takeaways

17

18 of 24

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.

19 of 24

Let’s look at some real-world examples:

19

20 of 24

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

  • Classifying toys based on age. �What kinds of features make a toy suitable?
  • Classify games, movies, and music
  • Reviewing job applications. �What kinds of things help us determine the strength of a job application?
  • College applications.�What kinds of things make for a strong college application?

20

21 of 24

Computers don’t learn the way people do.

21

22 of 24

How do people learn?

22

Discussion

23 of 24

Ways people learn:

  • Being taught by someone (e.g., parent, teacher, sibling, friend)
  • Asking questions
  • Observing others
  • Reading
  • Trial and error
  • Systematic experimentation
  • Everyday life experiences

23

Note: None of these are things that computers currently do well.

24 of 24

Ways Computers Learn

  • Learning from labeled examples (like Pasta Land and Teachable Machine)
    • This is called supervised learning
    • We will only explore supervised learning in this unit�
  • Finding clusters in data
    • This is called unsupervised learning because the data does not come pre-labeled
    • Example: examining data on plants collected from a forest and decided how many different species of plants there are in the forest�
  • Learning from experience via trial and error
    • This is called reinforcement learning
    • This is how computers learn good strategies for playing games�
  • Learning by being told
    • This is called zero shot learning.
    • Large language models like ChatGPT can learn a new task by being told what to do and they will follow those instructions.

24