{"id":61,"date":"2026-04-03T11:03:53","date_gmt":"2026-04-03T11:03:53","guid":{"rendered":"https:\/\/gigz.pk\/ml\/?post_type=lesson&#038;p=61"},"modified":"2026-04-07T06:42:24","modified_gmt":"2026-04-07T06:42:24","slug":"logistic-regression","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/ml\/lesson\/logistic-regression\/","title":{"rendered":"\u00a0Logistic Regression"},"content":{"rendered":"\n<p>Logistic Regression is a widely used Machine Learning algorithm for <strong>classification problems<\/strong>. Unlike Linear Regression, which predicts continuous values, Logistic Regression predicts the probability that a given input belongs to a particular class. It is commonly used for <strong>binary classification<\/strong> (two classes) but can be extended to multi-class problems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Logistic Regression Works<\/h2>\n\n\n\n<p>Logistic Regression uses a <strong>sigmoid function<\/strong> to map predicted values to probabilities between 0 and 1. The sigmoid function is defined as:<\/p>\n\n\n\n<p><code>\u03c3(z) = 1 \/ (1 + e^(-z))<\/code><\/p>\n\n\n\n<p>Where <code>z<\/code> is the linear combination of input features:<\/p>\n\n\n\n<p><code>z = b0 + b1*x1 + b2*x2 + ... + bn*xn<\/code><\/p>\n\n\n\n<p>The output probability indicates the likelihood that the input belongs to a particular class. A threshold (commonly 0.5) is used to assign the input to a class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps in Logistic Regression<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Collect and Prepare Data:<\/strong> Gather labeled data with input features and binary or categorical output.<\/li>\n\n\n\n<li><strong>Split Data:<\/strong> Divide the dataset into training and testing sets.<\/li>\n\n\n\n<li><strong>Train the Model:<\/strong> Fit the logistic regression model to the training data to find the best coefficients.<\/li>\n\n\n\n<li><strong>Make Predictions:<\/strong> Use the model to predict probabilities and classify new data.<\/li>\n\n\n\n<li><strong>Evaluate the Model:<\/strong> Use metrics like Accuracy, Precision, Recall, F1 Score, and ROC-AUC to assess performance.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Applications of Logistic Regression<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Email spam detection (spam or not spam)<\/li>\n\n\n\n<li>Predicting whether a customer will buy a product (yes\/no)<\/li>\n\n\n\n<li>Disease diagnosis (positive\/negative) based on medical data<\/li>\n\n\n\n<li>Loan approval prediction (approved\/rejected)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Advantages<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Simple and easy to implement<\/li>\n\n\n\n<li>Provides probabilities for predictions<\/li>\n\n\n\n<li>Works well for binary and linearly separable problems<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Limitations<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Cannot handle complex non-linear relationships without feature transformations<\/li>\n\n\n\n<li>Sensitive to outliers<\/li>\n\n\n\n<li>Assumes that features are independent of each other (multicollinearity can reduce performance)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Logistic Regression is a fundamental classification algorithm in Machine Learning. It is simple, interpretable, and effective for binary classification problems. Understanding Logistic Regression is important before moving on to more advanced classification algorithms.<\/p>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1775543840995\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/ml\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">Machine Learning Foundations > Supervised Learning > Logistic Regression<\/span><\/span><\/div>","protected":false},"menu_order":18,"template":"","class_list":["post-61","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u00a0Logistic Regression - Machine Learning Mastery<\/title>\n<meta name=\"description\" content=\"Discover Logistic Regression in ML \u2014 how it works, sigmoid function, applications, and key advantages for classification problems.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u00a0Logistic Regression - Machine Learning Mastery\" \/>\n<meta property=\"og:description\" content=\"Discover Logistic Regression in ML \u2014 how it works, sigmoid function, applications, and key advantages for classification problems.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/\" \/>\n<meta property=\"og:site_name\" content=\"Machine Learning Mastery\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-07T06:42:24+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/ml\\\/lesson\\\/logistic-regression\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/\",\"name\":\"\u00a0Logistic Regression - Machine Learning Mastery\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/ml\\\/#website\"},\"datePublished\":\"2026-04-03T11:03:53+00:00\",\"dateModified\":\"2026-04-07T06:42:24+00:00\",\"description\":\"Discover Logistic Regression in ML \u2014 how it works, sigmoid function, applications, and key advantages for classification problems.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/ml\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Machine Learning Foundations > Supervised Learning > Logistic Regression\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/ml\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/ml\\\/\",\"name\":\"Machine Learning Mastery\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/ml\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u00a0Logistic Regression - Machine Learning Mastery","description":"Discover Logistic Regression in ML \u2014 how it works, sigmoid function, applications, and key advantages for classification problems.","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:\/\/gigz.pk\/","og_locale":"en_US","og_type":"article","og_title":"\u00a0Logistic Regression - Machine Learning Mastery","og_description":"Discover Logistic Regression in ML \u2014 how it works, sigmoid function, applications, and key advantages for classification problems.","og_url":"https:\/\/gigz.pk\/","og_site_name":"Machine Learning Mastery","article_modified_time":"2026-04-07T06:42:24+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/ml\/lesson\/logistic-regression\/","url":"https:\/\/gigz.pk\/","name":"\u00a0Logistic Regression - Machine Learning Mastery","isPartOf":{"@id":"https:\/\/gigz.pk\/ml\/#website"},"datePublished":"2026-04-03T11:03:53+00:00","dateModified":"2026-04-07T06:42:24+00:00","description":"Discover Logistic Regression in ML \u2014 how it works, sigmoid function, applications, and key advantages for classification problems.","breadcrumb":{"@id":"https:\/\/gigz.pk\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/ml\/"},{"@type":"ListItem","position":2,"name":"Machine Learning Foundations > Supervised Learning > Logistic Regression"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/ml\/#website","url":"https:\/\/gigz.pk\/ml\/","name":"Machine Learning Mastery","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/ml\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/ml\/wp-json\/wp\/v2\/lesson\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/ml\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/ml\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/ml\/wp-json\/wp\/v2\/media?parent=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}