What is a Model?
The core concept: a function learned from data that makes predictions
Knowledge Debt detected
You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.
Explanation
A machine learning model is a mathematical function that maps inputs to outputs, learned from data rather than manually programmed.
Traditional programming:
Rules + Data → Output
Machine learning:
Data + Output (labels) → Rules (the model)
Example — predicting house price:
- Input (features): size, bedrooms, location, age
- Output (label): price
- Model: learns the relationship between features and price from historical data
- Prediction: given a new house's features, output a price estimate
The workflow:
- 1. Collect labeled data (examples with known outputs)
- 2. Choose a model type (linear regression, decision tree, neural network…)
- 3. Train the model — adjust its internal parameters to fit the data
- 4. Evaluate — how well does it predict on data it hasn't seen?
- 5. Predict — apply the trained model to new, unseen inputs
Key insight: The model doesn't "know" anything — it has learned statistical patterns. It will fail on data that looks nothing like its training data.
Examples
The simplest possible model
fit() = train, predict() = apply to new data
from sklearn.linear_model import LinearRegression
import numpy as np
# Training data: hours studied → exam score
X = np.array([[1],[2],[3],[4],[5]]) # features must be 2D
y = np.array([50, 60, 65, 72, 80]) # labels
model = LinearRegression()
model.fit(X, y) # TRAINING
# Predict for a student who studied 6 hours
pred = model.predict([[6]])
print(f"Predicted score: {pred[0]:.1f}") # ~86Next in Machine Learning Basics
Train/Test Split