R
Rishtaara
Machine Learning Fundamentals
Lesson 3 of 8Article17 min

Supervised Learning Foundations

Supervised learning uses input-output pairs to learn a mapping from features to labels.

Core supervised setup

Supervised learning uses input-output pairs to learn a mapping from features to labels.

  • Regression predicts continuous values.
  • Classification predicts discrete classes.
  • Generalization means good performance on unseen data.

Train/test split example

Simple model training loop
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier

X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42, stratify=y
)

model = DecisionTreeClassifier(max_depth=5, random_state=42)
model.fit(X_train, y_train)