Your First ML Model
You know what ML is and its three types. Now let’s build your first mental model of how machines actually learn — from data to predictions.
What is a Model?
A function that takes inputs and produces outputs. In traditional programming, humans write the rules. In ML, the model discovers the rules from data.
Features & Labels
Features (X) are inputs the model uses. Labels (y) are answers it predicts. Feature quality often matters more than algorithm choice.
Training Data
A model learns from examples where we already know the answers. More examples, more representative → better model. Bad data = bad model.
Predict → Compare → Adjust
The fundamental mechanism behind all supervised learning:
Loss Functions
The model’s report card. Mean Squared Error squares prediction errors and averages them — penalizing large mistakes heavily.
Gradient Descent
Imagine standing on a hill in fog. You can’t see the bottom, but you feel the slope. Take a step downhill. Repeat. That’s gradient descent.
Linear Regression
The simplest ML model: a straight line. w is the weight (slope), b is the bias (intercept). Despite its simplicity, it’s powerful and widely used.
Overfitting vs Underfitting
The central challenge of ML:
Train / Test Split
Hold out data the model never sees during training. Evaluate on it. If training accuracy is high but test accuracy is low — overfitting detected.
The Full ML Pipeline
Five steps, always iterative:
What you learned
A model learns from data through predict → measure → adjust loops. Loss functions guide learning. Gradient descent finds the minimum. Train/test splits catch overfitting.