SlideShare a Scribd company logo
Supervised Learning:
Introduction to Supervised Learning
AAA-Python Edition
Plan
●
1- Supervised Learning
●
2- Classifcation
●
3- Regression
●
4- Features
●
5- Linear Regression
●
6- Polynomial Regression
3
1-Supervised
Learning
[By Amina Delali]
Machine LearningMachine Learning
Fit
Observed Data: described
by a set of features
Machine learning
Build
Predict
Mathematical Model with Tunable parameters
New Data
4
1-Supervised
Learning
[By Amina Delali]
Supervised LearningSupervised Learning
Fit
Labeled Observed Data
Supervised learning
Build
Predict the Labels
Mathematical Model with Tunable parameters
Fitting == minimize the cost function
( difference between True and Predicted labels )
Predicting == Apply the obtained mathematical model on the New Data
5
2-Classifcation
[By Amina Delali]
Unsupervised LearningUnsupervised Learning
●
Fit
Not Labeled Observed Data
Unsupervised learning
Build
Predict the Labels
Mathematical Model with Tunable parameters
Predicting = Extract information about New Data
6
2-Classifcation
[By Amina Delali]
ClassifcationClassifcation
●
Fit
Labeled Observed Data: The Labels are categories
Supervised learning: Classification
Build
Predict
Mathematical Model with Tunable parameters
Predict the known categories for the New Data
7
2-Classifcation
[By Amina Delali]
Scikit-LearnScikit-Learn
●
Scikit-learn is a python library used for data mining and data
analysis
●
It is build on :”Numpy”, “Scipy”, and “Matplotlib” libraries.
●
It will be used for both classifcation and regression by importing
the corresponding modules.
●
It will also be used for feature extraction
using :”sklearn.feature_extraction” module
●
The full documentation about scikit-learn, is available at its
homepage: http://scikit-learn.org/stable/index.html
8
3-Regression
[By Amina Delali]
Classifcation ProblemsClassifcation Problems
●
Fit
Observed Data: x-ray images. Labels == yes or no.
Yes == Presence of Tumor, No == Absence of Tumor
Classifying images
Predict if there is a tumor or not
New Data: Not labeled x-ray images.
Classifying text
Predict if the category of the word
New Data: Not labeled words
Fit
Observed Data: words in sentences. Labels == verb, subject, or
adjective
9
3-Regression
[By Amina Delali]
RegressionRegression
●
Fit
Labeled Observed Data: The Labels are continuous
quantities
Supervised learning: Regression
Build
Predict
Mathematical Model with Tunable parameters
Predict the New quantities for the New Data
10
3-Regression
[By Amina Delali]
Regression ProblemsRegression Problems
●
Fit
Observed Data: houses described by a set of characteristics.
Labels == prices of the houses
Photometric redshift
Predict the distance
New galaxies without the distance information
Fit
Observed Data: galaxies described by their brightness at several
wavelengths. Labels == distances of the galaxies
House pricing
Predict houses price
New Data: a set of houses described by the same set of characteristics
(with different values), but they don’t have the price indicated.
11
4-Features
[By Amina Delali]
IntroductionIntroduction
● Fit
Observed Data: the data must be described by a set of
characteristics: numerical values
Machine Learning
Predict if there is a tumor or not
The new Data: must be described by the same set but with
different values
These characteristics, aren’t always in a numerical format. They can be:
Categories Text Images
They have to be transformed in a numerical format
12
4-Features
[By Amina Delali]
Categorical featuresCategorical features
Categories One-hot-encoding
The Feature 3 is
transformed into 3 other
features each one
representing the presence
of a category belonging
to feature 3
13
4-Features
[By Amina Delali]
Text featuresText features
● Text
Word count
TF – IDF:
term frequency–inverse
document frequencyWord count
Each line will represent
a row. And each word
will represent a feature.
Features values in each
row will be the count of
the corresponding word
in the corresponding
line
Appears 0 times in line 0
Appears 2 times in line 1
14
4-Features
[By Amina Delali]
Text featuresText features
● Text
Word count
TF – IDF:
term frequency–inverse
document frequencyTF – IDF
We didn’t normalize the
results
tf −idf (t ,d)=tf (t ,d)∗idf (t)
tf (t ,d)=number of ×the termt occurs∈document t
idf (t)=ln(
1+nd
1+df (d ,t)
)+1
df (d ,t)=number of documents that containthe termt
== 1 *
(ln[(1+2)/1+1]+1 )
== 1.405465
nd=total number of documents0
15
4-Features
[By Amina Delali]
ImagesImages
● Image
Use pixel values as
features values:
number of features ==
number of pixels
Is just a
reshape
of images
16
5-LinearRegression
[By Amina Delali]
Simple Linear Regression (with 1 Feature)Simple Linear Regression (with 1 Feature)
Fit
Labeled Observed Data: described by 1 feature: x
The labels are y values. Fitting == find a and b that minimize the
difference between the real labels: y and the estimated ones.
Simple Linear Regression : 1 feature
Build
Predict
Mathematical Model== a
Line, modelized by:
Y = a x + b
with
a: the slope
b: the intercept
Predict the New y for the New not labeled x values
17
5-LinearRegression
[By Amina Delali]
ExampleExample
●
The model to train
Initialization of a
linear regressor
instance
Train the model
Predict y for new
values: actually this
new x values are
used to draw the
model
Parameters of the model
The line
representing the
model
18
6-PolynomialRegression
[By Amina Delali]
Linear regression basis Polynomial function (1 feature)Linear regression basis Polynomial function (1 feature)
●
Fit
Labeled Observed Data: described by 1 feature: x
From that x, new polynomial features are generated: x2
,x3
, …, xn.
Linear regression basis Polynomial function (1 feature)
Build
Predict
Mathematical Model== a Linear
curve, modelized by:
Y = a1
x +a2
x2
+...+an
xn
+b
with
The parameters: a1
, a2
, …., an
,b
N: the degree of the polynomial model
The new x values must be transformed first into
polynomial feature, before applying the model.
19
6-PolynomialRegression
[By Amina Delali]
ExampleExample
●
The model is the same, we will just generate
new features: polynomial features
20
6-PolynomialRegression
[By Amina Delali]
Example with a pipelineExample with a pipeline
●
The newX values are
generated in a way that
the model can be plotted
in a linear form :
it describes the model
This pipeline will:
1- generate polynomial
features from the data.
2- apply the regression
model to the new data
References
●
Joshi Prateek. Artifcial intelligence with Python. Packt
Publishing, 2017.
●
Jake VanderPlas. Python data science handbook: essential
tools for working with data. O’Reilly Media, Inc, 2017.
Thank
you!
FOR ALL YOUR TIME

More Related Content

PPTX
Packing Problems Using Gurobi
PDF
Functional and Algebraic Domain Modeling
PDF
Silicon valleycodecamp2013
PDF
Data Structures 2007
PDF
Introduction to Machine Learning in Python using Scikit-Learn
PDF
R programmingmilano
PDF
Algebraic Thinking for Evolution of Pure Functional Domain Models
PDF
Power of functions in a typed world
Packing Problems Using Gurobi
Functional and Algebraic Domain Modeling
Silicon valleycodecamp2013
Data Structures 2007
Introduction to Machine Learning in Python using Scikit-Learn
R programmingmilano
Algebraic Thinking for Evolution of Pure Functional Domain Models
Power of functions in a typed world

What's hot (20)

PPT
PDF
Mining Functional Patterns
PPTX
08 class and object
PDF
Boosted Tree-based Multinomial Logit Model for Aggregated Market Data
PPTX
Matlab operators
PDF
The ABC of Implementing Supervised Machine Learning with Python.pptx
PDF
Architectural Patterns in Building Modular Domain Models
PDF
Visualizing the model selection process
PPT
Maps&hash tables
PDF
1 Anne complains that defining functions to use in her programs is a lot of ...
PPTX
Data structure and algorithm All in One
PPT
16829 memory management2
PDF
Ai_Project_report
PDF
Linear Regression (Machine Learning)
PPTX
stacks and queues for public
PPT
Data structure
PPSX
Software Metrics
PPTX
Nearest neighbour algorithm
PDF
Visualizing the Model Selection Process
PPTX
Introduction to FSharp
Mining Functional Patterns
08 class and object
Boosted Tree-based Multinomial Logit Model for Aggregated Market Data
Matlab operators
The ABC of Implementing Supervised Machine Learning with Python.pptx
Architectural Patterns in Building Modular Domain Models
Visualizing the model selection process
Maps&hash tables
1 Anne complains that defining functions to use in her programs is a lot of ...
Data structure and algorithm All in One
16829 memory management2
Ai_Project_report
Linear Regression (Machine Learning)
stacks and queues for public
Data structure
Software Metrics
Nearest neighbour algorithm
Visualizing the Model Selection Process
Introduction to FSharp
Ad

Similar to Aaa ped-10-Supervised Learning: Introduction to Supervised Learning (20)

PDF
Introduction to Machine Learning with SciKit-Learn
PDF
Hands-on - Machine Learning using scikitLearn
PDF
Machine learning- key concepts
PPTX
UNIT II SUPERVISED LEARNING - Introduction
PPTX
Ml ppt at
PDF
Machine Learning deep learning artificial
PPTX
Week_1 Machine Learning introduction.pptx
PDF
Data Mining the City - A (practical) introduction to Machine Learning
PPTX
Essential of ML 1st Lecture IIT Kharagpur
PPTX
Session 06 machine learning.pptx
PPTX
Session 06 machine learning.pptx
PDF
Machine Learning - Implementation with Python - 2
PDF
20MEMECH Part 3- Classification.pdf
PDF
Introduction to machine learning
PPTX
Predire il futuro con Machine Learning & Big Data
PPTX
Nimrita koul Machine Learning
PPT
594503964-Introduction-to-Classification-PPT-Slides-1.ppt
PPTX
Lecture 3 ml
PDF
Data Science Cheatsheet.pdf
PDF
2013 - Andrei Zmievski: Machine learning para datos
Introduction to Machine Learning with SciKit-Learn
Hands-on - Machine Learning using scikitLearn
Machine learning- key concepts
UNIT II SUPERVISED LEARNING - Introduction
Ml ppt at
Machine Learning deep learning artificial
Week_1 Machine Learning introduction.pptx
Data Mining the City - A (practical) introduction to Machine Learning
Essential of ML 1st Lecture IIT Kharagpur
Session 06 machine learning.pptx
Session 06 machine learning.pptx
Machine Learning - Implementation with Python - 2
20MEMECH Part 3- Classification.pdf
Introduction to machine learning
Predire il futuro con Machine Learning & Big Data
Nimrita koul Machine Learning
594503964-Introduction-to-Classification-PPT-Slides-1.ppt
Lecture 3 ml
Data Science Cheatsheet.pdf
2013 - Andrei Zmievski: Machine learning para datos
Ad

More from AminaRepo (20)

PDF
Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
PDF
Aaa ped-22-Artificial Neural Network: Introduction to ANN
PDF
Aaa ped-21-Recommender Systems: Content-based Filtering
PDF
Aaa ped-20-Recommender Systems: Model-based collaborative filtering
PDF
Aaa ped-19-Recommender Systems: Neighborhood-based Filtering
PDF
Aaa ped-18-Unsupervised Learning: Association Rule Learning
PDF
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
PDF
Aaa ped-16-Unsupervised Learning: clustering
PDF
Aaa ped-15-Ensemble Learning: Random Forests
PDF
Aaa ped-14-Ensemble Learning: About Ensemble Learning
PDF
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
PDF
Aaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
PDF
Aaa ped-9-Data manipulation: Time Series & Geographical visualization
PDF
Aaa ped-Data-8- manipulation: Plotting and Visualization
PDF
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
PDF
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & Preparation
PDF
Aaa ped-5-Data manipulation: Pandas
PDF
Aaa ped-4- Data manipulation: Numpy
PDF
Aaa ped-3. Pythond: advanced concepts
PDF
Aaa ped-2- Python: Basics
Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-22-Artificial Neural Network: Introduction to ANN
Aaa ped-21-Recommender Systems: Content-based Filtering
Aaa ped-20-Recommender Systems: Model-based collaborative filtering
Aaa ped-19-Recommender Systems: Neighborhood-based Filtering
Aaa ped-18-Unsupervised Learning: Association Rule Learning
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-16-Unsupervised Learning: clustering
Aaa ped-15-Ensemble Learning: Random Forests
Aaa ped-14-Ensemble Learning: About Ensemble Learning
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
Aaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
Aaa ped-9-Data manipulation: Time Series & Geographical visualization
Aaa ped-Data-8- manipulation: Plotting and Visualization
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & Preparation
Aaa ped-5-Data manipulation: Pandas
Aaa ped-4- Data manipulation: Numpy
Aaa ped-3. Pythond: advanced concepts
Aaa ped-2- Python: Basics

Recently uploaded (20)

PPTX
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
PPTX
INTRODUCTION TO EVS | Concept of sustainability
PDF
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
PPTX
2. Earth - The Living Planet earth and life
PDF
An interstellar mission to test astrophysical black holes
PPTX
microscope-Lecturecjchchchchcuvuvhc.pptx
PDF
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
PPTX
ECG_Course_Presentation د.محمد صقران ppt
PDF
HPLC-PPT.docx high performance liquid chromatography
PDF
Formation of Supersonic Turbulence in the Primordial Star-forming Cloud
PPTX
2. Earth - The Living Planet Module 2ELS
PDF
Biophysics 2.pdffffffffffffffffffffffffff
PDF
The scientific heritage No 166 (166) (2025)
PDF
Phytochemical Investigation of Miliusa longipes.pdf
PPTX
famous lake in india and its disturibution and importance
PPT
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
PDF
AlphaEarth Foundations and the Satellite Embedding dataset
PPTX
Taita Taveta Laboratory Technician Workshop Presentation.pptx
PPTX
Cell Membrane: Structure, Composition & Functions
PPTX
Classification Systems_TAXONOMY_SCIENCE8.pptx
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
INTRODUCTION TO EVS | Concept of sustainability
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
2. Earth - The Living Planet earth and life
An interstellar mission to test astrophysical black holes
microscope-Lecturecjchchchchcuvuvhc.pptx
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
ECG_Course_Presentation د.محمد صقران ppt
HPLC-PPT.docx high performance liquid chromatography
Formation of Supersonic Turbulence in the Primordial Star-forming Cloud
2. Earth - The Living Planet Module 2ELS
Biophysics 2.pdffffffffffffffffffffffffff
The scientific heritage No 166 (166) (2025)
Phytochemical Investigation of Miliusa longipes.pdf
famous lake in india and its disturibution and importance
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
AlphaEarth Foundations and the Satellite Embedding dataset
Taita Taveta Laboratory Technician Workshop Presentation.pptx
Cell Membrane: Structure, Composition & Functions
Classification Systems_TAXONOMY_SCIENCE8.pptx

Aaa ped-10-Supervised Learning: Introduction to Supervised Learning

  • 1. Supervised Learning: Introduction to Supervised Learning AAA-Python Edition
  • 2. Plan ● 1- Supervised Learning ● 2- Classifcation ● 3- Regression ● 4- Features ● 5- Linear Regression ● 6- Polynomial Regression
  • 3. 3 1-Supervised Learning [By Amina Delali] Machine LearningMachine Learning Fit Observed Data: described by a set of features Machine learning Build Predict Mathematical Model with Tunable parameters New Data
  • 4. 4 1-Supervised Learning [By Amina Delali] Supervised LearningSupervised Learning Fit Labeled Observed Data Supervised learning Build Predict the Labels Mathematical Model with Tunable parameters Fitting == minimize the cost function ( difference between True and Predicted labels ) Predicting == Apply the obtained mathematical model on the New Data
  • 5. 5 2-Classifcation [By Amina Delali] Unsupervised LearningUnsupervised Learning ● Fit Not Labeled Observed Data Unsupervised learning Build Predict the Labels Mathematical Model with Tunable parameters Predicting = Extract information about New Data
  • 6. 6 2-Classifcation [By Amina Delali] ClassifcationClassifcation ● Fit Labeled Observed Data: The Labels are categories Supervised learning: Classification Build Predict Mathematical Model with Tunable parameters Predict the known categories for the New Data
  • 7. 7 2-Classifcation [By Amina Delali] Scikit-LearnScikit-Learn ● Scikit-learn is a python library used for data mining and data analysis ● It is build on :”Numpy”, “Scipy”, and “Matplotlib” libraries. ● It will be used for both classifcation and regression by importing the corresponding modules. ● It will also be used for feature extraction using :”sklearn.feature_extraction” module ● The full documentation about scikit-learn, is available at its homepage: http://scikit-learn.org/stable/index.html
  • 8. 8 3-Regression [By Amina Delali] Classifcation ProblemsClassifcation Problems ● Fit Observed Data: x-ray images. Labels == yes or no. Yes == Presence of Tumor, No == Absence of Tumor Classifying images Predict if there is a tumor or not New Data: Not labeled x-ray images. Classifying text Predict if the category of the word New Data: Not labeled words Fit Observed Data: words in sentences. Labels == verb, subject, or adjective
  • 9. 9 3-Regression [By Amina Delali] RegressionRegression ● Fit Labeled Observed Data: The Labels are continuous quantities Supervised learning: Regression Build Predict Mathematical Model with Tunable parameters Predict the New quantities for the New Data
  • 10. 10 3-Regression [By Amina Delali] Regression ProblemsRegression Problems ● Fit Observed Data: houses described by a set of characteristics. Labels == prices of the houses Photometric redshift Predict the distance New galaxies without the distance information Fit Observed Data: galaxies described by their brightness at several wavelengths. Labels == distances of the galaxies House pricing Predict houses price New Data: a set of houses described by the same set of characteristics (with different values), but they don’t have the price indicated.
  • 11. 11 4-Features [By Amina Delali] IntroductionIntroduction ● Fit Observed Data: the data must be described by a set of characteristics: numerical values Machine Learning Predict if there is a tumor or not The new Data: must be described by the same set but with different values These characteristics, aren’t always in a numerical format. They can be: Categories Text Images They have to be transformed in a numerical format
  • 12. 12 4-Features [By Amina Delali] Categorical featuresCategorical features Categories One-hot-encoding The Feature 3 is transformed into 3 other features each one representing the presence of a category belonging to feature 3
  • 13. 13 4-Features [By Amina Delali] Text featuresText features ● Text Word count TF – IDF: term frequency–inverse document frequencyWord count Each line will represent a row. And each word will represent a feature. Features values in each row will be the count of the corresponding word in the corresponding line Appears 0 times in line 0 Appears 2 times in line 1
  • 14. 14 4-Features [By Amina Delali] Text featuresText features ● Text Word count TF – IDF: term frequency–inverse document frequencyTF – IDF We didn’t normalize the results tf −idf (t ,d)=tf (t ,d)∗idf (t) tf (t ,d)=number of ×the termt occurs∈document t idf (t)=ln( 1+nd 1+df (d ,t) )+1 df (d ,t)=number of documents that containthe termt == 1 * (ln[(1+2)/1+1]+1 ) == 1.405465 nd=total number of documents0
  • 15. 15 4-Features [By Amina Delali] ImagesImages ● Image Use pixel values as features values: number of features == number of pixels Is just a reshape of images
  • 16. 16 5-LinearRegression [By Amina Delali] Simple Linear Regression (with 1 Feature)Simple Linear Regression (with 1 Feature) Fit Labeled Observed Data: described by 1 feature: x The labels are y values. Fitting == find a and b that minimize the difference between the real labels: y and the estimated ones. Simple Linear Regression : 1 feature Build Predict Mathematical Model== a Line, modelized by: Y = a x + b with a: the slope b: the intercept Predict the New y for the New not labeled x values
  • 17. 17 5-LinearRegression [By Amina Delali] ExampleExample ● The model to train Initialization of a linear regressor instance Train the model Predict y for new values: actually this new x values are used to draw the model Parameters of the model The line representing the model
  • 18. 18 6-PolynomialRegression [By Amina Delali] Linear regression basis Polynomial function (1 feature)Linear regression basis Polynomial function (1 feature) ● Fit Labeled Observed Data: described by 1 feature: x From that x, new polynomial features are generated: x2 ,x3 , …, xn. Linear regression basis Polynomial function (1 feature) Build Predict Mathematical Model== a Linear curve, modelized by: Y = a1 x +a2 x2 +...+an xn +b with The parameters: a1 , a2 , …., an ,b N: the degree of the polynomial model The new x values must be transformed first into polynomial feature, before applying the model.
  • 19. 19 6-PolynomialRegression [By Amina Delali] ExampleExample ● The model is the same, we will just generate new features: polynomial features
  • 20. 20 6-PolynomialRegression [By Amina Delali] Example with a pipelineExample with a pipeline ● The newX values are generated in a way that the model can be plotted in a linear form : it describes the model This pipeline will: 1- generate polynomial features from the data. 2- apply the regression model to the new data
  • 21. References ● Joshi Prateek. Artifcial intelligence with Python. Packt Publishing, 2017. ● Jake VanderPlas. Python data science handbook: essential tools for working with data. O’Reilly Media, Inc, 2017.