{"id":51095,"date":"2025-06-05T17:28:38","date_gmt":"2025-06-05T11:58:38","guid":{"rendered":"https:\/\/www.iquanta.in\/blog\/?p=51095"},"modified":"2025-06-05T17:37:47","modified_gmt":"2025-06-05T12:07:47","slug":"logistic-regression-in-machine-learning","status":"publish","type":"post","link":"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/","title":{"rendered":"Logistic Regression in Machine Learning"},"content":{"rendered":"\n<p>Imagine you want to know if someone will click on an ad or not. You have some basic info like age income or search history. Logistic regression takes that info and gives you a number like 0.73 which means there is a 73 percent chance they will click. If the number is more than 0.5 we say yes if not then no. This is how machines make decisions in a smart way without being too complex. <\/p>\n\n\n\n<p>In this blog we will explain logistic regression in a simple way we will talk about how it works, types of logistic regression in<a href=\"https:\/\/www.iquanta.in\/blog\/what-is-machine-learning-an-introduction-for-beginners\/\"> machine learning<\/a>, some math behind it, examples in real life and how you can use it in Python. No heavy math just clear and easy to understand logic.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/chat.whatsapp.com\/B6weknl7133BQXjPva0pgB\"><img fetchpriority=\"high\" decoding=\"async\" width=\"864\" height=\"129\" src=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-49.png\" alt=\"Logistic Regression\" class=\"wp-image-51027\" srcset=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-49.png 864w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-49-300x45.png 300w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-49-768x115.png 768w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-49-150x22.png 150w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-49-696x104.png 696w\" sizes=\"(max-width: 864px) 100vw, 864px\" \/><\/a><\/figure><\/div>\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_77 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#What_is_Logistic_Regression\" >What is Logistic Regression?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#Maths_Behind_Logistic_Regression\" >Maths Behind Logistic Regression<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#Types_of_Logistic_Regression\" >Types of Logistic Regression<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#Assumption_of_Logistic_Regression\" >Assumption of Logistic Regression<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#How_Logistic_Regression_Works\" >How Logistic Regression Works?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#Evaluation_Metrics_For_Logistic_Regression\" >Evaluation Metrics For Logistic Regression<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#Advantages_of_Logistic_Regression\" >Advantages of Logistic Regression<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#Disadvantages_of_Logistic_Regression\" >Disadvantages of Logistic Regression<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#Applications_of_Logistic_Regression\" >Applications of Logistic Regression<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#Frequently_Asked_Questions_FAQs\" >Frequently Asked Questions (FAQs)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#What_is_logistic_regression_used_for\" >What is logistic regression used for?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#How_is_logistic_regression_different_from_linear_regression\" >How is logistic regression different from linear regression?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#What_are_the_key_assumptions_of_logistic_regression\" >What are the key assumptions of logistic regression?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-logistic-regression\"><span class=\"ez-toc-section\" id=\"What_is_Logistic_Regression\"><\/span><strong>What is Logistic Regression?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Logistic regression is a basic machine learning algorithm that is used when we want to predict something that has only two outcomes like yes or no true or false buy or not buy. It looks at the data we already have and tries to find a pattern so it can guess what might happen next. For example if you give it details like a person&#8217;s age income and past purchases it can tell you if that person is likely to buy your product or not.<\/p>\n\n\n\n<p>But instead of just saying yes or no right away it gives you a number between 0 and 1 which tells how likely it is to be a yes. If the number is more than 0.5 we take it as a yes and if it is less we take it as a no. This number is called probability and it helps us make better decisions.<\/p>\n\n\n\n<p>Even though it has the word regression in its name it is mostly used for classification problems which means sorting things into groups like spam or not spam or pass or fail. It is easy to use works well for simple problems and is often the first algorithm people learn in machine learning.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-maths-behind-logistic-regression\"><span class=\"ez-toc-section\" id=\"Maths_Behind_Logistic_Regression\"><\/span><strong>Maths Behind Logistic Regression<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In logistic regression we do not use a straight line like in linear regression because we are not predicting numbers we are predicting chances. So instead of using a normal line we use something called the sigmoid function. This function takes any number and turns it into a value between 0 and 1. That value shows the chance of something happening.<\/p>\n\n\n\n<p>Let us say you give some input like age or salary to the model. First it multiplies those inputs with some weights and adds them up. This is just basic math like 5 times age plus 3 times salary. The result is just a number which can be big or small. Then this number is passed through the sigmoid function. The sigmoid changes it into a value between 0 and 1. For example it might change 2.4 into 0.91 which means there is a 91 percent chance of getting a yes.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/chat.whatsapp.com\/B6weknl7133BQXjPva0pgB\"><img decoding=\"async\" width=\"864\" height=\"129\" src=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-52.png\" alt=\"\" class=\"wp-image-51116\" srcset=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-52.png 864w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-52-300x45.png 300w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-52-768x115.png 768w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-52-150x22.png 150w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-52-696x104.png 696w\" sizes=\"(max-width: 864px) 100vw, 864px\" \/><\/a><\/figure><\/div>\n\n\n<p>The math also uses something called a cost function which checks how far the prediction is from the actual answer. If the model is wrong the cost will be high. So it keeps adjusting the weights again and again using a method called gradient descent until the cost becomes as low as possible. This is how the model learns from the data and gets better at making predictions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-types-of-logistic-regression\"><span class=\"ez-toc-section\" id=\"Types_of_Logistic_Regression\"><\/span><strong>Types of Logistic Regression<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong>Type<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Number of Classes<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Output Type<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Real-life Example<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>When to Use<\/strong><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">Binary Logistic Regression<\/td><td class=\"has-text-align-center\" data-align=\"center\">2<\/td><td class=\"has-text-align-center\" data-align=\"center\">Yes\/No or 0\/1<\/td><td class=\"has-text-align-center\" data-align=\"center\">Spam or Not Spam<\/td><td class=\"has-text-align-center\" data-align=\"center\">When your outcome has only two categories<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">Multinomial Logistic Regression<\/td><td class=\"has-text-align-center\" data-align=\"center\">3 or more (no order)<\/td><td class=\"has-text-align-center\" data-align=\"center\">One class from many<\/td><td class=\"has-text-align-center\" data-align=\"center\">Predicting if a person chooses Apple Banana or Orange<\/td><td class=\"has-text-align-center\" data-align=\"center\">When you have more than two options without any ranking<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">Ordinal Logistic Regression<\/td><td class=\"has-text-align-center\" data-align=\"center\">3 or more (ordered)<\/td><td class=\"has-text-align-center\" data-align=\"center\">One ranked category<\/td><td class=\"has-text-align-center\" data-align=\"center\">Customer satisfaction: Poor Fair Good Excellent<\/td><td class=\"has-text-align-center\" data-align=\"center\">When categories have a natural order or level<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-assumption-of-logistic-regression\"><span class=\"ez-toc-section\" id=\"Assumption_of_Logistic_Regression\"><\/span><strong>Assumption of Logistic Regression<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Logistic regression is like teaching your computer how to guess something that has a yes or no answer. For example it can learn if a person has cancer or not based on some test results. It takes some data learns from it and then makes predictions. The more data it sees the better it gets at guessing. It is one of the easiest and most useful tools when you want to predict simple choices like true or false or yes or no.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\nfrom statsmodels.stats.outliers_influence import variance_inflation_factor\nimport statsmodels.api as sm\n\n# Sample data\ndata = {\n    'X1': &#091;1, 2, 3, 4, 5, 6],\n    'X2': &#091;2, 4, 6, 8, 10, 12],\n    'X3': &#091;5, 3, 6, 9, 12, 15],\n    'y':  &#091;0, 0, 0, 1, 1, 1]\n}\n\ndf = pd.DataFrame(data)\nX = df&#091;&#091;'X1', 'X2', 'X3']]\nX = sm.add_constant(X)\n\nvif = pd.DataFrame()\nvif&#091;'Feature'] = X.columns\nvif&#091;'VIF'] = &#091;variance_inflation_factor(X.values, i) for i in range(X.shape&#091;1])]\n\nprint(vif)\n<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/chat.whatsapp.com\/B6weknl7133BQXjPva0pgB\"><img decoding=\"async\" width=\"864\" height=\"129\" src=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-53.png\" alt=\"\" class=\"wp-image-51117\" srcset=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-53.png 864w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-53-300x45.png 300w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-53-768x115.png 768w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-53-150x22.png 150w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-53-696x104.png 696w\" sizes=\"(max-width: 864px) 100vw, 864px\" \/><\/a><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-logistic-regression-works\"><span class=\"ez-toc-section\" id=\"How_Logistic_Regression_Works\"><\/span><strong>How Logistic Regression Works?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Step<\/td><td class=\"has-text-align-center\" data-align=\"center\">What Happens<\/td><td class=\"has-text-align-center\" data-align=\"center\">Explanation in Simple Words<\/td><\/tr><tr><td>1<\/td><td class=\"has-text-align-center\" data-align=\"center\">Take input features<\/td><td class=\"has-text-align-center\" data-align=\"center\">Use data like age income marks etc<\/td><\/tr><tr><td>2<\/td><td class=\"has-text-align-center\" data-align=\"center\">Multiply inputs by weights and add bias<\/td><td class=\"has-text-align-center\" data-align=\"center\">Do basic math like 5 times age plus 2 times income plus a small extra number<\/td><\/tr><tr><td>3<\/td><td class=\"has-text-align-center\" data-align=\"center\">Apply the sigmoid function<\/td><td class=\"has-text-align-center\" data-align=\"center\">Turn the result into a value between 0 and 1<\/td><\/tr><tr><td>4<\/td><td class=\"has-text-align-center\" data-align=\"center\">Get the probability<\/td><td class=\"has-text-align-center\" data-align=\"center\">This number shows the chance of saying yes or no<\/td><\/tr><tr><td>5<\/td><td class=\"has-text-align-center\" data-align=\"center\">Use a threshold (like 0.5)<\/td><td class=\"has-text-align-center\" data-align=\"center\">If the chance is more than 0.5 say yes else say no<\/td><\/tr><tr><td>6<\/td><td class=\"has-text-align-center\" data-align=\"center\">Compare prediction with actual result (calculate error)<\/td><td class=\"has-text-align-center\" data-align=\"center\">Check if the model was right or wrong<\/td><\/tr><tr><td>7<\/td><td class=\"has-text-align-center\" data-align=\"center\">Update weights using gradient descent<\/td><td class=\"has-text-align-center\" data-align=\"center\">Adjust the math so the next guess is better<\/td><\/tr><tr><td>8<\/td><td class=\"has-text-align-center\" data-align=\"center\">Repeat the process till the error becomes small<\/td><td class=\"has-text-align-center\" data-align=\"center\">Keep improving till the model becomes good enough<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-evaluation-metrics-for-logistic-regression\"><span class=\"ez-toc-section\" id=\"Evaluation_Metrics_For_Logistic_Regression\"><\/span><strong>Evaluation Metrics For Logistic Regression<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are some evaluation metrics which we are taking care for the logistic regression:<\/p>\n\n\n\n<ol>\n<li><strong>Accuracy<\/strong><br>Percentage of correctly predicted samples out of total samples.<\/li>\n\n\n\n<li><strong>Precision<\/strong><br>Out of all predicted positives, how many are actually positive.<br>Formula: Precision = TP \/ (TP + FP)<\/li>\n\n\n\n<li><strong>Recall (Sensitivity)<\/strong><br>Out of all actual positives, how many were correctly predicted.<br>Formula: Recall = TP \/ (TP + FN)<\/li>\n\n\n\n<li><strong>F1 Score<\/strong><br>Harmonic mean of precision and recall, balances both.<br>Formula: F1 = 2 * (Precision * Recall) \/ (Precision + Recall)<\/li>\n\n\n\n<li><strong>ROC-AUC (Receiver Operating Characteristic &#8211; Area Under Curve)<\/strong><br>Measures the model\u2019s ability to distinguish classes; higher is better.<\/li>\n\n\n\n<li><strong>Log Loss (Cross-Entropy Loss)<\/strong><br>Measures how well the predicted probabilities match actual labels and also lower is better.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-advantages-of-logistic-regression\"><span class=\"ez-toc-section\" id=\"Advantages_of_Logistic_Regression\"><\/span><strong>Advantages of Logistic Regression<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol>\n<li>Easy to implement and understand.<\/li>\n\n\n\n<li>Works well for binary classification problem<\/li>\n\n\n\n<li>Provides probabilities for class predictions.<\/li>\n\n\n\n<li>Can handle both continuous and categorical variables.<\/li>\n\n\n\n<li>Requires less computation compared to complex models.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-disadvantages-of-logistic-regression\"><span class=\"ez-toc-section\" id=\"Disadvantages_of_Logistic_Regression\"><\/span><strong>Disadvantages of Logistic Regression<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol>\n<li>Can only handle linear relationships between features and log-odds.<\/li>\n\n\n\n<li>Not suitable for complex or non-linear problems.<\/li>\n\n\n\n<li>Sensitive to outliers and noisy data.<\/li>\n\n\n\n<li>Assumes no multicollinearity among input features.<\/li>\n\n\n\n<li>Can struggle with large number of features without proper regularization.<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/chat.whatsapp.com\/B6weknl7133BQXjPva0pgB\"><img loading=\"lazy\" decoding=\"async\" width=\"864\" height=\"129\" src=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-54.png\" alt=\"\" class=\"wp-image-51118\" srcset=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-54.png 864w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-54-300x45.png 300w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-54-768x115.png 768w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-54-150x22.png 150w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-54-696x104.png 696w\" sizes=\"(max-width: 864px) 100vw, 864px\" \/><\/a><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-applications-of-logistic-regression\"><span class=\"ez-toc-section\" id=\"Applications_of_Logistic_Regression\"><\/span><strong>Applications of Logistic Regression<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol>\n<li>Predicting whether a patient has a specific disease based on medical data.<\/li>\n\n\n\n<li>Assessing the likelihood that a loan applicant will default on payment.<\/li>\n\n\n\n<li>Forecasting if a customer will buy a product or respond to a campaign.<\/li>\n\n\n\n<li>Classifying emails accurately as spam or legitimate messages.<\/li>\n\n\n\n<li>Predicting if customers are likely to stop using a service or product.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Logistic regression is a powerful and easy-to-use classification method that helps predict binary outcomes. It works well when the relationship between features and the target is roughly linear on the log-odds scale. Despite some limitations like handling only linear relationships and sensitivity to outliers, it remains widely used in fields like healthcare, finance, and marketing because of its interpretability and efficiency. Understanding its assumptions and evaluation metrics helps build better and reliable models.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-frequently-asked-questions-faqs\"><span class=\"ez-toc-section\" id=\"Frequently_Asked_Questions_FAQs\"><\/span><strong>Frequently Asked Questions (FAQs)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_logistic_regression_used_for\"><\/span><strong>What is logistic regression used for?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>It is used to predict binary outcomes like yes\/no or true\/false decisions based on input features.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/chat.whatsapp.com\/B6weknl7133BQXjPva0pgB\"><img loading=\"lazy\" decoding=\"async\" width=\"864\" height=\"129\" src=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-55.png\" alt=\"\" class=\"wp-image-51119\" srcset=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-55.png 864w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-55-300x45.png 300w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-55-768x115.png 768w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-55-150x22.png 150w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/image-55-696x104.png 696w\" sizes=\"(max-width: 864px) 100vw, 864px\" \/><\/a><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_is_logistic_regression_different_from_linear_regression\"><\/span><strong>How is logistic regression different from linear regression?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Logistic regression predicts probabilities and class labels for classification problems, while linear regression predicts continuous numeric values.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_are_the_key_assumptions_of_logistic_regression\"><\/span><strong>What are the key assumptions of logistic regression?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The main assumptions are no multicollinearity among features, linearity between features and the log-odds of the outcome, and independent observations.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Imagine you want to know if someone will click on an ad or not. You have some basic info like age income or search history. Logistic regression takes that info and gives you a number like 0.73 which means there is a 73 percent chance they will click. If the number is more than 0.5 [&hellip;]<\/p>\n","protected":false},"author":560,"featured_media":51122,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1074,1073],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.4 (Yoast SEO v21.9.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Logistic Regression in Machine Learning - iQuanta<\/title>\n<meta name=\"description\" content=\"Learn logistic regression in machine learning explained in simple words with real life examples types how it works and code using Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Logistic Regression in Machine Learning\" \/>\n<meta property=\"og:description\" content=\"Learn logistic regression in machine learning explained in simple words with real life examples types how it works and code using Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/\" \/>\n<meta property=\"og:site_name\" content=\"iQuanta\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/iquanta.in\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-05T11:58:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-05T12:07:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/Your-paragraph-text-29.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Nidhi Goswami\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nidhi Goswami\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/\"},\"author\":{\"name\":\"Nidhi Goswami\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/ec8c8c25d0526dd86557b6fed064f7f3\"},\"headline\":\"Logistic Regression in Machine Learning\",\"datePublished\":\"2025-06-05T11:58:38+00:00\",\"dateModified\":\"2025-06-05T12:07:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/\"},\"wordCount\":1253,\"publisher\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/#organization\"},\"articleSection\":[\"Data Analytics\",\"iSkills\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/\",\"url\":\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/\",\"name\":\"Logistic Regression in Machine Learning - iQuanta\",\"isPartOf\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/#website\"},\"datePublished\":\"2025-06-05T11:58:38+00:00\",\"dateModified\":\"2025-06-05T12:07:47+00:00\",\"description\":\"Learn logistic regression in machine learning explained in simple words with real life examples types how it works and code using Python.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.iquanta.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Logistic Regression in Machine Learning\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#website\",\"url\":\"https:\/\/www.iquanta.in\/blog\/\",\"name\":\"iQuanta | Cat Preparation Online\",\"description\":\"Building Learning Networks\",\"publisher\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.iquanta.in\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#organization\",\"name\":\"IQuanta\",\"url\":\"https:\/\/www.iquanta.in\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2018\/08\/IQuanta-1.png\",\"contentUrl\":\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2018\/08\/IQuanta-1.png\",\"width\":525,\"height\":200,\"caption\":\"IQuanta\"},\"image\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/iquanta.in\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/ec8c8c25d0526dd86557b6fed064f7f3\",\"name\":\"Nidhi Goswami\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/21d234d87afd924b217d26b25a3cf1ee?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/21d234d87afd924b217d26b25a3cf1ee?s=96&d=mm&r=g\",\"caption\":\"Nidhi Goswami\"},\"url\":\"https:\/\/www.iquanta.in\/blog\/author\/nidhigoswami\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Logistic Regression in Machine Learning - iQuanta","description":"Learn logistic regression in machine learning explained in simple words with real life examples types how it works and code using Python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/","og_locale":"en_US","og_type":"article","og_title":"Logistic Regression in Machine Learning","og_description":"Learn logistic regression in machine learning explained in simple words with real life examples types how it works and code using Python.","og_url":"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/","og_site_name":"iQuanta","article_publisher":"https:\/\/facebook.com\/iquanta.in","article_published_time":"2025-06-05T11:58:38+00:00","article_modified_time":"2025-06-05T12:07:47+00:00","og_image":[{"width":1600,"height":900,"url":"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/06\/Your-paragraph-text-29.png","type":"image\/png"}],"author":"Nidhi Goswami","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Nidhi Goswami","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#article","isPartOf":{"@id":"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/"},"author":{"name":"Nidhi Goswami","@id":"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/ec8c8c25d0526dd86557b6fed064f7f3"},"headline":"Logistic Regression in Machine Learning","datePublished":"2025-06-05T11:58:38+00:00","dateModified":"2025-06-05T12:07:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/"},"wordCount":1253,"publisher":{"@id":"https:\/\/www.iquanta.in\/blog\/#organization"},"articleSection":["Data Analytics","iSkills"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/","url":"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/","name":"Logistic Regression in Machine Learning - iQuanta","isPartOf":{"@id":"https:\/\/www.iquanta.in\/blog\/#website"},"datePublished":"2025-06-05T11:58:38+00:00","dateModified":"2025-06-05T12:07:47+00:00","description":"Learn logistic regression in machine learning explained in simple words with real life examples types how it works and code using Python.","breadcrumb":{"@id":"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.iquanta.in\/blog\/logistic-regression-in-machine-learning\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.iquanta.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Logistic Regression in Machine Learning"}]},{"@type":"WebSite","@id":"https:\/\/www.iquanta.in\/blog\/#website","url":"https:\/\/www.iquanta.in\/blog\/","name":"iQuanta | Cat Preparation Online","description":"Building Learning Networks","publisher":{"@id":"https:\/\/www.iquanta.in\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.iquanta.in\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.iquanta.in\/blog\/#organization","name":"IQuanta","url":"https:\/\/www.iquanta.in\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.iquanta.in\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2018\/08\/IQuanta-1.png","contentUrl":"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2018\/08\/IQuanta-1.png","width":525,"height":200,"caption":"IQuanta"},"image":{"@id":"https:\/\/www.iquanta.in\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/iquanta.in"]},{"@type":"Person","@id":"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/ec8c8c25d0526dd86557b6fed064f7f3","name":"Nidhi Goswami","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/21d234d87afd924b217d26b25a3cf1ee?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/21d234d87afd924b217d26b25a3cf1ee?s=96&d=mm&r=g","caption":"Nidhi Goswami"},"url":"https:\/\/www.iquanta.in\/blog\/author\/nidhigoswami\/"}]}},"_links":{"self":[{"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/posts\/51095"}],"collection":[{"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/users\/560"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/comments?post=51095"}],"version-history":[{"count":9,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/posts\/51095\/revisions"}],"predecessor-version":[{"id":51124,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/posts\/51095\/revisions\/51124"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/media\/51122"}],"wp:attachment":[{"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/media?parent=51095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/categories?post=51095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/tags?post=51095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}