Polynomial Regression
Description
Polynomial Regression is an extension of linear regression that models the relationship between the independent variable(s) and the dependent variable as an nth degree polynomial. It is useful when the data shows a nonlinear relationship but can still be fitted with a polynomial curve.
Polynomial Regression
The model fits a polynomial equation to the data:
Y = β₀ + β₁X + β₂X² + β₃X³ + ... + βₙXⁿ + ε
- β₀, β₁, ..., βₙ are the polynomial coefficients.
- Xⁿ represents the independent variable raised to the nth power.
- Can capture curves and nonlinear trends in data.
- Higher degree polynomials can lead to overfitting.
Examples
Polynomial Regression Example in Python
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
# Sample data
X = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9]).reshape(-1, 1)
y = np.array([1, 4, 9, 16, 25, 36, 49, 64, 81]) # y = x^2
# Transform features to polynomial features degree=2
poly = PolynomialFeatures(degree=2)
X_poly = poly.fit_transform(X)
# Create and train model
model = LinearRegression()
model.fit(X_poly, y)
# Predictions
y_pred = model.predict(X_poly)
# Plot
plt.scatter(X, y, color='blue')
plt.plot(X, y_pred, color='red')
plt.title('Polynomial Regression (Degree=2)')
plt.xlabel('X')
plt.ylabel('Y')
plt.show()
Real-World Applications
Polynomial Regression Applications
- Economics: Modeling complex relationships like GDP growth over time with nonlinear trends.
- Engineering: Curve fitting for stress-strain data, signal processing.
- Environmental Science: Modeling temperature changes or pollution levels over time.
- Biology: Growth rates of organisms that follow nonlinear patterns.
- Finance: Modeling nonlinear price trends in stocks and commodities.

Resources
The following resources will be manually added later:
Video Tutorials
PDF/DOC Materials
Interview Questions
1. What is polynomial regression and how does it differ from linear regression?
Polynomial regression fits a polynomial equation to the data allowing for curvature, while linear regression fits a straight line. Polynomial regression models nonlinear relationships by including powers of the independent variable.
2. How do you choose the degree of the polynomial in polynomial regression?
The degree is usually chosen based on domain knowledge, visualizing the data, or using techniques like cross-validation to avoid overfitting or underfitting.
3. What are the risks of using high-degree polynomials in regression?
High-degree polynomials can cause overfitting, where the model fits noise instead of the underlying trend, leading to poor generalization on new data.
4. How do you transform features for polynomial regression?
Features are transformed by creating additional features that are powers of the original features (e.g., X², X³). Libraries like sklearn's PolynomialFeatures automate this process.
5. Can polynomial regression be used with multiple features?
Yes, polynomial regression can be extended to multiple features by including interaction terms and polynomial terms for each feature.