Classic Algorithms of Machine Learning

Machine Learning Algorithms: A Historical Introduction

Apunte, 3 min de lectura.algorithms/00_introduction.md

En esta página
  1. The Evolution of Machine Learning
  2. Timeline of Key Algorithms
  3. 1. Linear Regression (Early 1800s)
  4. 2. Logistic Regression (1940s)
  5. 3. K-Means Clustering (1957)
  6. 4. K-Nearest Neighbors (KNN) (1951-1967)
  7. 5. Decision Trees (1960s-1980s)
  8. 6. Q-Learning (1989)
  9. 7. Random Forests (2001)
  10. The Three Paradigms of Machine Learning
  11. Supervised Learning
  12. Unsupervised Learning
  13. Reinforcement Learning
  14. The Modern Era
  15. Choosing the Right Algorithm

The Evolution of Machine Learning

Machine learning, as a field, has evolved over several decades, with different algorithms emerging to solve specific types of problems. Understanding the historical context helps us appreciate why certain algorithms were developed and when to use each one.

Machine learning encompasses three fundamental paradigms:

  • Supervised Learning: Learning from labeled examples (input-output pairs)
  • Unsupervised Learning: Discovering patterns in unlabeled data
  • Reinforcement Learning: Learning through interaction and feedback

Timeline of Key Algorithms

1. Linear Regression (Early 1800s)

Purpose: Predict continuous numerical values based on input features.

Why it matters: Linear regression established the foundation for supervised learning and remains widely used due to its simplicity, interpretability, and effectiveness for many real-world problems.

2. Logistic Regression (1940s)

Purpose: Classification problems, particularly binary classification (yes/no, true/false).

Why it matters: Despite its name containing "regression," it's primarily a classification algorithm. It extended linear regression concepts to categorical outcomes and introduced the sigmoid function, which became fundamental in neural networks.

3. K-Means Clustering (1957)

Purpose: Unsupervised learning for grouping similar data points into clusters.

Why it matters: K-means was one of the first successful unsupervised learning algorithms, proving that machines could find patterns in data without explicit labels. It remains widely used for customer segmentation, image compression, and data exploration.

4. K-Nearest Neighbors (KNN) (1951-1967)

Purpose: Both classification and regression through similarity-based learning.

Why it matters: KNN introduced the concept of instance-based learning (lazy learning), where no explicit model is built during training. It's intuitive and effective for many problems but can be computationally expensive.

5. Decision Trees (1960s-1980s)

History: The concept emerged in the 1960s, but modern algorithms were developed later:

  • CART (Classification and Regression Trees) (1984)
  • ID3 (1986)
  • C4.5 (1993) - an improvement of ID3

Purpose: Both classification and regression through hierarchical decision-making.

Why it matters: Decision trees are highly interpretable and can capture non-linear relationships. They became the foundation for powerful ensemble methods like Random Forests and Gradient Boosting.

6. Q-Learning (1989)

Purpose: Reinforcement learning for sequential decision-making through trial and error.

Why it matters: Q-Learning introduced a fundamentally different learning paradigm. Unlike supervised learning (which learns from labeled examples) or unsupervised learning (which finds patterns), reinforcement learning learns by interacting with an environment and receiving rewards or penalties. This approach has proven crucial for robotics, game playing, and autonomous systems.

Key concept: The algorithm builds a "Q-table" that stores the expected future reward for each action in each state, gradually learning optimal behavior through experience.

7. Random Forests (2001)

Purpose: Ensemble method for classification and regression that improves upon single decision trees.

Why it matters: Random Forests demonstrated the power of ensemble learning - combining multiple weak learners to create a strong learner. They address the overfitting problem of individual decision trees.

The Three Paradigms of Machine Learning

Supervised Learning

Algorithms learn from labeled data (input-output pairs):

  • Regression: Linear Regression
  • Classification: Logistic Regression, Decision Trees, KNN, Random Forests

When to use: When you have historical data with known outcomes and want to predict future outcomes.

Unsupervised Learning

Algorithms find patterns in unlabeled data:

  • Clustering: K-Means
  • Dimensionality Reduction: PCA (Principal Component Analysis)

When to use: When you want to discover hidden patterns, group similar items, or reduce data complexity without predefined labels.

Reinforcement Learning

Algorithms learn through trial and error by interacting with an environment:

  • Value-Based Methods: Q-Learning
  • Policy-Based Methods: Policy Gradients
  • Deep RL: Deep Q-Networks (DQN), AlphaGo

When to use: When you need to make sequential decisions, don't have labeled training data, but can define rewards for desired outcomes (games, robotics, autonomous vehicles).

The Modern Era

Today's machine learning landscape has evolved to include:

  • Deep Learning (2010s): Neural networks with many layers (CNNs, RNNs, LSTMs)
  • Advanced Ensemble Methods: XGBoost (2014), LightGBM, CatBoost
  • Transfer Learning: Reusing pre-trained models to solve new problems
  • Large Language Models (2020s): Transformers and attention mechanisms (GPT, BERT, Claude)
  • Deep Reinforcement Learning: AlphaGo (2016), AlphaZero (2017), ChatGPT with RLHF

However, the classical algorithms we study remain fundamental because:

  • They're often the best choice for small to medium-sized datasets
  • They're interpretable and explainable (crucial for regulated industries)
  • They serve as building blocks for more complex methods
  • They're computationally efficient and require less data
  • They're essential for understanding modern ML concepts
  • Many state-of-the-art solutions still use these algorithms (e.g., XGBoost is based on decision trees)

Choosing the Right Algorithm

The choice of algorithm depends on several factors:

FactorConsider
Problem TypeClassification, regression, clustering, or sequential decision-making?
Data AvailabilityDo you have labeled data? Unlabeled? Or can you define rewards?
Data SizeSmall datasets favor simpler models; large datasets can leverage complex models
InterpretabilityDo you need to explain predictions? (Use linear models, decision trees)
SpeedTraining time vs. prediction time trade-offs
Accuracy RequirementsSimple models may suffice; complex problems may need ensembles
Data PropertiesLinear vs. non-linear relationships, presence of outliers, feature interactions
Sequential DecisionsIf actions affect future states, consider reinforcement learning

Scikit-learn: choosing the right estimator

Escribe al menos dos letras. Busca también dentro del código de los notebooks.