Introduction to Predictive Analytics

From Hindsight to Foresight

Predictive Analytics is the art of using historical data to forecast the future. For **Netflix**, this means answering the billion-dollar question: *"Will this user cancel their subscription next month?"* For **Walmart**, it's predicting demand spikes before they happen. And for **Visa**, it's flagging a fraudulent transaction before it clears.

In this chapter, we lay the groundwork for Machine Learning: the difference between **Supervised** and **Unsupervised** learning, **Feature Engineering** (turning raw data into prediction-ready inputs), and the critical concept of **Train/Test Splits** to avoid overfitting.

Supervised vs. Unsupervised Learning

In **Supervised Learning**, we give the model labeled examples: "This transaction WAS fraud" or "This user DID churn." The model learns the pattern. In **Unsupervised Learning**, we give the model unlabeled data and ask it to find hidden groups. **Netflix** uses supervised learning to predict churn and unsupervised learning to discover new "taste clusters."

PythonRuns entirely in your browser — nothing is sent to a server.

Feature Engineering: The Secret Weapon

Raw data is rarely model-ready. **Feature Engineering** transforms it into powerful predictive signals. For **Netflix**, the raw data is "User watched Stranger Things for 45 minutes." The engineered feature is "User's average binge ratio is 0.85 (they finish 85% of what they start)." This single number is far more predictive of churn than raw watch time.

PythonRuns entirely in your browser — nothing is sent to a server.

Train/Test Split: Avoiding the Illusion of Accuracy

A model that memorizes the training data scores 100% on that data but fails on new, unseen data. This is **Overfitting**. To combat this, we split our dataset: 80% for **Training** and 20% for **Testing**. For **Visa**, this means training the fraud model on historical transactions and testing it on a held-out set it has never seen.

PythonRuns entirely in your browser — nothing is sent to a server.

Practice Questions

Question 1

Why is 'Binge Ratio' a better feature than raw 'Watch Time' for predicting Netflix churn?

  • It is a shorter number
  • It normalizes behavior relative to content length, making it comparable across users who watch different amounts of content
  • It is easier to spell
  • Netflix doesn't use watch time at all

Question 2

What is the primary risk of NOT using a Train/Test split?

  • The model will be too slow
  • The model will overfit to the training data and perform poorly on new, unseen data
  • The database will run out of space
  • Python will throw an error