—
I’ve reached a brand new milestone in my knowledge science journey: Regression Evaluation!
What’s regression? When and why ought to we use it?
On this submit, I’ll cowl elementary regression ideas, step-by-step Python implementation, efficiency analysis metrics, and visualizations.
—
Regression is a machine studying algorithm used to foretell a dependent (goal) variable primarily based on unbiased variables (options).
📊 Instance Use Instances:
Home value prediction
Gross sales forecasting
Temperature prediction
—
- Easy Linear Regression
- A number of Linear Regression
- Polynomial Regression
- Ridge, Lasso, ElasticNet
- Choice Tree Regressor,
- Random Forest Regressor
—
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score
x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9]).reshape(-1, 1)
y = np.array([2, 4, 5, 4, 5, 6, 7, 8, 9])
mannequin = LinearRegression()
mannequin.match(x, y)
y_pred = mannequin.predict(x)
print("Coefficient:", mannequin.coef_)
print("Intercept:", mannequin.intercept_)
print("MSE:", mean_squared_error(y, y_pred))
print("R2 Rating:", r2_score(y, y_pred))
plt.scatter(x, y, shade='blue', label='Precise Information')
plt.plot(x, y_pred, shade='pink', label='Prediction Line')
plt.title("Easy Linear Regression")
plt.xlabel("Impartial Variable")
plt.ylabel("Dependent Variable")
plt.legend()
plt.present()
—
Metric Description:
MSE Imply Squared Error
R2 Mannequin’s explanatory energy
MAE Imply Absolute Error
—
Within the subsequent article: A number of Linear Regression and Polynomial Regression fashions! 🚀