SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
6. Classification Algorithm –
Logistic regression
Classification and Representation
SUPERVISED LEARNING:
➢REGRESSION – y can take any value
➢CLASSIFICATION - y can take only specified discrete value
Or
WHY REGRESSION ALGO CAN’T BE USED ON CLASSISFICATION
PROBLEMS:
For a classification problem: if regression algo is applied:
To attempt classification, one method is to use linear regression
and map all predictions greater than 0.5 as a 1 and all less than 0.5
as a 0. However, this method doesn't work well because
classification is not actually a linear function.
This seems to work fine for this example but:
If we add another data point:
Algo starts giving wrong hypothesis: Thus using reg algo on
classification problem is bad
For a classification problem: binary classification
h(x) can be:
So an algo is used :
Given xi
, the
Corresponding yi
is also called the label for the training example.
HYPOTHESIS REPRESENTATION:
Here g(z) = sigmoid or logistic function
g(z) vs z:logistic fxn
Sigmoid fxn takes asymptotes at 0 (for -inf) and 1(for +inf)
We need to find best fitting parameters Θ for our hypothesis.
This means that h( x ) – is just the probability of y being equal to 1.
Y == 0 or 1:
This gives the prob. Of y=1 for an example having particular values
of X and Θ.
i.e., prob of y==0 for a patient having values of x and prob of y=1 for
the same patient adds up to 1 == 100%.
Our probability that our prediction is 0 is just the complement of
our probability that it is 1 (e.g. if probability that it is 1 is 70%, then
the probability that it is 0 is 30%).
DECESION BOUNDARY:
This means:
Decision Boundary: The decision boundary is the line that separates
the area where y = 0 and where y = 1.
It is created by our hypothesis function.
Example: taking a linear example
this line is k/a decision
boundary
All values to the right of this line correspond to y==1
And all the values on left are for y==0
Non-linear example:
The hypothesis fxn can be super complex
It can be noted that: the decision boundary depends only on the
parameters(Θ) and not on the training set(values of xi
and y)
Thus:
The hypothesis fxn can be super complex and the decision
boundary may have weird looking curves:
COST FUNCTION:
For a linear reg fxn:
But for logistic fxn:
This cost fxn is a non-convex fxn of Θ:
In a non-convex fxn there can be so many local optimas that it’s
hard to reach global minima.. unlike in convex fxn
In non-convex fxns, linear reg cost algo does not guarantee global
mnima
So we choose a different Cost fxn:
Note that writing the cost function in this way guarantees that J(θ)
is convex for logistic regression
This is the cost of just one example. it will be needed to be summed
for J(Θ)—error fxn
Cost vs h(x)
Cost vs h(x)
The above two graphs for y==1 and y==0 means that:
The cost of a given value of h(x) is the cost that is to be paid by the
algorithm for that prediction.
It is the measure of how wrong the prediction is.
SIMPLIFIED COST FUNCTION: equivalent cost function:
VECTORIZED IMPLEMENTATION:
OPTIMIZATION ALGORITHMS:
We can use octave's "fminunc()" optimization algorithm
For bigger example:
MULTICLASS CLASSIFICATION: One vs All Classification
When y can take more than 2 values: but they are discrete
Instead of y = {0,1} we will expand our definition so that y =
{0,1...n}.
Since y = {0,1...n}, we divide our problem into n+1 (+1 because the
index starts at 0) binary classification problems; in each one, we
predict the probability that 'y' is a member of one of our classes.
The multiclass problem is considered using 3 different binary
classification problem
hΘ
(i)
( x ) – here (i) denotes the class(y) – each value of y
corresponds to a diff class
◼ It denotes the probability of y belonging to that class. That is
it’s the prob. Of y’s value being that of i.
◼ Therefore, the values of all 3 hΘ ( x ) are computed than the
one corresponding to highest probability is selected.
◼ A different decision boundary exits for all classes
To make a prediction on a new x ➔ pick the class that maximizes
hΘ( x )

Contenu connexe

Tendances

17 large scale machine learning
17 large scale machine learning17 large scale machine learning
17 large scale machine learningTanmayVijay1
 
13 unsupervised learning clustering
13 unsupervised learning   clustering13 unsupervised learning   clustering
13 unsupervised learning clusteringTanmayVijay1
 
14 dimentionality reduction
14 dimentionality reduction14 dimentionality reduction
14 dimentionality reductionTanmayVijay1
 
Chapter 2 continuous_random_variable_2009
Chapter 2 continuous_random_variable_2009Chapter 2 continuous_random_variable_2009
Chapter 2 continuous_random_variable_2009ayimsevenfold
 
ML - Multiple Linear Regression
ML - Multiple Linear RegressionML - Multiple Linear Regression
ML - Multiple Linear RegressionAndrew Ferlitsch
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine LearningKuppusamy P
 
U6 Cn2 Definite Integrals Intro
U6 Cn2 Definite Integrals IntroU6 Cn2 Definite Integrals Intro
U6 Cn2 Definite Integrals IntroAlexander Burt
 
Numerical approximation
Numerical approximationNumerical approximation
Numerical approximationMileacre
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical MethodsESUG
 
Random number generation
Random number generationRandom number generation
Random number generationVinit Dantkale
 
Simplex Method Flowchart/Algorithm
Simplex Method Flowchart/AlgorithmSimplex Method Flowchart/Algorithm
Simplex Method Flowchart/AlgorithmRaja Adapa
 
linear programming
linear programminglinear programming
linear programmingJazz Bhatti
 
Algorithm of some numerical /computational methods
Algorithm of some numerical /computational methodsAlgorithm of some numerical /computational methods
Algorithm of some numerical /computational methodsChandan
 

Tendances (20)

17 large scale machine learning
17 large scale machine learning17 large scale machine learning
17 large scale machine learning
 
13 unsupervised learning clustering
13 unsupervised learning   clustering13 unsupervised learning   clustering
13 unsupervised learning clustering
 
14 dimentionality reduction
14 dimentionality reduction14 dimentionality reduction
14 dimentionality reduction
 
Chapter 2 continuous_random_variable_2009
Chapter 2 continuous_random_variable_2009Chapter 2 continuous_random_variable_2009
Chapter 2 continuous_random_variable_2009
 
Calc 2.1
Calc 2.1Calc 2.1
Calc 2.1
 
ML - Multiple Linear Regression
ML - Multiple Linear RegressionML - Multiple Linear Regression
ML - Multiple Linear Regression
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
 
Teknik Simulasi
Teknik SimulasiTeknik Simulasi
Teknik Simulasi
 
U6 Cn2 Definite Integrals Intro
U6 Cn2 Definite Integrals IntroU6 Cn2 Definite Integrals Intro
U6 Cn2 Definite Integrals Intro
 
Random number generator
Random number generatorRandom number generator
Random number generator
 
Numerical approximation
Numerical approximationNumerical approximation
Numerical approximation
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical Methods
 
Random number generation
Random number generationRandom number generation
Random number generation
 
simplex method
simplex methodsimplex method
simplex method
 
Simplex Method Flowchart/Algorithm
Simplex Method Flowchart/AlgorithmSimplex Method Flowchart/Algorithm
Simplex Method Flowchart/Algorithm
 
linear programming
linear programminglinear programming
linear programming
 
Riemann's Sum
Riemann's SumRiemann's Sum
Riemann's Sum
 
Algorithm of some numerical /computational methods
Algorithm of some numerical /computational methodsAlgorithm of some numerical /computational methods
Algorithm of some numerical /computational methods
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Uniform Distribution
Uniform DistributionUniform Distribution
Uniform Distribution
 

Similaire à 6 logistic regression classification algo

CS229 Machine Learning Lecture Notes
CS229 Machine Learning Lecture NotesCS229 Machine Learning Lecture Notes
CS229 Machine Learning Lecture NotesEric Conner
 
Difference between logistic regression shallow neural network and deep neura...
Difference between logistic regression  shallow neural network and deep neura...Difference between logistic regression  shallow neural network and deep neura...
Difference between logistic regression shallow neural network and deep neura...Chode Amarnath
 
Machine learning (1)
Machine learning (1)Machine learning (1)
Machine learning (1)NYversity
 
CALCULUS chapter number one presentation
CALCULUS chapter number one presentationCALCULUS chapter number one presentation
CALCULUS chapter number one presentationkdoha825
 
UE19EC353 ML Unit4_slides.pptx
UE19EC353 ML Unit4_slides.pptxUE19EC353 ML Unit4_slides.pptx
UE19EC353 ML Unit4_slides.pptxpremkumar901866
 
PRML Chapter 4
PRML Chapter 4PRML Chapter 4
PRML Chapter 4Sunwoo Kim
 
Logistic regression.ppt
Logistic regression.pptLogistic regression.ppt
Logistic regression.pptBalaChowdappa1
 
07 logistic regression and stochastic gradient descent
07 logistic regression and stochastic gradient descent07 logistic regression and stochastic gradient descent
07 logistic regression and stochastic gradient descentSubhas Kumar Ghosh
 
Machine learning
Machine learningMachine learning
Machine learningShreyas G S
 
Machine learning (4)
Machine learning (4)Machine learning (4)
Machine learning (4)NYversity
 
Machine learning session4(linear regression)
Machine learning   session4(linear regression)Machine learning   session4(linear regression)
Machine learning session4(linear regression)Abhimanyu Dwivedi
 
2.7 other classifiers
2.7 other classifiers2.7 other classifiers
2.7 other classifiersKrish_ver2
 
Chapter4
Chapter4Chapter4
Chapter4Vu Vo
 
Chi-squared Goodness of Fit Test Project Overview and.docx
Chi-squared Goodness of Fit Test Project  Overview and.docxChi-squared Goodness of Fit Test Project  Overview and.docx
Chi-squared Goodness of Fit Test Project Overview and.docxbissacr
 
Chi-squared Goodness of Fit Test Project Overview and.docx
Chi-squared Goodness of Fit Test Project  Overview and.docxChi-squared Goodness of Fit Test Project  Overview and.docx
Chi-squared Goodness of Fit Test Project Overview and.docxmccormicknadine86
 
Regression_1.pdf
Regression_1.pdfRegression_1.pdf
Regression_1.pdfAmir Saleh
 
IVS-B UNIT-1_merged. Semester 2 fundamental of sciencepdf
IVS-B UNIT-1_merged. Semester 2 fundamental of sciencepdfIVS-B UNIT-1_merged. Semester 2 fundamental of sciencepdf
IVS-B UNIT-1_merged. Semester 2 fundamental of sciencepdf42Rnu
 

Similaire à 6 logistic regression classification algo (20)

CS229 Machine Learning Lecture Notes
CS229 Machine Learning Lecture NotesCS229 Machine Learning Lecture Notes
CS229 Machine Learning Lecture Notes
 
Difference between logistic regression shallow neural network and deep neura...
Difference between logistic regression  shallow neural network and deep neura...Difference between logistic regression  shallow neural network and deep neura...
Difference between logistic regression shallow neural network and deep neura...
 
Machine learning (1)
Machine learning (1)Machine learning (1)
Machine learning (1)
 
CALCULUS chapter number one presentation
CALCULUS chapter number one presentationCALCULUS chapter number one presentation
CALCULUS chapter number one presentation
 
UE19EC353 ML Unit4_slides.pptx
UE19EC353 ML Unit4_slides.pptxUE19EC353 ML Unit4_slides.pptx
UE19EC353 ML Unit4_slides.pptx
 
PRML Chapter 4
PRML Chapter 4PRML Chapter 4
PRML Chapter 4
 
Logistic regression.ppt
Logistic regression.pptLogistic regression.ppt
Logistic regression.ppt
 
07 logistic regression and stochastic gradient descent
07 logistic regression and stochastic gradient descent07 logistic regression and stochastic gradient descent
07 logistic regression and stochastic gradient descent
 
Machine learning
Machine learningMachine learning
Machine learning
 
Machine learning (4)
Machine learning (4)Machine learning (4)
Machine learning (4)
 
Machine learning session4(linear regression)
Machine learning   session4(linear regression)Machine learning   session4(linear regression)
Machine learning session4(linear regression)
 
2.7 other classifiers
2.7 other classifiers2.7 other classifiers
2.7 other classifiers
 
Chapter4
Chapter4Chapter4
Chapter4
 
Chi-squared Goodness of Fit Test Project Overview and.docx
Chi-squared Goodness of Fit Test Project  Overview and.docxChi-squared Goodness of Fit Test Project  Overview and.docx
Chi-squared Goodness of Fit Test Project Overview and.docx
 
Logistics regression
Logistics regressionLogistics regression
Logistics regression
 
Chi-squared Goodness of Fit Test Project Overview and.docx
Chi-squared Goodness of Fit Test Project  Overview and.docxChi-squared Goodness of Fit Test Project  Overview and.docx
Chi-squared Goodness of Fit Test Project Overview and.docx
 
Regression_1.pdf
Regression_1.pdfRegression_1.pdf
Regression_1.pdf
 
2. diagnostics, collinearity, transformation, and missing data
2. diagnostics, collinearity, transformation, and missing data 2. diagnostics, collinearity, transformation, and missing data
2. diagnostics, collinearity, transformation, and missing data
 
working with python
working with pythonworking with python
working with python
 
IVS-B UNIT-1_merged. Semester 2 fundamental of sciencepdf
IVS-B UNIT-1_merged. Semester 2 fundamental of sciencepdfIVS-B UNIT-1_merged. Semester 2 fundamental of sciencepdf
IVS-B UNIT-1_merged. Semester 2 fundamental of sciencepdf
 

Plus de TanmayVijay1

18 application example photo ocr
18 application example  photo ocr18 application example  photo ocr
18 application example photo ocrTanmayVijay1
 
1 Introduction to Machine Learning
1 Introduction to Machine Learning1 Introduction to Machine Learning
1 Introduction to Machine LearningTanmayVijay1
 
16 recommender systems
16 recommender systems16 recommender systems
16 recommender systemsTanmayVijay1
 
11 ml system design
11 ml system design11 ml system design
11 ml system designTanmayVijay1
 
3 linear algebra review
3 linear algebra review3 linear algebra review
3 linear algebra reviewTanmayVijay1
 

Plus de TanmayVijay1 (6)

18 application example photo ocr
18 application example  photo ocr18 application example  photo ocr
18 application example photo ocr
 
1 Introduction to Machine Learning
1 Introduction to Machine Learning1 Introduction to Machine Learning
1 Introduction to Machine Learning
 
16 recommender systems
16 recommender systems16 recommender systems
16 recommender systems
 
11 ml system design
11 ml system design11 ml system design
11 ml system design
 
5 octave tutorial
5 octave tutorial5 octave tutorial
5 octave tutorial
 
3 linear algebra review
3 linear algebra review3 linear algebra review
3 linear algebra review
 

Dernier

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Dernier (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

6 logistic regression classification algo

  • 1. 6. Classification Algorithm – Logistic regression Classification and Representation SUPERVISED LEARNING: ➢REGRESSION – y can take any value ➢CLASSIFICATION - y can take only specified discrete value Or
  • 2. WHY REGRESSION ALGO CAN’T BE USED ON CLASSISFICATION PROBLEMS: For a classification problem: if regression algo is applied: To attempt classification, one method is to use linear regression and map all predictions greater than 0.5 as a 1 and all less than 0.5 as a 0. However, this method doesn't work well because classification is not actually a linear function. This seems to work fine for this example but: If we add another data point:
  • 3. Algo starts giving wrong hypothesis: Thus using reg algo on classification problem is bad For a classification problem: binary classification h(x) can be: So an algo is used : Given xi , the Corresponding yi is also called the label for the training example.
  • 4. HYPOTHESIS REPRESENTATION: Here g(z) = sigmoid or logistic function g(z) vs z:logistic fxn Sigmoid fxn takes asymptotes at 0 (for -inf) and 1(for +inf) We need to find best fitting parameters Θ for our hypothesis.
  • 5. This means that h( x ) – is just the probability of y being equal to 1. Y == 0 or 1: This gives the prob. Of y=1 for an example having particular values of X and Θ. i.e., prob of y==0 for a patient having values of x and prob of y=1 for the same patient adds up to 1 == 100%.
  • 6. Our probability that our prediction is 0 is just the complement of our probability that it is 1 (e.g. if probability that it is 1 is 70%, then the probability that it is 0 is 30%). DECESION BOUNDARY:
  • 8. Decision Boundary: The decision boundary is the line that separates the area where y = 0 and where y = 1. It is created by our hypothesis function. Example: taking a linear example
  • 9. this line is k/a decision boundary All values to the right of this line correspond to y==1 And all the values on left are for y==0
  • 10. Non-linear example: The hypothesis fxn can be super complex
  • 11. It can be noted that: the decision boundary depends only on the parameters(Θ) and not on the training set(values of xi and y) Thus: The hypothesis fxn can be super complex and the decision boundary may have weird looking curves:
  • 12. COST FUNCTION: For a linear reg fxn:
  • 13. But for logistic fxn: This cost fxn is a non-convex fxn of Θ: In a non-convex fxn there can be so many local optimas that it’s hard to reach global minima.. unlike in convex fxn In non-convex fxns, linear reg cost algo does not guarantee global mnima So we choose a different Cost fxn: Note that writing the cost function in this way guarantees that J(θ) is convex for logistic regression
  • 14. This is the cost of just one example. it will be needed to be summed for J(Θ)—error fxn Cost vs h(x)
  • 15. Cost vs h(x) The above two graphs for y==1 and y==0 means that: The cost of a given value of h(x) is the cost that is to be paid by the algorithm for that prediction. It is the measure of how wrong the prediction is.
  • 16. SIMPLIFIED COST FUNCTION: equivalent cost function: VECTORIZED IMPLEMENTATION:
  • 17.
  • 18. OPTIMIZATION ALGORITHMS: We can use octave's "fminunc()" optimization algorithm
  • 19. For bigger example: MULTICLASS CLASSIFICATION: One vs All Classification When y can take more than 2 values: but they are discrete Instead of y = {0,1} we will expand our definition so that y = {0,1...n}.
  • 20. Since y = {0,1...n}, we divide our problem into n+1 (+1 because the index starts at 0) binary classification problems; in each one, we predict the probability that 'y' is a member of one of our classes. The multiclass problem is considered using 3 different binary classification problem
  • 21. hΘ (i) ( x ) – here (i) denotes the class(y) – each value of y corresponds to a diff class ◼ It denotes the probability of y belonging to that class. That is it’s the prob. Of y’s value being that of i. ◼ Therefore, the values of all 3 hΘ ( x ) are computed than the one corresponding to highest probability is selected. ◼ A different decision boundary exits for all classes
  • 22. To make a prediction on a new x ➔ pick the class that maximizes hΘ( x )