Data Driven Approach

Unlike the Model Based Approach, the Data Driven Approach doesn't assume a fixed mathematical structure - instead, it learns patterns directly from historical data using machine learning techniques.

The Core Idea

# Instead of assuming a formula for the series,
# treat forecasting as a supervised learning problem:
#
# Use past values (lags) as features to predict the next value

Creating Lag Features in Python

import pandas as pd
from sklearn.ensemble import RandomForestRegressor

df["Lag1"] = df["Sales"].shift(1)
df["Lag2"] = df["Sales"].shift(2)
df = df.dropna()

X = df[["Lag1", "Lag2"]]
y = df["Sales"]

model = RandomForestRegressor(n_estimators=100, random_state=42)
model.fit(X, y)

print(model.predict(X.tail(3)))

Advantages

Data driven approaches can capture complex, non-linear relationships and work well when there's plenty of historical data, without needing strict statistical assumptions.

Limitations

These models are typically less interpretable than statistical models, and they need enough historical data to learn meaningful patterns - they can perform poorly on very short series.

In practice, many real-world forecasting systems combine both approaches - a model based baseline supplemented with a data driven model trained on the residual errors.

Coming Up Next

Next, you'll move to a different area of machine learning - Clustering.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course