Computer ScienceChapter 24 min read

Ch2. Machine Learning Basics — Supervised, Unsupervised, and Reinforcement Learning

O
OIYO EditorialContributor
2/8

What is Machine Learning?

Machine Learning (ML) is a subfield of AI that enables systems to learn patterns from data and make predictions or decisions without being explicitly programmed for each task.

Traditional programming: Rules + Data → Output
Machine Learning: Data + Output → Rules (Model)


The Three Learning Paradigms

1. Supervised Learning

Definition: Learning from data where inputs (X) are paired with labeled outputs (Y)

Goal: Find the mapping function X → Y

Problem TypeExamplesKey Algorithms
ClassificationSpam detection, image classificationLogistic Regression, SVM, Random Forest, Neural Networks
RegressionHouse price prediction, stock forecastingLinear Regression, Ridge, Lasso, Gradient Boosting

The key bottleneck in supervised learning is labeled data. Labeling is expensive and time-consuming — the quantity and quality of labeled data sets the performance ceiling of your model.

2. Unsupervised Learning

Definition: Finding hidden structure or patterns in unlabeled data

Goal: Discover the underlying structure of data without predefined answers

Problem TypeExamplesKey Algorithms
ClusteringCustomer segmentation, document groupingK-means, DBSCAN, Hierarchical Clustering
Dimensionality ReductionVisualization, noise removalPCA, t-SNE, UMAP, Autoencoders
Anomaly DetectionFraud detection, defect detectionIsolation Forest, LOF

3. Reinforcement Learning

Definition: An agent learns to maximize cumulative reward by interacting with an environment

Core Components:

  • Agent: The learning entity
  • Environment: The world the agent interacts with
  • State: The current situation in the environment
  • Action: Choices available to the agent
  • Reward: Feedback signal from the environment

Applications: AlphaGo, autonomous driving, robotics, recommendation systems


Model Evaluation: Overfitting vs. Underfitting

           Underfitting       Just Right       Overfitting
Train Error:   High        →    Low       →    Very Low
Valid Error:   High        →    Low       →    High

Underfitting: Model too simple to capture patterns even in training data
→ Fix: More complex model, more features, less regularization

Overfitting: Model memorizes training data noise, fails to generalize
→ Fix: More data, regularization (L1/L2), dropout, early stopping


The Bias-Variance Tradeoff

Bias: Error from incorrect assumptions (underfitting)
Variance: Error from sensitivity to fluctuations in training data (overfitting)

Total Error = Bias² + Variance + Irreducible Noise

A good model finds the optimal balance between bias and variance.


Comparing Key ML Algorithms

AlgorithmStrengthsWeaknessesBest For
Linear RegressionInterpretable, fastCannot capture nonlinearityClear linear relationships
Decision TreeIntuitive, handles nonlinearityProne to overfittingInterpretability-critical tasks
Random ForestRobust, resists overfittingSlow, hard to interpretGeneral classification/regression
SVMEffective in high dimensionsSlow on large datasetsMedium-scale classification
Neural NetworkLearns complex patternsNeeds lots of data + computeImages, text, audio
XGBoostHigh accuracy, fastMany hyperparametersTabular data competitions

Key Concept Cards

Supervised / Unsupervised / Reinforcement Learning ★★★★★ : Supervised=has labels, Unsupervised=no labels, Reinforcement=reward signal. Know the clear distinctions.

Overfitting vs. Underfitting ★★★★★ : Overfitting=train↑ valid↓, Underfitting=both↑. Fix overfitting with regularization, dropout, or more data.

Bias-Variance Tradeoff ★★★★☆ : Simple model=high bias/low variance. Complex model=low bias/high variance. Finding the optimal balance is core ML.


Practice Quiz

Q1. What learning paradigm is appropriate for an email spam classifier?

Supervised learning. You train a classification model on emails already labeled as “spam” or “not spam.” There are clear labels and a defined output (spam probability), making supervised learning the right choice.

Q2. A model has 99% training accuracy but 72% test accuracy. What is the problem?

Overfitting. The model has memorized the training data rather than learning generalizable patterns. Solutions include stronger regularization, dropout, data augmentation, or using a simpler model architecture.

O

OIYO Editorial

Editorial Desk

The OIYO editorial desk researches money, law, lifestyle, and self-understanding topics against primary sources and public statistics. Every piece carries source notes and is reviewed on a regular cycle for accuracy and usefulness.