{"id":175,"date":"2026-03-03T11:42:47","date_gmt":"2026-03-03T06:42:47","guid":{"rendered":"https:\/\/gigz.pk\/python\/?post_type=lesson&#038;p=175"},"modified":"2026-03-17T09:27:03","modified_gmt":"2026-03-17T04:27:03","slug":"regression-models","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/python\/lesson\/regression-models\/","title":{"rendered":"Regression Models"},"content":{"rendered":"\n<p>Regression models are Machine Learning algorithms used to predict continuous numerical values.<\/p>\n\n\n\n<p>If the output is a number (price, score, temperature, salary), regression is used.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>Predict house price<br>Predict sales revenue<br>Predict student marks<br>Predict stock value<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Regression?<\/h2>\n\n\n\n<p>Regression finds the relationship between:<\/p>\n\n\n\n<p>Independent variables (Features \u2013 X)<br>Dependent variable (Target \u2013 y)<\/p>\n\n\n\n<p>The goal is to predict a continuous output value.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>X \u2192 Study Hours<br>y \u2192 Exam Score<\/p>\n\n\n\n<p>The model learns how study hours affect score.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Types of Regression Models<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Linear Regression<\/h3>\n\n\n\n<p>The simplest regression model.<\/p>\n\n\n\n<p>It assumes a linear relationship between input and output.<\/p>\n\n\n\n<p>Equation:<\/p>\n\n\n\n<p>y = mx + b<\/p>\n\n\n\n<p>Used when data follows a straight-line pattern.<\/p>\n\n\n\n<p>Example use cases:<\/p>\n\n\n\n<p>House price prediction<br>Sales forecasting<br>Trend analysis<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Multiple Linear Regression<\/h2>\n\n\n\n<p>Used when there are multiple input features.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>Price = f(Size, Location, Bedrooms)<\/p>\n\n\n\n<p>Instead of one variable, it uses many variables.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Polynomial Regression<\/h2>\n\n\n\n<p>Used when data is not linear.<\/p>\n\n\n\n<p>It adds polynomial terms to capture curved relationships.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>y = ax\u00b2 + bx + c<\/p>\n\n\n\n<p>Useful when data shows a curve.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Ridge Regression<\/h2>\n\n\n\n<p>Used to prevent overfitting.<\/p>\n\n\n\n<p>Adds a penalty term to reduce large coefficients.<\/p>\n\n\n\n<p>Useful when:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Many features<\/li>\n\n\n\n<li>Multicollinearity exists<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">5. Lasso Regression<\/h2>\n\n\n\n<p>Similar to Ridge but can reduce some coefficients to zero.<\/p>\n\n\n\n<p>Useful for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Feature selection<\/li>\n\n\n\n<li>Reducing model complexity<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">6. Decision Tree Regressor<\/h2>\n\n\n\n<p>Splits data into branches to make predictions.<\/p>\n\n\n\n<p>Works well for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Non-linear data<\/li>\n\n\n\n<li>Complex relationships<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">7. Random Forest Regressor<\/h2>\n\n\n\n<p>Uses multiple decision trees.<\/p>\n\n\n\n<p>Improves:<\/p>\n\n\n\n<p>Accuracy<br>Stability<br>Generalization<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Evaluation Metrics for Regression<\/h2>\n\n\n\n<p>To measure performance:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Mean Absolute Error (MAE)<\/h3>\n\n\n\n<p>Average of absolute differences between actual and predicted values.<\/p>\n\n\n\n<p>Lower is better.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Mean Squared Error (MSE)<\/h3>\n\n\n\n<p>Average of squared errors.<\/p>\n\n\n\n<p>Penalizes large errors more.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Root Mean Squared Error (RMSE)<\/h3>\n\n\n\n<p>Square root of MSE.<\/p>\n\n\n\n<p>More interpretable because it is in original unit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. R-Squared (R\u00b2)<\/h3>\n\n\n\n<p>Shows how well model explains variance.<\/p>\n\n\n\n<p>Value range:<\/p>\n\n\n\n<p>0 to 1<\/p>\n\n\n\n<p>Higher is better.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example Using Scikit-Learn<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">from sklearn.linear_model import LinearRegression<br>from sklearn.model_selection import train_test_split<br>import numpy as np# Sample Data<br>X = np.array([[1], [2], [3], [4], [5]])<br>y = np.array([2, 4, 6, 8, 10])# Split Data<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)# Create Model<br>model = LinearRegression()# Train Model<br>model.fit(X_train, y_train)# Predict<br>predictions = model.predict(X_test)print(predictions)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">When to Use Regression Models<\/h2>\n\n\n\n<p>Use regression when:<\/p>\n\n\n\n<p>Target variable is numeric<br>You need forecasting<br>You want to understand relationships between variables<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Real-World Applications<\/h2>\n\n\n\n<p>Real estate price prediction<br>Sales forecasting<br>Demand prediction<br>Stock price estimation<br>Risk analysis<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Key Takeaway<\/h2>\n\n\n\n<p>Regression models are used to predict continuous numerical values.<\/p>\n\n\n\n<p>From simple Linear Regression to advanced models like Random Forest, regression techniques help solve real-world prediction problems efficiently.<\/p>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773721648325\"><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\/python\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">PYTHON FOR AI AND LLM (PYAI) > Scikit-Learn > Regression Models<\/span><\/span><\/div>","protected":false},"menu_order":98,"template":"","class_list":["post-175","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Regression Models - One Language. Endless Possibilities<\/title>\n<meta name=\"description\" content=\"Learn regression models in Machine Learning to predict numeric values using Linear, Polynomial, Ridge, Lasso, and Random Forest techniques.\" \/>\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\/python\/lesson\/regression-models\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Regression Models - One Language. Endless Possibilities\" \/>\n<meta property=\"og:description\" content=\"Learn regression models in Machine Learning to predict numeric values using Linear, Polynomial, Ridge, Lasso, and Random Forest techniques.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/python\/lesson\/regression-models\/\" \/>\n<meta property=\"og:site_name\" content=\"One Language. Endless Possibilities\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-17T04:27:03+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\\\/python\\\/lesson\\\/regression-models\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/regression-models\\\/\",\"name\":\"Regression Models - One Language. Endless Possibilities\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\"},\"datePublished\":\"2026-03-03T06:42:47+00:00\",\"dateModified\":\"2026-03-17T04:27:03+00:00\",\"description\":\"Learn regression models in Machine Learning to predict numeric values using Linear, Polynomial, Ridge, Lasso, and Random Forest techniques.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/regression-models\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/regression-models\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/regression-models\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PYTHON FOR AI AND LLM (PYAI) > Scikit-Learn > Regression Models\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\",\"name\":\"One Language. Endless Possibilities\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/python\\\/?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":"Regression Models - One Language. Endless Possibilities","description":"Learn regression models in Machine Learning to predict numeric values using Linear, Polynomial, Ridge, Lasso, and Random Forest techniques.","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\/python\/lesson\/regression-models\/","og_locale":"en_US","og_type":"article","og_title":"Regression Models - One Language. Endless Possibilities","og_description":"Learn regression models in Machine Learning to predict numeric values using Linear, Polynomial, Ridge, Lasso, and Random Forest techniques.","og_url":"https:\/\/gigz.pk\/python\/lesson\/regression-models\/","og_site_name":"One Language. Endless Possibilities","article_modified_time":"2026-03-17T04:27:03+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\/python\/lesson\/regression-models\/","url":"https:\/\/gigz.pk\/python\/lesson\/regression-models\/","name":"Regression Models - One Language. Endless Possibilities","isPartOf":{"@id":"https:\/\/gigz.pk\/python\/#website"},"datePublished":"2026-03-03T06:42:47+00:00","dateModified":"2026-03-17T04:27:03+00:00","description":"Learn regression models in Machine Learning to predict numeric values using Linear, Polynomial, Ridge, Lasso, and Random Forest techniques.","breadcrumb":{"@id":"https:\/\/gigz.pk\/python\/lesson\/regression-models\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/python\/lesson\/regression-models\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/python\/lesson\/regression-models\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/python\/"},{"@type":"ListItem","position":2,"name":"PYTHON FOR AI AND LLM (PYAI) > Scikit-Learn > Regression Models"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/python\/#website","url":"https:\/\/gigz.pk\/python\/","name":"One Language. Endless Possibilities","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/media?parent=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}