AI-101

Lesson 2

How Machine Learning Works

AI Confidence: 85%

AI-generated

The Core Idea

Machine learning is how AI systems learn from data instead of being explicitly programmed. Instead of a programmer writing rules like "if the email contains 'free money,' mark it as spam," a machine learning system looks at thousands of examples of spam and not-spam emails, finds the patterns itself, and uses those patterns to classify new emails.

This is a fundamental shift: instead of telling the computer what to do, you show it examples and let it figure out the rules.

How Training Works

Training a machine learning model has three steps:

1. Gather data: Collect examples with known answers. For a spam filter, this means thousands of emails labeled "spam" or "not spam."

2. Train the model: Feed the data through an algorithm that adjusts internal parameters to minimize prediction errors. The model starts with random parameters and gradually improves. Each pass through the data is called an epoch.

3. Evaluate: Test the model on data it has never seen before to check if it actually learned generalizable patterns rather than just memorizing the training data (called overfitting).

Types of Machine Learning

Supervised learning: The most common type. You provide labeled examples (input + correct answer) and the model learns the mapping. Email classification, image recognition, and language translation are all supervised learning.

Unsupervised learning: You provide data without labels and the model finds structure on its own. Clustering similar documents, detecting anomalies, and reducing data dimensions are unsupervised tasks.

Reinforcement learning: The model learns by taking actions in an environment and receiving rewards or penalties. This is how game-playing AIs (AlphaGo) and robotics systems learn. RLHF (used to train ChatGPT and Claude) is a form of reinforcement learning.

Deep Learning and Neural Networks

Deep learning is a subset of machine learning that uses neural networks with many layers (hence "deep"). Each layer transforms the data, extracting increasingly abstract features. Early layers might detect edges in an image; deeper layers recognize faces.

Large language models like GPT and Claude are deep learning models with billions of parameters, trained on massive text datasets. The "learning" in their name is literal: they learned language patterns from data rather than being programmed with grammar rules.

Why This Matters to You

You do not need to train your own models to use AI effectively. But understanding the basics helps you:

- Set realistic expectations: Models are only as good as their training data. If the data has biases, the model will too. - Debug AI failures: When an AI gives a wrong answer, understanding that it is pattern-matching (not reasoning from first principles) helps you understand why. - Choose the right approach: Sometimes a simple rule-based system is better than machine learning. Knowing the difference saves time and money.

Sources & Further Reading

Google Machine Learning Crash Course - https://developers.google.com/machine-learning/crash-course

Stanford CS229: Machine Learning (course materials) - https://cs229.stanford.edu/

3Blue1Brown "Neural Networks" video series - https://www.youtube.com/playlist?list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi

fast.ai Practical Deep Learning for Coders - https://course.fast.ai/

Wikipedia: Machine Learning - https://en.wikipedia.org/wiki/Machine_learning