1 of 53

Supervised

Learning

Session 3

ACM AI + ACM TeachLA

Slides Link:

https://teachla.uclaacm.com/classes/ml

2 of 53

What are you going to be for Halloween?

3 of 53

Recap

4 of 53

Key Terms

  • Artificial Intelligence - The theory and development of computer systems able to perform tasks that normally require human intelligence.
  • Machine Learning - A type of AI that provides computers with the ability to learn without being explicitly programmed.
  • Deep Learning - An ML learning method based on artificial neural networks.

5 of 53

AI

  • if-else statements
  • Decision Trees + Bayesian decision-making
  • data mining

ML

  • supervised learning
  • unsupervised learning
  • reinforcement learning
  • deep learning
    • neural networks

  • natural language processing

6 of 53

Supervised Learning?

It's one of the most widely used forms of machine learning!

7 of 53

Supervised

guided

helped

directed

8 of 53

Let’s imagine a basketball game...

...with 3 seconds left, down by 1!

0 : 0 3

99

Team Lebron

100

USC

9 of 53

0 : 0 3

99

Team Lebron

100

USC

Our captain (Mr. Supervisor)

has the ball (input)!

input

10 of 53

0 : 0 3

99

Team Lebron

100

USC

but is trapped!

11 of 53

0 : 0 3

99

Team Lebron

100

USC

Mr. Supervisor passes to Mr. Model who can score!

MODEL

12 of 53

MODEL

However, Mr. Model actually doesn’t know how to play basketball 😳

. . .he was given the ball (input data) but. . .

input

. . .doesn’t know what to do (output)

output

13 of 53

MODEL

Mr. Model needs a supervisor to point him in the right direction. . .

input

output

Mr. Supervisor is here to tell him the output (what he should do)

14 of 53

MODEL

Mr. Supervisor: I DON'T CARE HOW you do it, just make sure the ball goes in the basket!

output

input

15 of 53

MODEL

input

output

output

Now that Mr. Model has an idea of the end result (output). . .

Mr. Model can use the ball (input) to score!

16 of 53

MODEL

input

labeled

output

Now that Mr. Model has an idea of the end result (output). . .

Mr. Model can use the ball (input) to score!

In other words. . .

The model uses input and labeled output

data to map the input to the output

17 of 53

Input Data

ML Model

Labeled Output Data

it’s like a big math function!

*Except instead of figuring out the output, we’re figuring out the relationship of input->output

Supervised Learning:

The model (function) uses input and labeled

output data to map the input to the output

18 of 53

For reference...

Normal/AI outside ML

    • Given: input and defined relationship / function
    • Find: the output

f(x) = y

Machine Learning

    • Given: input and output
    • Find: the relationship / function

f(x) = y

19 of 53

Supervised Learning:

The model (function) uses input and labeled

output data to map the input to the output

Input Data

ML Model

Labeled Output Data

take a moment to let that sink in!

It’s “supervised” because we tell the model the labeled output beforehand

20 of 53

Recap So Far:

  • A Machine Learning model is a big function
  • A Supervised Machine Learning model uses labeled output data, hence the name “supervised”
    • Labeled: output data we help give the model
  • Supervised Learning maps the relationship of: � input → labeled output

21 of 53

22 of 53

Training Models

Not these types of models!

23 of 53

Mapping? Learning?

  • Supervised machine learning is all about “mapping” the relationship of input to output
  • But how exactly does it “map?” (given input and output)

map

24 of 53

Mapping? Learning?

  • Supervised machine learning is all about “mapping” the relationship of input to output
  • But how exactly does it “map?” (given input and output)

Let's take a look at our basketball example again...

25 of 53

input

output

Recall that Mr. Model doesn’t know how to play basketball

MODEL

He doesn’t know how to:

  • shoot
  • dribble
  • dunk!

He has to train to learn those skills!

26 of 53

Training

So in order to map input to output consistently...

27 of 53

Training

So in order to map input to output consistently...

Mr. Model must train so he gets good at scoring baskets

(input → output)

input

MODEL

28 of 53

A Model in Training

  • A model “training” means it’s learning ways to correctly map input data to output data
  • Hence “machine learning
  • “Training” and “Learning” are interchangeable terms

29 of 53

A “Trained” Model

So after hours of training… Mr. Model is now trained and able to score hoops!

MODEL

Training a machine learning model is a long, hefty mathematical process

We’ll learn how it specifically works in the coming weeks!

input

30 of 53

31 of 53

How to Effectively Train Models

32 of 53

Effective Training

During preseason, in preparation for the NBA season Mr. Model trains a lot

MODEL

He trains by playing against the B team, his training data

B Team

33 of 53

A training dataset is any dataset that allows our model to train (map input -> output)

B Team

MODEL

In our case, the B Team is our training dataset: Mr. Model trains on them in order to learn how to play bball

Let’s take a closer look at our B Team data!

34 of 53

Training on the B Team

4 feet

The average height of the B Team is 4 feet. . .

So Mr. Model just dunks on them everytime

**It’s so effective, it becomes the only thing Mr. Model learns how to do

B Team

(Training Data)

35 of 53

Testing our training abilities

Now that preseason is over, it’s time to test Mr. Model’s new bball skills...

Training Data

(Preseason)

Trained Model

...on the NBA!

36 of 53

Test Dataset

When we want to test to see if our model is well trained, we test our model on a test dataset

Test Data

(NBA)

The test dataset is an example of what the model will see in the real world…

it’s a true test of its abilities!

37 of 53

Effective Training??

As we test Mr. Model plays against the tall, skilled players of the NBA we almost forgot...

MODEL

…that he only knows how to dunk!

He’s only able to dunk on people that are 4 feet tall! (B Team)

38 of 53

(In)effective Training

Did Mr. Model have good training? Especially if he plans to play against the tall, skilled players of the NBA?

MODEL

8 feet!

39 of 53

(In)effective Training (cont’d)

MODEL

Did Mr. Model have good training? Especially if he plans to play against the tall, skilled players of the NBA?

NO

40 of 53

Mr. Model has become so accustomed to dunking on the short players of the B Team that. . .

MODEL

. . .he sucks at playing against anyone taller than 6 feet because dunking won’t work on them!

Mr. Model had bad training!

(In)effective Training (cont’d)

41 of 53

Overfitting

Whenever a model has become too accustomed to a specific dataset (playing against B team too much), it’s called overfitting.

  • The model is too mode-specific
  • Not “general” enough to handle real-world randomness
    • Randomness of players: tall AND short, fast AND slow, good AND bad, clueless AND intelligent

42 of 53

Overfitting (cont.)

  • Overfitting occurs when model becomes too sample-specific (only knows how the B Team plays)
  • Generally, a model should be trained to perform well on the entire population of data (well-rounded players)
    • Better for Tesla cars to drive all streets decently well rather than one specific street perfectly

43 of 53

Combatting Overfitting

What are some ways Mr. Model could’ve avoided overfitting?

  • Playing against diverse set of teams/players
    • Use a diverse input/output dataset for your model
  • Train more! Train skills other than dunking too
    • Using more diverse data for your model always helps

44 of 53

Combatting Overfitting (cont.)

What does this tell us about the training dataset?

B Team

(Training Data)

4 feet

BAD!

  • Our training dataset was NOT diverse enough!
  • Ideally, we want the training dataset to fairly represent the majority of the population

45 of 53

**Avoid training against a small subset of your population, or else you’ll get creamed like Mr. Model in the NBA!

46 of 53

Underfitting

Conversely, if Mr. Model is lazy (doesn’t have much data to train on) he can be susceptible to underfitting

MODEL

Underfitting: when the model is too basic, and doesn’t work effectively in most situations

How do we combat this?

Gather more data to train on!

47 of 53

  • Predictor variable: any input variable used to measure output

Training (graphically)

48 of 53

  • Predictor variable: any input variable used to measure output

The black dotted line represents our model.

Training (graphically)

Amount of water given

Amount of water given

Amount of water given

Growth

Growth

Growth

49 of 53

¡Kahoot!

50 of 53

Homework (optional)

51 of 53

Closing Comments

52 of 53

Key Takeaways

  1. Supervised ML Models are just big functions!
  2. ML Models “train”: finding the relation between �input → output
  3. Train on A LOT of diverse data to avoid overfitting/underfitting

53 of 53

Thanks!

Fill out our Feedback Form: https://tinyurl.com/aimlworld

  • - -

Check out our Github

Read our Blog

ACM AI