Introduction to Regression

 

Introduction to Regression

Regression is a statistical and machine learning technique used to study the relationship between variables and to predict an output based on one or more input variables.

For example:

  • Predicting salary based on years of experience
  • Predicting house price based on its area and number of rooms
  • Predicting whether a student will pass or fail based on attendance and marks

In regression terminology:

  • Independent variable / Predictor / Input (XX) → Variable used for prediction.
  • Dependent variable / Response / Output (YY) → Variable to be predicted.

1. Linear Regression

Linear regression studies the relationship between one independent variable and a continuous dependent variable.

Example

Predicting a student's marks based on the number of hours studied.

Hours Studied→Marks\text{Hours Studied} \rightarrow \text{Marks}

The model tries to find the best-fitting straight line through the data.



The general form is:

Y=β0+β1XY = \beta_0 + \beta_1X

where:

  • β0\beta_0 → Intercept
  • β1\beta_1 → Slope
  • XX → Input variable
  • YY → Predicted output

Example

Marks=40+5(Hours Studied)\text{Marks} = 40 + 5(\text{Hours Studied})

2. Multiple Linear Regression

Multiple linear regression is used when we want to predict a continuous output using two or more independent variables.

Example

Predicting student marks using:

  • Hours studied
  • Attendance percentage
  • Previous examination marks

The model can be represented as:

Y=β0+β1X1+β2X2+⋯+βnXnY=\beta_0+\beta_1X_1+\beta_2X_2+\cdots+\beta_nX_n

Example

Marks=β0+β1(Study Hours)+β2(Attendance)+β3(Previous Marks)\text{Marks} = \beta_0+ \beta_1(\text{Study Hours})+ \beta_2(\text{Attendance})+ \beta_3(\text{Previous Marks})

Simple Linear Regression → One predictor
Multiple Linear Regression → Multiple predictors


3. Logistic Regression

Despite its name, logistic regression is mainly used for classification problems.

It predicts the probability that an observation belongs to a particular class.

Example

Predicting whether a student will:

  • Pass (1)
  • Fail (0)

based on variables such as attendance and study hours.

Unlike linear regression, the output is a probability between:

0 and 10 \text{ and } 1

For example:

P(Pass)=0.85P(\text{Pass})=0.85

This means that the model estimates an 85% probability that the student will pass.

A threshold, often 0.5, can then be used to convert the probability into a class prediction.

At threshold 0.50:

We compute a linear combination of inputs:

z=β0+β1x1+β2x2+⋯+βnxn

Then apply the sigmoid function:

y^=11+e−z

  • y^= predicted probability
  • Output is always between 0 and 1

Quick Comparison

TypeNumber of PredictorsOutput TypeExample
Linear Regression OneContinuous  Predict marks from study hours
Multiple Linear Regression Two or moreContinuous  Predict marks from hours, attendance, etc.
Logistic Regression One or moreCategorical/Class  Predict pass or fail

Summary

Regression is used to understand relationships between variables and make predictions: linear regression predicts continuous values, multiple linear regression uses several predictors, and logistic regression predicts the probability of belonging to a class.

Comments

Popular posts from this blog

Statistical Methods Lab ( R Language) PCCBL308 Semester 3 KTU BTech CB and CU 2024 Scheme - Dr Binu V P

Programs in R - using control statements - Assignment 2

Programs to try using Functions in R - Assignment 3