Path: blob/master/Data Analytics Using Python/5 Simple Linear regression.ipynb
3074 views
Regression in Machine Learning
What is Regression?
Regression is a supervised learning technique used when the target variable is continuous. It models the relationship between a dependent variable (target) and one or more independent variables (features).
Goal: Predict a numerical value (e.g., salary, price, temperature) based on input data.
Why Use Regression?
Predict housing prices based on size, location, etc.
Forecast sales or stock prices
Estimate student marks based on study hours
Types of Regression
Type | Description | Example |
---|---|---|
Linear Regression | One dependent, one/multiple independent vars | Salary vs Experience |
Polynomial Regression | Features raised to a power (non-linear curves) | Age vs Cholesterol levels |
Ridge/Lasso Regression | Regularized linear regression | Used to prevent overfitting |
Logistic Regression (Special) | Used for classification problems | Yes/No outcomes |
Simple Linear Regression Formula
Example: Salary Prediction
Experience (Years) | Salary (Lakhs) |
---|---|
1 | 2.5 |
2 | 3.2 |
3 | 3.8 |
4 | 4.5 |
5 | 5.0 |
Model may learn: [ \text{Salary} = 0.58 \times \text{Experience} + 1.95 ]
Visual Representation
The regression line tries to minimize the distance (error) between actual and predicted values.
In simple linear regression, it’s a straight line.
In polynomial regression, it’s a curve.
Summary
Regression is used when the target is continuous.
Linear regression is the most common starting point.
Helps understand relationships and make predictions.