Machine learning is a subset of artificial intelligence where systems learn patterns from data rather than being explicitly programmed with rules.
Instead of writing:
"If the email contains 'free money', mark it as spam"
You give the system thousands of emails labeled as spam or not spam, and it figures out the patterns on its own.
Every ML system needs three things:
Let's see ML in action. We'll train a simple linear regression model to predict housing prices based on square footage.
Run the code below:
The model learned a relationship between square footage and price from the data. It didn't need explicit rules — it found the pattern (a linear relationship) automatically.
This is the core idea of ML: learn from examples, then generalize to new inputs.
There are three main categories:
We'll cover supervised and unsupervised learning in the next two lessons.
Modify the code below to predict the price of a 2500 sqft house. What happens when you predict for a house far outside the training range (like 10,000 sqft)? Does the prediction still make sense?