0% found this document useful (0 votes)
23 views

Supervised Learning Overview, Formulation, Train-Test Split: EE514 - CS535

This document provides an overview of supervised machine learning. It defines machine learning and the goal of making a system learn from examples to make predictions. It describes the process of using training data to build a model using an algorithm, and then making predictions on new data. It discusses supervised learning problems like regression and classification, and the process of splitting data into training and test sets to evaluate a model's performance on new data and avoid overfitting. Key terms like features, labels, loss functions, and generalization

Uploaded by

Zubair Khalid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Supervised Learning Overview, Formulation, Train-Test Split: EE514 - CS535

This document provides an overview of supervised machine learning. It defines machine learning and the goal of making a system learn from examples to make predictions. It describes the process of using training data to build a model using an algorithm, and then making predictions on new data. It discusses supervised learning problems like regression and classification, and the process of splitting data into training and test sets to evaluate a model's performance on new data and avoid overfitting. Key terms like features, labels, loss functions, and generalization

Uploaded by

Zubair Khalid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Machine Learning

EE514 – CS535

Supervised Learning Overview,


Formulation, Train-test Split

Zubair Khalid

School of Science and Engineering


Lahore University of Management Sciences

https://www.zubairkhalid.org/ee514_2021.html
Machine Learning: Overview
What is Machine Learning?
Given examples (training data), make a machine learn system
behavior or discover patterns

Data
Model

Algorithm f ( x)
Final output which
enables us to make
Given to us We need to design it predictions
Machine Learning: Overview
Algorithms vs Model

- Linear regression algorithm produces a model, that is, a vector of values


of the coefficients of the model.

- Decision tree algorithm produces a model comprised of a tree of if-then


statements with specific values.

- Neural network along with backpropagation + gradient descent: produces


a model comprised of a trained (weights assigned) neural network.
Machine Learning: Overview
Nature of ML Problems
1. Supervised Learning
The learning algorithm would receive a set of inputs along with the corresponding correct
outputs to train a model
Training Data

All labeled
Model Prediction
data
Supervised Learning
Regression
Regression: Quantitative Prediction on a continuous scale
Examples: Prediction of
- Age of a person from his/her photo
- Price of 10 Marla, 5-bedroom house in 2050
- USD/PKR exchange rate after one week What do all these problems
- Efficacy of Pfizer Covid vaccine have in common?
- Average temperature/Rainfall during monsoon
Continuous outputs
- Cumulative score in ML course
- Probability of decrease in the electricity prices in Pakistan
- No. of steps per day

Predicting continuous outputs is called regression


Supervised Learning
Classification
Classification: Given a data sample, predict its class (discrete)
Examples: Prediction of
- Gender of a person using his/her photo or hand-writing style
What do all these problems
- Spam filtering
have in common?
- Object or face detection in a photo
Discrete outputs: Categorical
- We will be back on Campus on Feb 1
- Temperature/Rainfall normal or abnormal during monsoon Yes/No (Binary Classification)
- Letter grade in ML course
Multi-class classification:
- Decrease expected in electricity prices in Pakistan next year multiple classes
- More than 10000 Steps taken today

Predicting a categorical output is called classification


Supervised Learning Setup
Nomenclature

In these regression or classification problems, we have


- Inputs – referred to as Features
- Output – referred to as Label
- Training data – (input, output) for which the output is known and is
used for training a model by ML algorithm
- A Loss, an objective or a cost function – determines how well a trined
model approximates the training data
- Test data – (input, output) for which the output is known and is used
for the evaluation of the performance of the trained model
Supervised Learning Setup
Nomenclature - Example
Predict Stock Index Price

- Features (Input)
- Labels (Output)
- Training data

?
?
?
Supervised Learning Setup
Formulation

?
?
?
Supervised Learning Setup
Formulation

Regression:

Classification:
Supervised Learning Setup
Example

Data of 200 Patients:


- Age of the patient
- Cholesterol levels
Model (h) Prediction of Oxygen Saturation
- Glucose levels
- BMI
- Height
- Heart Rate
- Calories intake
- No. of steps taken
Supervised Learning Setup
Example

Model (h) Prediction

MNIST Data:
- Each sample 28x28 pixel image
- 60,000 training data
- 10,000 testing data
Supervised Learning Setup
Learning
Supervised Learning Setup
Hypothesis Class

Q: How?
A:
Supervised Learning Setup
Q: How do we evaluate the performance?
A:

Loss Function
Supervised Learning Setup

0/1 Loss Function:


Zero-one loss is defined as

Interpretation:
- Note normalization by the number of samples. This makes it the loss per sample.
- Loss function counts the number of mistakes made by hypothesis function D.
- Not used frequently due to non-differentiability and non-continuity.
Supervised Learning Setup

Squared Loss Function:


Squared loss is defined as (also referred to as mean-square error, MSE )

Interpretation:
- Again note normalization by the number of samples.
- Loss is always nonnegative.
- Loss grows quadratically with the absolute error amount in each sample.
Root Mean Squared Error (RMSE):
RMSE is just square root of squared loss function:
Supervised Learning Setup

Absolute Loss Function:


Absolute loss is defined as

Interpretation:
- Loss grows linearly with the absolute of the error in each prediction.
- Used in regression and suited for noisy data.

* All of the losses are non-negative


Supervised Learning Setup
Learning

(Optimization problem)

Recall

Q: How can we ensure that hypothesis h will give low loss on the input not in D?
Supervised Learning Setup

Interpretation:
- 0% loss error on the training data (Model is fit to every data point in D).
- Large error for some input not in D
- First glimpse of overfitting.
Revisit:
Q: How can we ensure that hypothesis h will give low loss on the input not in D?

A: Train/Test Split
Supervised Learning Setup
Generalization: The Train-Test Split

How to carry out splitting?

You can only use the test dataset once after deciding on the model using training dataset
Supervised Learning Setup
Learning (Revisit after train-test split)

Evaluation
Supervised Learning Setup
Generalization loss
Supervised Learning Setup
Generalization: The Train-Test Split

Q: Idea:
Validation data is used evaluate the loss for a function h that is
determined using the learning on the training data-set. If the loss
on validation data is high for a given h, the hypothesis or model
needs to be changed.
Supervised Learning Setup
Generalization: The Train-Test Split

More explanation* to better understand the difference between validation and test data:

- Training set: A set of examples used for learning, that is to fit the
parameters of the hypothesis (model).

- Validation set: A set of examples used to tune the hyper-parameters of


the hypothesis function, for example to choose the number of hidden
units in a neural network OR the order of polynomial approximating
the data.

- Test set: A set of examples used only to assess the performance of a


fully-specified model or hypothesis.

Adapted from *Brian Ripley, Pattern Recognition and Neural Networks, 1996
Supervised Learning Setup
Generalization: The Train-Test Split (Example)

Cross validation simulates multiple train-test splits on the training data


Supervised Learning Setup
Reference:

• https://www.cs.cornell.edu/courses/cs4780/2018fa/

• CB: sec 1.1

• HTF section 2.1

• KM: sec. 1.1, 1.2


Feedback: Questions or Comments?

Email: [email protected]

You might also like