Simple Linear Regression Notes
Simple Linear Regression Notes
Definition:
Simple Linear Regression is a statistical method used to find the relationship between two variables:
It fits a straight line (called a regression line) through the data to predict Y from X.
Basic Idea:
If we know that X (like study hours) affects Y (like marks), then we try to draw a straight line that
Y = b0 + b1X
Example:
Lets say we want to predict marks (Y) based on study hours (X).
Y = 30 + 5X
This means:
Graphical View:
A scatter plot of data is made with X and Y values. Then a straight line is drawn to minimize the
difference between actual Y values and predicted Y values. This line is called the "best fit line".
Where:
Advantages:
Limitations:
- Sensitive to outliers
Applications:
import numpy as np
Y = np.array([2, 4, 5, 4, 5])
model = LinearRegression()
model.fit(X, Y)
# Predict
predicted = model.predict([[6]])
print("Predicted value for X=6 is:", predicted[0])
Simple Linear Regression is a method to model the relationship between one independent and one
dependent variable using a straight line. The model predicts the output by fitting the best line using
the least squares method. It is useful for understanding and forecasting outcomes based on a single
input feature.