📈 Linear Regression
Linear Regression models the relationship between a dependent variable (outcome) and one or more independent variables (predictors) using a straight line. It is mainly used for continuous outcomes.
- ✔ Helps predict sales, revenue, or prices
- ✔ Useful for trend forecasting (e.g., monthly sales growth)
- ✔ Identifies how much each factor influences the outcome
# Example: Predicting sales from advertising spend
import pandas as pd
from sklearn.linear_model import LinearRegression
# Dataset
data = {'Ad_Spend': [10, 20, 30, 40, 50], 'Sales': [25, 40, 55, 70, 85]}
df = pd.DataFrame(data)
X = df[['Ad_Spend']]
y = df['Sales']
model = LinearRegression()
model.fit(X, y)
print("Coefficient:", model.coef_[0])
print("Intercept:", model.intercept_)
Business Example: A company estimates how advertising spend impacts revenue.
