Entri Blog
No Result
View All Result
Sunday, February 5, 2023
  • State Level PSC
    • Kerala PSC
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
  • SSC
  • Railway
  • Entri Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • TET
    • APTET
    • CTET
    • DSSSB
    • Karnataka TET
    • Kerala TET
    • KVS
    • MPTET
    • SUPER TET
    • TNTET
    • TSTET
    • UPTET
FREE GK TEST: SIGNUP NOW
Entri Blog
  • State Level PSC
    • Kerala PSC
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
  • SSC
  • Railway
  • Entri Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • TET
    • APTET
    • CTET
    • DSSSB
    • Karnataka TET
    • Kerala TET
    • KVS
    • MPTET
    • SUPER TET
    • TNTET
    • TSTET
    • UPTET
No Result
View All Result
Entri Blog
Free GK Test
banner top article banner top article
Home Articles

What is Logistic Regression in Machine Learning?

by Akhil M G
November 23, 2022
in Articles, Coding, Data Science and Machine Learning, Java Programming, React Native, Web and Android Development
What is Logistic Regression in Machine Learning?
Share on FacebookShare on WhatsAppShare on Telegram

Table of Contents

  • Supervised Learning
  • What is Logistic Regression?
  • Advantages of Logistic Regression Algorithm
  • How Does the Logistic Regression Algorithm Work?
  • Applications of Logistic Regression
  • The assumption in a Logistic Regression Algorithm
  • Predict the Digits in Images Using a Logistic Regression Classifier in Python
  • Conclusion

The business has undergone a revolution thanks to machine learning, enabling us to create complex apps that tackle challenging issues. Classification, regression, and clustering methods can be used to solve problems utilizing supervised and unsupervised machine learning models. In this post, we’ll talk about the Python implementation of the supervised machine learning technique known as logistic regression. Both classification and regression issues can be resolved using logistic regression.

Learn Machine learning in advanced level. Join Entri now

Supervised Learning

A labeled training dataset is used by supervised machine learning algorithms to discover insights, patterns, and relationships. It indicates that each record in the collection already has a known value for the target variable. Because an algorithm learns from the training dataset under the supervision of an instructor, this process is known as supervised learning. The algorithm iteratively makes predictions based on the training data, and the instructor corrects it. You already know the right answers. Learning is complete when the algorithm reaches the desired performance and accuracy level

Supervised learning problems can be further classified into regression and classification problems.

  • Classification: In a classification problem, the output variable is a category, such as “red” or “blue,” “disease” or “no disease,” “true” or “false,” etc.
  • Regression: In a regression problem, the output variable is a real continuous value, such as “dollars” or “weight.”

What is Logistic Regression?

When creating machine learning models, logistic regression is a statistical technique used when the dependent variable is dichotomous, or binary. Data and the relationship between one dependent variable and one or more independent variables are described using logistic regression. Nominal, ordinal, or interval types are all acceptable for the independent variables. The concept of the logistic function that it employs is where the term “logistic regression” originates. The sigmoid function is another name for the logistic function. This logistic function has a value between 0 and 1.

Advantages of Logistic Regression Algorithm

  • Logistic regression performs better when the data is linearly separable
  • It does not require too many computational resources as it’s highly interpretable
  • There is no problem scaling the input features—It does not require tuning
  • It is easy to implement and train a model using logistic regression
  • It gives a measure of how relevant a predictor (coefficient size) is, and its direction of association (positive or negative)

Learn Machine learning in advanced level. Join Entri now

How Does the Logistic Regression Algorithm Work?

Think about the following instance: A company wants to decide whether to enhance an employee’s pay based on their performance. They will make their decision using a linear regression technique. They can simplify their task by plotting a regression line using the employee’s performance as the independent variable and the salary rise as the dependent variable. What happens if a company wants to determine whether a worker deserves a promotion based on their performance? The linear graph shown above won’t work in this situation. In order to create a sigmoid curve, we clip the line at zero and one (S curve). The company can decide whether or not to raise an employee’s wage based on the threshold values.

To understand logistic regression, let’s go over the odds of success.

Odds (𝜃) = Probability of an event happening / Probability of an event not happening

𝜃 = p / 1 – p

The values of odds range from zero  ∞ and the values of probability lie between zero and one.

Consider the equation of a straight line:

𝑦 = 𝛽0 + 𝛽1* 𝑥

Here, 𝛽0 is the y-intercept

𝛽1 is the slope of the line

x is the value of the x coordinate

y is the value of the prediction

Now to predict the odds of success, we use the following formula:

log

Exponentiating both sides, we have:

et-y

Let Y = e 𝛽0+𝛽1 * 𝑥

Then p(x) / 1 – p(x) = Y

p(x) = Y(1 – p(x))

p(x) = Y – Y(p(x))

p(x) + Y(p(x)) = Y

p(x)(1+Y) = Y

p(x) = Y / 1+Y

px

The equation of the sigmoid function is:

The sigmoid curve obtained from the above equation is as follows:

Applications of Logistic Regression

  • Using the logistic regression algorithm, banks can predict whether a customer would default on loans or not
  • To predict the weather conditions of a certain place (sunny, windy, rainy, humid, etc.)
  • Ecommerce companies can identify buyers if they are likely to purchase a certain product
  • Companies can predict whether they will gain or lose money in the next quarter, year, or month based on their current performance
  • To classify objects based on their features and attributes

The assumption in a Logistic Regression Algorithm

  • In a binary logistic regression, the dependent variable must be binary
  • For a binary regression, the factor level one of the dependent variables should represent the desired outcome
  • Only meaningful variables should be included
  • The independent variables should be independent of each other. This means the model should have little or no multicollinearity
  • The independent variables are linearly related to the log odds
  • Logistic regression requires quite large sample sizes

Predict the Digits in Images Using a Logistic Regression Classifier in Python

We’ll be using the digits dataset in the sci-kit learn library to predict digit values from images using the logistic regression model in Python.

 

  • Importing libraries and their associated methods

 

  • Determining the total number of images and labels

 

  • Displaying some of the images and their labels

 

  • Dividing the dataset into “training” and “test” set
  • Importing the logistic regression model
  • Making an instance of the model and training it
  • Predicting the output of the first element of the test set
  • Predicting the output of the first 10 elements of the test set
  • Prediction for the entire dataset
  • Determining the accuracy of the model
  • Representing the confusion matrix in a heat map

actual-output

  • Presenting predictions and actual output

The images above depict the actual numbers and the predicted digit values from our logistic regression model.

Conclusion

We anticipated that this essay would help you become familiar with the fundamentals of logistic regression and supervised learning. We discussed the logistic regression algorithm in depth using a complex case. The list of assumptions you should make to develop a logistic regression model was then discussed, after which we looked at the various applications of logistic regression. Finally, to predict the digits in photos, we developed a model using the logistic regression approach.

Get the latest updates on machine learning in the Entri app

 

Share63SendShare
Akhil M G

Akhil M G

Related Posts

MPPEB ITI TO Result 2022 Out: Answer Key, Cut Off Marks
Articles

MPPEB ITI TO Result 2022 Out: Answer Key, Cut Off Marks

February 2, 2023
OPSC OMAS Syllabus 2023 Out: Exam Pattern, PDF
Articles

OPSC OMAS Syllabus 2023 Out: Exam Pattern, PDF

February 2, 2023
BMC Gujarat Bharti 2023: Apply Online for 149 Vacancies, Notification PDF
Articles

BMC Gujarat Bharti 2023: Apply Online for 149 Vacancies, Notification PDF

February 2, 2023
Next Post
What Is Cleaning Data In Python? An Overview

What Is Data Cleaning In Python? An Overview

Discussion about this post

Latest Posts

  • Learn Continuous Tense Examples
  • Examples of Adverb in English Sentences
  • Slogans on World Environment Day
  • Top CSS Tools for Web Developer in 2023
  • TNPSC Inspector of Fisheries Admit Card 2023 Out: Download Here

Trending Posts

  • states of india and their capitals and languages

    List of 28 States of India and their Capitals and Languages 2023 – PDF Download

    149828 shares
    Share 59928 Tweet 37455
  • List of Government Banks in India 2023: All you need to know

    61097 shares
    Share 24439 Tweet 15274
  • TNPSC Group 2 Posts and Salary Details 2022

    39459 shares
    Share 15784 Tweet 9865
  • New Map of India with States and Capitals 2023

    28565 shares
    Share 11426 Tweet 7141
  • Odisha Police Recruitment 2023 PDF Download for 4790 Posts – Eligibility, Selection Process

    863 shares
    Share 345 Tweet 216

Company

  • Become a teacher
  • Login to Entri Web

Quick Links

  • Articles
  • Videos
  • Entri Daily Quiz Practice
  • Current Affairs & GK
  • News Capsule – eBook
  • Preparation Tips
  • Kerala PSC Gold
  • Entri Skilling

Popular Exam

  • IBPS Exam
  • SBI Exam
  • Railway RRB Exam
  • Kerala PSC
  • Tamil Nadu PSC
  • Telangana PSC
  • Andhra Pradesh PSC
  • MPPSC
  • UPPSC
  • Karnataka PSC
  • Staff Selection Commission Exam

© 2021 Entri.app - Privacy Policy | Terms of Service

No Result
View All Result
  • State Level PSC
    • Kerala PSC
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
  • SSC
  • Railway
  • Entri Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • TET
    • APTET
    • CTET
    • DSSSB
    • Karnataka TET
    • Kerala TET
    • KVS
    • MPTET
    • SUPER TET
    • TNTET
    • TSTET
    • UPTET

© 2021 Entri.app - Privacy Policy | Terms of Service