09/30/26: Lect-06
Overview
Joseph Zambreno connects data quality lessons to multi-layer perceptrons (MLPs): models can fail through leakage or distribution shift, while domain-informed feature engineering and label-preserving augmentation can improve learning. He motivates MLPs with limits of linear decision boundaries, including XOR, then explains how hidden layers, nonlinear activation functions, and backpropagation enable models to learn more complex relationships.
Key takeaways
- The pneumonia-and-asthma example illustrates leakage from downstream preventive care: a feature can encode decisions made after the point when a risk prediction must be produced.
- Google Flu Trends failed in late 2012 when search-based estimates exceeded CDC estimates by more than 2×, demonstrating concept shift when the input-output relationship changes.
- Feature engineering can make a linear model express selected nonlinear patterns: distance from 98.6°F represents temperature extremes, and x1 × x2 enables linear classification of XOR.
- An MLP learns intermediate representations with hidden layers, but those layers only add expressive power when nonlinear activations prevent stacked affine transformations from collapsing into one.
- Activation functions trade off computation, output range, and gradient behavior: sigmoid saturates, ReLU is efficient but can produce inactive units, and ELU preserves a nonzero negative-side gradient.
Chapters
- In the pneumonia-risk example, patients with both pneumonia and asthma appeared to have lower risk, contradicting medical expectations.
- Preventive care associated with asthma can leak downstream information into the data, even though that care would not be available when making the intended prediction.
- Unexpected predictions should prompt checks of data collection and clinical assumptions before a model is trusted.
- Google Flu Trends estimated flu prevalence from real-time searches and matched them to lagging CDC reports, but its estimates exceeded CDC estimates by more than 2× in late 2012.
- Changes in search habits or Google autocomplete could alter the relationship between search data and flu prevalence without invalidating the original data.
- Covariate shift changes the input distribution, label shift changes class prevalence, and concept shift changes the relationship between inputs and outputs.
- Monitoring production data and redeploying models can help address shifts that cannot be fixed through model design alone.
- Raw timestamps can be converted into features such as whether a measurement occurred on a weekend, as practiced in Lab 2.
- For sensor fault detection, rate of change may be more informative than a raw reading.
- Engineered features can let a simpler model match or outperform a more complex one, and can make sampling problems easier to audit.
- Deep convolutional neural networks can learn image features such as histograms of oriented gradients, but learned features do not eliminate the value of domain expertise.
- Augmentation expands limited training data with plausible transformations that preserve labels, such as rotating, cropping, brightening, or darkening a cat image.
- AlexNet-era image training benefited from augmentation because large models needed more training examples than available datasets alone could provide.
- An upside-down cat remains a cat, but vertically flipping a stop sign or license plate may distort the letters and compromise the label.
- Synthetic transformations supplement rather than exactly replace real deployment examples, such as actual low-light images.
- A complex model trained on one cat image may memorize that specific image and fail on a rotated or flipped version.
- When data is small relative to model complexity, overfitting becomes more likely; when data complexity overwhelms the model, underfitting becomes more likely.
- Whether a transformation is useful depends on the deployment setting and whether it genuinely preserves the target label.
- Training time limits how much augmentation experimentation is practical in a course lab.
- Treat datasets as claims to investigate rather than facts to accept, and ask where the data came from and what assumptions shaped it.
- Check for leakage, sampling bias, distribution shift, and whether all features would be available at prediction time.
- Evaluate whether accuracy metrics and class balance support the conclusions being drawn.
- Investigating data assumptions before deployment is easier than correcting a model after flawed assumptions have propagated.
- A perceptron computes an affine transformation, such as a weighted input plus a bias; logistic and softmax regression add output activations for classification.
- A linear model separates classes with a line, plane, or higher-dimensional hyperplane.
- A single linear weight cannot represent a temperature risk pattern where both unusually high and unusually low temperatures are dangerous.
- The monotonic effect of each feature in a linear model limits the patterns it can represent directly.
- A domain-informed temperature feature, such as distance from 98.6°F, can encode risk from both hot and cold extremes for a linear model.
- A perceptron can implement many Boolean gates but cannot classify XOR from its two original binary inputs with one linear boundary.
- For XOR, labels at (1, 0) and (0, 1) differ from those at (0, 0) and (1, 1), so no single line separates the classes.
- Feature engineering can resolve particular nonlinear patterns when domain knowledge reveals a useful transformation.
- TensorFlow Playground visualizes how a linear classifier performs on linearly separable data and fails on more complex patterns.
- Adding the engineered feature x1 × x2 allows a still-linear model to classify XOR by giving it a useful nonlinear representation.
- In the XOR example, the learned weight on x1 × x2 does most of the classification work.
- When the relevant feature relationship is unknown, adding hidden layers offers a way for the model to learn representations instead of relying on manual feature design.
- An MLP stacks fully connected layers, with earlier layers learning useful feature representations and the final layer producing regression or classification outputs.
- The example architecture has four input features, five hidden units, and three output classes.
- The number of hidden layers and the width of each layer are hyperparameters to explore; hidden-layer width need not match input or output size.
- A model with one hidden layer is also called a two-layer MLP when counting the output layer but not the input layer.
- Without an activation between layers, a hidden value H = XW1 + B1 followed by O = HW2 + B2 simplifies to another affine transformation of X.
- Matrix multiplication combines W1 and W2 into one effective weight matrix, and the biases combine into one effective bias.
- Adding more linear layers alone therefore does not expand the relationships a model can represent.
- Nonlinear activation functions prevent this collapse and make deeper networks useful for learning nonlinear patterns.
- Useful activations should add nonlinearity, support gradient computation, run efficiently, and ideally provide bounded outputs and useful gradients.
- Sigmoid is smooth and maps inputs to a bounded range from 0 to 1, making it useful for binary-classification probabilities.
- Computing sigmoid requires an exponential and division, so it is less lightweight than a simple threshold operation.
- Sigmoid gradients approach zero for large positive or negative inputs, which can make gradient information vanish during backpropagation.
- ReLU, max(0, x), is computationally simple and nonlinear, but it is unbounded above and units can become inactive on negative inputs.
- ReLU is technically nondifferentiable at zero, but implementations use a practical piecewise gradient there.
- Tanh has a bounded output range from -1 to 1, while its gradients can diminish for saturated inputs.
- ELU retains nonzero gradients on its negative side and has a roughly linear positive side; SELU and Mish are among other available activation choices.
- Bounded activations can have vanishing gradients in saturated regions, while unbounded or piecewise-linear activations make different tradeoffs.
Transcript excerpt
0:00 In the interest of time, uh, we can go ahead and get started. Um, we're kind of in that transition sort of finishing up this lecture five datacentric machine learning topic and then moving on to our multi-layer perceptron topic. It's kind of a nice uh synchronized point in the semester. as we've seen, it's not always that way in which what we'll be talking about as we get into that lecture six material today uh very closely connects to what you're going to start doing as you look into uh lab 4 and work on the prelab there. So that's a nice thing. That's my hope at least. Talk about some concepts here in class. You jump into the lab tomorrow, you really start to work on it, come back on Monday and it kind of all sort of builds upon each other versus being kind of independent uh threads of learning. So hopefully the next couple weeks will be uh pretty
0:47 enjoyable. I'm also going to stick to my plan from Monday of attempting to offer an exam question, at least cover what I believe will be an exam question based on how the conversation goes in class and one exam question a day. So I I know what I'll ask as of Monday's lecture and we'll we'll figure out what what today's will be. where we left off on Monday, uh we were talking about data leakage and and a fairly astute observer sent me a message and said that what you really described doesn't exactly sound like data leakage. Well, uh there's some value to that that feedback. Uh this is a very classic example of what's referred to as data leakage. Arguably, what happened in this asthma case? So again just to quickly refresh the idea
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Joseph Zambreno.