← Writing & notes

FROM THE NOTEBOOK

Machine Learning - Stanford CS229

Stanford CS229: Machine Learning I Spring 2022 - YouTube

This course provides a comprehensive and mathematically-grounded introduction to the foundational principles, algorithms, and paradigms of modern machine learning. The curriculum is structured around the three core areas of the field: supervised, unsupervised, and reinforcement learning, building from classical models to the state-of-the-art.
In supervised learning, the course begins with the fundamentals of learning from labeled data. It starts with Linear Regression, deriving its least-squares cost function from the principle of Maximum Likelihood Estimation (MLE) under Gaussian assumptions. This probabilistic framework is then generalized to solve classification problems using Logistic Regression. These concepts are unified under the powerful abstraction of Generalized Linear Models (GLMs) and the Exponential Family of distributions, demonstrating how a vast array of models can be understood and optimized through a common lens. The course then tackles non-linearity through two key approaches: the classical elegance of Kernel Methods and the modern power of Neural Networks. The core training mechanism for deep learning, Backpropagation, is derived from first principles as an efficient application of the chain rule.
The practical realities of building effective models are addressed through a deep dive into generalization. The course covers the classical bias-variance trade-off to explain underfitting and overfitting, and introduces the modern phenomenon of double descent seen in overparameterized models. This motivates the use of regularization techniques, such as L1 (LASSO) and L2 (Weight Decay), to control model complexity. The full machine learning lifecycle is explored, emphasizing the critical importance of data splitting (train/validation/test), hyperparameter tuning, and data quality.
In unsupervised learning, the focus shifts to discovering hidden structure in unlabeled data. The course covers clustering with the classic k-means algorithm and the more sophisticated, probabilistic Gaussian Mixture Models (GMMs). The key algorithmic tool for these latent variable models, the Expectation-Maximization (EM) algorithm, is formally derived. The second major unsupervised task, dimensionality reduction, is explored through Principal Component Analysis (PCA), which finds directions of maximal variance, and Independent Component Analysis (ICA), which solves the "cocktail party problem" by assuming non-Gaussian, independent sources. These classical ideas build towards the modern paradigm of self-supervised learning, where models like Transformers are pre-trained on massive unlabeled datasets (e.g., by predicting the next word) to create powerful foundation models that can be adapted to numerous downstream tasks through fine-tuning or prompting.
Finally, the course provides a concise introduction to Reinforcement Learning (RL), the paradigm of learning to make sequential decisions. It establishes the formal language of Markov Decision Processes (MDPs)—including states, actions, rewards, and transitions. The concepts of the policy, the value function, and the recursive Bellman Equation are developed, culminating in the Value Iteration algorithm, a foundational dynamic programming method for finding the optimal policy when the environment's model is known.

L1: Introduction

The course is introduced by instructors Tony Ma, a researcher in machine learning theory (including RL and supervised learning), and Chris, who works on building large-scale, robust ML systems and has contributed to products like Google Search and Assistant. They frame the course as providing the absolute foundational layer of machine learning, which is more relevant than ever as ML products have become part of daily life. The course aims to give students insight into how these systems work and why significant research challenges remain.
2. Course Logistics and Administration
A significant portion of the lecture is dedicated to outlining the structure and expectations for the course.

3. What is Machine Learning?
The lecture introduces the core concept of machine learning through two historical definitions.

  1. Arthur Samuel (1959): The field of study that gives computers the ability to learn without being explicitly programmed. This distinguishes ML from traditional programming where every rule is hard-coded.
  2. Tom Mitchell (1997): A more formal definition: "A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E."
    • Experience (E): Typically refers to data (e.g., a dataset of past games).
    • Task (T): The problem to be solved (e.g., playing checkers).
    • Performance Measure (P): A metric to evaluate success (e.g., the win rate).
    • Learning: The key is that performance improves as the program is exposed to more experience (data).

4. A Taxonomy of Machine Learning
The course is structured around three primary paradigms of machine learning, which are presented as distinct but often overlapping fields.

5. Other Course Topics
The lecture concludes by mentioning other key areas that will be covered, which cut across the three main paradigms:

L2: Supervised Learning Set Up

This lecture, led by instructor Chris, marks the beginning of a three-lecture block focused on building the fundamental models of supervised learning. The plan is to start with the simplest case, linear regression, and then progressively generalize to classification and a broad class of models known as the exponential family. A key theme is that these seemingly different models can all be solved using the same underlying optimization algorithm: stochastic gradient descent.

2. Supervised Learning: Formal Setup and Notation

The lecture formally defined the supervised learning problem, establishing notation that will be used throughout the course.

3. Linear Regression: The Model

The lecture focused on the simplest predictive model: the linear model.

4. Finding the Best Model: The Cost Function

To find the "best" parameters θ, we need a way to measure how well a given model fits the data. This is done using a cost function (or loss function).

5. Solving the Optimization Problem: Gradient Descent

The lecture introduced gradient descent as a general-purpose algorithm for minimizing cost functions. This is the workhorse algorithm that will be reused for many other models.

6. Practical Optimization: Batch vs. Stochastic Gradient Descent

A major practical issue with the "batch" gradient descent described above is that it requires summing over the entire training dataset to compute a single gradient step. This is computationally infeasible for large datasets.

7. The Normal Equations (Briefly Mentioned)

The lecture concluded by briefly mentioning the normal equations, which provide a closed-form, analytical solution for the least squares problem: θ = (XᵀX)⁻¹Xᵀy. While useful for understanding the linear algebra of the problem and for small datasets, this method is not used in practice for large-scale ML because computing the matrix inverse is prohibitively expensive (O(d³)). The iterative gradient descent methods are far more scalable.

L3: Weighted Least Squares, Logistic Regression, NM

The lecture, led by instructor Chris, continues the structured development of supervised learning models. The primary goal is to generalize the concepts from linear regression to solve classification problems. The core pedagogical strategy is to demonstrate how a probabilistic interpretation of linear regression provides a powerful framework that can be extended to classification and, in the next lecture, to a much broader set of models known as the exponential family. This approach reveals the deep, parallel structure underlying many machine learning algorithms and their optimization methods.
2. A Probabilistic Interpretation of Linear Regression
The lecture began by revisiting the linear regression model from the previous session and providing a deeper justification for its cost function (the sum of squared errors).

3. Classification and Logistic Regression
The lecture then pivoted from regression (continuous outputs) to classification (discrete outputs).

4. Optimization: Newton's Method
The lecture introduced Newton's method as a powerful, alternative optimization algorithm to gradient descent.

L4: Exponential Family, Generalized Linear Methods

This lecture, led by instructor Chris, concludes the foundational block on supervised learning by introducing a powerful abstraction: the Exponential Family of distributions. This framework is crucial because it unifies many of the models seen so far (like linear and logistic regression) under a single theoretical umbrella. Understanding this family provides a "recipe" for constructing, analyzing, and optimizing a wide range of machine learning models, a pattern that will reappear in unsupervised learning.
2. Revisiting Linear Regression with a Probabilistic View
The lecture began by formalizing the probabilistic interpretation of linear regression to set the stage for generalization.

3. The Exponential Family of Distributions
This is the central concept of the lecture. It is a class of probability distributions whose probability density/mass function can be written in a specific canonical form.

4. Generalized Linear Models (GLMs)
GLMs provide the recipe for building a supervised learning model using the exponential family. It consists of three design choices/assumptions:

  1. Output Distribution: Assume that the conditional distribution p(y | x; θ) is a member of the exponential family (e.g., Gaussian for regression, Bernoulli for binary classification).
  2. Linearity Assumption: Assume that the natural parameter η is a linear function of the input features x: η = θᵀx.
  3. Prediction: The model's prediction h_θ(x) is defined as the expected value of the target variable E[y | x; θ].

5. Multiclass Classification and Softmax Regression
The final part of the lecture extended these ideas from binary to multiclass classification, where the output y can take on one of k discrete values.

6. Summary and Look Ahead
The lecture concluded a three-part series on the foundations of supervised learning. The key takeaway is the power of abstraction. By understanding the probabilistic framework of GLMs and the exponential family, students can see that many seemingly different algorithms (linear regression, logistic regression, softmax regression, Poisson regression, etc.) are all instances of the same underlying principles and can be solved with the same core optimization techniques. The course will next move on to more advanced supervised learning topics like Support Vector Machines and Kernel Methods.

L5: Gaussian Discriminant Analysis, Naive Bayes

The lecture, led by instructor Tony, introduces a fundamental distinction between two major classes of learning algorithms.

2. Gaussian Discriminant Analysis (GDA)
GDA is the first generative learning algorithm presented, designed for classification tasks where the input features x are continuous.

3. Learning the Parameters via Maximum Likelihood Estimation (MLE)
The core principle for fitting a generative model is Maximum Likelihood Estimation. The goal is to find the set of parameters that makes the observed training data most probable.

These results are highly intuitive: the parameters that best explain the data are simply the empirical statistics calculated from that data.
4. Making Predictions with the GDA Model
Once the parameters are learned from the training data, the model can be used to make predictions on a new, unseen input x.

5. GDA vs. Logistic Regression: A Deeper Look
The fact that these two very different modeling approaches lead to similar functional forms for the posterior probability p(y|x) raises a crucial question: when should one be preferred over the other?

L6: Naive Bayes, LaPlace Smoothing

The lecture, led by instructor Tony, began with a concise review of GDA, the generative learning algorithm for continuous features introduced in the previous session.

2. GDA vs. Logistic Regression: A Deeper Comparison
A key discussion centered on the trade-offs between generative (GDA) and discriminative (Logistic Regression) models, both of which can produce linear classifiers.

3. Naive Bayes for Text Classification (Spam Filtering)
The lecture then introduced a new generative algorithm, Naive Bayes, specifically for the task of spam classification, where the input features x are discrete.

4. A Practical Problem: The Zero-Probability Issue
A critical issue arises with the MLE estimates for Naive Bayes.

5. The Solution: Laplace Smoothing
To fix the zero-probability problem, a simple and effective technique called Laplace smoothing is introduced.

L7: Kernels

The lecture, led by instructor Tony, addresses a fundamental limitation of the linear models discussed so far: they cannot capture non-linear relationships in data.

2. The Computational Challenge of High-Dimensional Features
While the feature map approach is powerful, it quickly becomes computationally infeasible as the dimensionality of the original input d and the complexity of the feature map (e.g., the degree of the polynomial) increase.

3. The Kernel Trick: A Computational Shortcut
The central topic of the lecture is the kernel trick, a profound idea that allows us to reap the benefits of high-dimensional (even infinite-dimensional) feature spaces without ever explicitly computing or storing the feature vectors.

4. The Kernelized Algorithm and the Change of Mindset
This insight leads to a new, kernelized version of the learning algorithm.

5. Valid Kernels and Mercer's Theorem
A crucial question is how to know if a function K(x, z) is a valid kernel.

6. Summary and Modern Context

L8: Neural Networks 1

The lecture, given by instructor Masha, serves as an introduction to deep learning and neural networks. The goal is to build upon the foundational concepts of linear and logistic regression to construct more expressive, non-linear models. The key insight is that even state-of-the-art models like GPT-3 and DALL-E 2 are built from the same fundamental principles. This lecture focuses on defining the structure and forward pass of a neural network, while the next lecture will cover how to train them using backpropagation.
2. From Linear Models to Non-Linearity
The lecture begins by revisiting the limitations of the models discussed so far and motivating the need for non-linearity.

3. The Simplest Neural Network: A Single Neuron
The lecture builds the concept of a neural network from its most basic component: a single "neuron."

4. Building a Two-Layer Neural Network
The power of neural networks comes from stacking these neurons into layers, where the output of one layer becomes the input to the next.

5. Vectorization and Formal Notation for an R-Layer Network
To handle complex networks efficiently, the operations are expressed using matrix and vector notation (vectorization). This is not just for notational convenience; it's crucial for efficient implementation on parallel hardware like GPUs.

6. The Importance of Non-Linearity and Connection to Kernels

L9: Neural Networks 2, Backprop

1. Introduction: The Need for Backpropagation
The lecture, led by instructor Tony, focuses on backpropagation, arguably the most critical algorithmic component of deep learning. While modern deep learning frameworks like PyTorch and TensorFlow handle gradient computation automatically ("auto-differentiation"), understanding backpropagation is essential for grasping how neural networks are trained. The lecture aims to present a vectorized, modular view of the process, which is cleaner and more aligned with modern implementations than a fine-grained, index-heavy derivation.
2. The Core Problem: Computing the Gradient

3. The Power of Automatic Differentiation: A High-Level Theorem
Before diving into the mechanics, a powerful and somewhat surprising theorem is presented to frame the discussion.

4. The Chain Rule: A Foundational Tool
The entire backpropagation algorithm is an application of the multivariate chain rule from calculus. The lecture reviews the basic form: to find the derivative of a final output J with respect to an input parameter θ_i, you sum over all intermediate variables z_k the product of (∂J/∂z_k) and (∂z_k/∂θ_i).

5. Backpropagation Through a Two-Layer Network: A Modular Approach
Instead of a brute-force, element-by-element derivation, the lecture presents a more elegant, modular, and vectorized approach. The neural network is viewed as a composition of simple computational blocks (e.g., matrix multiplication, element-wise activation), and "lemmas" are derived for how to backpropagate gradients through each block.

6. Generalizing to Deep Networks and Computational Graphs
This modular, backward-flowing process is why the algorithm is called backpropagation.

The lecture successfully demystified backpropagation by presenting it not as a monolithic, complex formula, but as a systematic application of the chain rule through a series of simple, reusable computational blocks.

L10: Bias - Variance, Regularization

1. Review of Backpropagation
The lecture, led by instructor Tony, began with a five-minute visual recap of backpropagation.

This modular, backward-flowing nature is the essence of backpropagation and is what enables the efficient training of deep neural networks.
2. Generalization, Training Loss, and Test Loss
The main topic of the lecture shifted from training a model to evaluating its performance, introducing the crucial concept of generalization.

3. Overfitting and Underfitting
When a model's test loss is high, it typically falls into one of two failure modes:

4. The Bias-Variance Trade-off: A Classical View
The concepts of overfitting and underfitting are explained by the classical bias-variance trade-off. The test error of a model can be decomposed into two main components:

5. Double Descent: A Modern Phenomenon
The lecture then introduced a modern and surprising finding that challenges the classical U-shaped view of the bias-variance trade-off: double descent.

6. Explaining Double Descent
The lecture provided several intuitions for this surprising phenomenon, primarily from the study of linear models.

  1. The Peak is an Algorithmic Failure: The peak in test error when n ≈ d is not a fundamental property of the problem but rather a failure of the standard learning algorithms (like unregularized gradient descent). In this "critically parameterized" region, the solution found by the algorithm has an extremely large norm (the θ vector has very large values), making it highly sensitive to noise and thus poorly generalizable.
  2. The Norm as a Better Complexity Measure: This suggests that the raw number of parameters is not the best measure of a model's complexity. The norm of the parameter vector might be a better measure. The models at the peak of the curve are, in a sense, the most complex because their norms explode.
  3. Implicit Regularization: In the heavily overparameterized regime (d >> n), there are infinitely many solutions that can achieve zero training error. The optimization algorithm (like SGD) doesn't just pick any solution; it has an implicit bias towards solutions with a small norm. By finding the minimum-norm solution that perfectly fits the data, the algorithm implicitly regularizes itself, leading to better generalization and the "second descent."
  4. Explicit Regularization: Adding explicit regularization (a penalty on the norm of θ to the loss function) can smooth out the peak, further supporting the idea that the peak is caused by finding high-norm, poorly-generalized solutions.

This concludes the lecture, setting the stage for the next session, which will delve deeper into regularization and practical aspects of training and evaluating machine learning models.

L11: Model Selection, ML Advice

The lecture, led by instructor Tony, began by reviewing the modern phenomenon of double descent.

2. Regularization: Controlling Model Complexity
The first major topic was regularization, a set of techniques for explicitly controlling model complexity to prevent overfitting and improve generalization.

3. Practical Machine Learning: A Lifecycle Approach
The lecture then shifted to a more practical, applied perspective on building a real-world ML system, using a spam detector as a running example. This section was based on slides from instructor Chris Re.

L12: K-Means, GMM (Non EM), EM

1. Introduction to Unsupervised Learning
The lecture, led by instructor Chris, transitions from supervised learning to the paradigm of unsupervised learning. This marks the beginning of a four-lecture block exploring what can be learned from data without explicit labels.

2. K-Means Clustering
The lecture begins with the most classic and intuitive clustering algorithm: k-means.

3. Gaussian Mixture Models (GMMs)
The lecture then introduces a more sophisticated and probabilistic approach to clustering: Gaussian Mixture Models.

4. The Expectation-Maximization (EM) Algorithm
Since we don't know the latent variables z, we cannot directly use maximum likelihood estimation. The problem is solved using the Expectation-Maximization (EM) algorithm, a powerful iterative method for finding MLE solutions in the presence of latent variables. The algorithm for GMMs mirrors the structure of k-means.

5. Convexity and Jensen's Inequality
The lecture concluded by introducing a key mathematical tool that will be used in the next session to formally derive and prove the convergence of the EM algorithm: Jensen's Inequality.

L13: GMM (EM)

1. Introduction and Lecture Plan
The lecture, led by instructor Chris, aims to provide a more principled, mathematical foundation for the unsupervised learning algorithms introduced in the previous session, particularly Gaussian Mixture Models (GMMs). The central goal is to formally derive the Expectation-Maximization (EM) algorithm as a method for performing Maximum Likelihood Estimation (MLE) in models with latent variables.

2. Technical Detour: Convexity and Jensen's Inequality
Before deriving the EM algorithm, a crucial mathematical tool was introduced: Jensen's Inequality.

3. The EM Algorithm as Maximum Likelihood Estimation
With Jensen's inequality in hand, the lecture proceeded to derive the EM algorithm from first principles.

4. EM for Gaussian Mixture Models (GMMs)
The lecture concluded by applying this general EM framework to the specific case of GMMs, showing that the intuitive algorithm from the previous lecture is a direct consequence of this principled derivation.

The lecture successfully demystified the EM algorithm, framing it not as an ad-hoc heuristic but as a principled method for maximizing likelihood in the presence of unobserved data, and showed how it provides the foundation for GMMs and, as will be seen next time, other latent variable models like Factor Analysis.

L14: Factor Analysis and PCA

1. Introduction and Lecture Plan
The lecture, led by instructor Chris, continues the exploration of unsupervised learning by focusing on Factor Analysis and then introducing a classic and fundamental dimensionality reduction technique: Principal Component Analysis (PCA). The core theme is developing methods to find low-dimensional latent structures in high-dimensional data, especially in the challenging setting where the number of dimensions d is much larger than the number of data points n.
2. The Challenge: High Dimensions, Few Data Points (d >> n)
The lecture begins by motivating the need for models like Factor Analysis.

3. Building Blocks for Factor Analysis
To address the rank-deficiency problem, two simplified covariance structures are introduced as building blocks. These models reduce the number of parameters needed to describe the covariance, ensuring it remains full-rank even with limited data.

  1. Isotropic Covariance:
    • Model: Σ = σ²I (a scalar σ² times the identity matrix).
    • Geometry: Assumes the noise is spherical. The variance is the same in all directions, and the features are uncorrelated.
    • Parameters: Only one parameter (σ²) to estimate for the entire covariance structure.
  2. Diagonal Covariance:
    • Model: Σ is a diagonal matrix.
    • Geometry: Assumes the noise is an axis-aligned ellipse. The features are uncorrelated, but the variance can be different along each axis.
    • Parameters: d parameters to estimate (one for each diagonal entry).

4. The Factor Analysis Model
Factor Analysis combines these ideas with a latent variable model to find a low-dimensional structure in high-dimensional data.

5. Principal Component Analysis (PCA)
The lecture then introduced PCA, a non-probabilistic but closely related method for dimensionality reduction.

PCA is a fundamental and widely used technique for data compression, visualization, and as a preprocessing step for other machine learning algorithms. It provides a deterministic, non-probabilistic counterpart to the probabilistic model of Factor Analysis.

L15: PCA/ICA

1. Introduction and Lecture Plan
The lecture, led by instructor Chris, continues the exploration of unsupervised learning by concluding the topic of Principal Component Analysis (PCA) and introducing a new, powerful technique: Independent Component Analysis (ICA). A key theme is investigating different structural assumptions that can be made about data to enable learning without labels. The lecture also briefly introduces the modern paradigm of Weak Supervision.
2. Finishing Principal Component Analysis (PCA)
The lecture began by formalizing the optimization problem at the heart of PCA.

3. Independent Component Analysis (ICA)
ICA is introduced through the famous cocktail party problem.

The remarkable result is that this procedure works. By simply maximizing the likelihood under a non-Gaussian prior, the algorithm can successfully separate the mixed signals, a task you will implement in the homework.
4. Introduction to Weak Supervision (Data-Centric AI)
The lecture concluded with a brief, high-level introduction to a modern paradigm for dealing with the bottleneck of creating large, labeled training datasets.

L16: Self-supervised Learning

1. Review of Backpropagation (Continued)
The lecture, led by instructor Tony, began by visually summarizing the backpropagation algorithm.

2. Generalization and Model Complexity
The main focus of the lecture shifted to generalization—the ability of a model to perform well on new, unseen data—and its relationship to model complexity.

3. Regularization: Explicitly Controlling Complexity
Regularization refers to a set of techniques used to combat overfitting by explicitly encouraging models to have lower complexity. This is done by adding a penalty term R(θ) to the training loss.

4. The Modern ML Pipeline: Pre-training and Adaptation
The lecture then transitioned to the dominant paradigm in modern machine learning, especially in NLP and vision: the two-stage process of pre-training and adaptation.

Since pre-training is often done on unlabeled data, a "pretext" task must be created to provide a learning signal. This is known as self-supervised learning.

Once a model is pre-trained, it can be adapted to a new task.

L17: Basic concepts in RL, Value Iteration, Policy Iteration

1. Introduction to Reinforcement Learning (RL)
The lecture, led by instructor Tony, introduces the final major topic of the course: Reinforcement Learning (RL).

2. The Markov Decision Process (MDP) Framework
The problem of sequential decision-making is formalized using the Markov Decision Process (MDP) framework. An MDP is defined by five components:

  1. States (S): A set of states describing the environment's configuration (e.g., the robot's position on the grid).
  2. Actions (A): A set of possible actions the agent can take in each state (e.g., move left, move right).
  3. Transition Probabilities (P): The dynamics of the environment. P(s' | s, a) specifies the probability of transitioning to state s' after taking action a in state s. The environment can be stochastic.
  4. Reward Function (R): A function R(s) that specifies the immediate reward received for being in state s.
  5. Discount Factor (γ): A value between 0 and 1 that discounts future rewards. The total payoff (or return) is the discounted sum of all future rewards: R(s₀) + γR(s₁) + γ²R(s₂) + .... The discount factor ensures this sum is finite in infinite-horizon problems and models the preference for immediate rewards over delayed ones.

3. Policies and Value Functions

4. The Bellman Equation
The Bellman equation is a fundamental equation in RL that provides a recursive definition for the value function. It decomposes the value of a state into the immediate reward plus the discounted value of the expected next state.

5. Finding the Optimal Policy
The ultimate goal is to find the optimal policy , which is the policy that maximizes the value function for all states.

6. Value Iteration
Value iteration is a classic dynamic programming algorithm for solving the Bellman optimality equation and finding V*.

This lecture lays the complete groundwork for "planning" in RL, where the agent knows the model of the world (P and R) and uses dynamic programming to compute the optimal way to behave.

L18: Societal Impact of ML

1. Introduction: AI in Healthcare
The lecture, delivered by guest speaker and Stanford professor James Zou, focuses on the practical applications, challenges, and responsibilities of deploying machine learning systems in real-world healthcare settings. The talk is framed through several case studies from Professor Zou's own research.
2. Case Study 1: EchoNet - Assessing Heart Conditions

3. Case Study 2: TrueImage - Improving Telehealth

4. The Detective Story: Why Do Dermatology AI Models Fail?
This section presents a critical investigation into why state-of-the-art dermatology AI models, which reported very high performance (e.g., AUC > 0.9) in their original papers, performed poorly (AUC ~ 0.6) when tested on real patients at Stanford. This "detective story" highlights key challenges in deploying ML in the real world.

5. Lessons for Building Trustworthy AI
Based on these experiences, the lecture outlines four key lessons for improving the reliability and responsibility of AI systems, especially in high-stakes domains like healthcare.

  1. Increase Data Transparency:
    • There is a critical need for transparency about the datasets used to train and evaluate models. Many medical AI models are tested on small, private datasets, making it impossible for external researchers to audit or replicate the results.
    • The speaker's group practices this by releasing large, publicly available medical datasets, such as the EchoNet dataset of over 10,000 cardiac videos.
  2. Quantify Data Contributions (Data Shapley):
    • It's important to understand how individual training points contribute to a model's final performance or biases.
    • Data Shapley is a technique adapted from game theory that assigns a value to each training data point, quantifying its contribution to the model's performance on a test set.
    • This allows for identifying and up-weighting high-quality, informative data points or down-weighting noisy or harmful ones during retraining, leading to improved model robustness.
  3. Understand and Explain Mistakes:
    • Analyzing why a model makes specific mistakes provides crucial insights into its blind spots.
    • The lecture presented a tool for conceptual explanation of mistakes. Instead of just saying a prediction was wrong, it provides a high-level, human-understandable reason (e.g., "The model predicted 'crocodile' instead of 'zebra' because there was too much water in the image.").
    • Applying this to the dermatology case revealed actionable insights: the model made mistakes due to dark skin tone, image blur, improper zoom, and the presence of hair.
  4. Embrace Human-in-the-Loop Evaluation:
    • Standard ML development optimizes for performance on a static benchmark, which may not reflect real-world utility.
    • The ultimate goal is to optimize for the performance of the human-AI team.
    • Tools like Gradio were developed to make it easy to create simple UI wrappers around any ML model, allowing non-experts (like clinicians) to interact with, test, and provide real-time feedback throughout the development cycle. This facilitates a more collaborative and user-centered approach to building AI systems.

L19: Model-Based RL, Value Function Approximator

1. Introduction to Reinforcement Learning (RL)
The lecture, led by instructor Tony, introduces the final major topic of the course: Reinforcement Learning (RL).

2. The Markov Decision Process (MDP) Framework
The problem of sequential decision-making is formalized using the Markov Decision Process (MDP) framework. An MDP is defined by five components:

  1. States (S): A set of states describing the environment's configuration (e.g., the robot's position on the grid).
  2. Actions (A): A set of possible actions the agent can take in each state (e.g., move left, move right).
  3. Transition Probabilities (P): The dynamics of the environment. P(s' | s, a) specifies the probability of transitioning to state s' after taking action a in state s. The environment can be stochastic.
  4. Reward Function (R): A function R(s) that specifies the immediate reward received for being in state s.
  5. Discount Factor (γ): A value between 0 and 1 that discounts future rewards. The total payoff (or return) is the discounted sum of all future rewards: R(s₀) + γR(s₁) + γ²R(s₂) + .... The discount factor ensures this sum is finite in infinite-horizon problems and models the preference for immediate rewards over delayed ones.

3. Policies and Value Functions

4. The Bellman Equation
The Bellman equation is a fundamental equation in RL that provides a recursive definition for the value function. It decomposes the value of a state into the immediate reward plus the discounted value of the expected next state.

5. Finding the Optimal Policy
The ultimate goal is to find the optimal policy , which is the policy that maximizes the value function for all states.

6. Value Iteration
Value iteration is a classic dynamic programming algorithm for solving the Bellman optimality equation and finding V*.

This lecture lays the complete groundwork for "planning" in RL, where the agent knows the model of the world (P and R) and uses dynamic programming to compute the optimal way to behave.

All writing