Save this video free

Lecture 2d

Prof. Schniter · 55:15 · Watch on YouTube

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Lecture 2d Watch on YouTube →

Overview

Prof. Schniter demonstrates practical linear regression in NumPy and scikit-learn, then shows how training fit, test performance, and categorical feature encoding affect model design. The lecture covers one-hot coding for category-specific intercepts or slopes, explains why using all K indicators with an intercept makes the design matrix singular, and introduces polynomial features as a way to build nonlinear curves with a linear predictor.

Key takeaways

Chapters

0:00 Least-Squares Coefficients and the Meaning of R-squared
2:35 Building the Design Matrix and Solving Least Squares in NumPy
5:50 NumPy lstsq, scikit-learn, and Training R-squared
15:05 Why More Features Cannot Worsen Training Least Squares
23:20 Evaluating Generalization with a 300-Sample Train-Test Split
26:55 One-Hot Encoding Brands as Categorical Features
35:15 Using One-Hot Features for Brand-Specific Slopes
38:08 Why K One-Hot Indicators Make the Intercept Model Singular
44:50 Encoding Both Slopes and Intercepts Changes What Data Is Shared
47:25 Polynomial Features Turn Linear Regression into Curved Fits
52:15 High-Order Polynomials Can Overfit Noisy Outliers

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:01 Okay, welcome back everyone. Hope you had a good weekend. Um, so let's uh get back to our linear regression notes. Last time we derived an alternate expression for the le squares coefficients. uh we have this expression here for the intercept term and this expression for the slope terms. And here we're using some statistics from our data set like the coariance matrix of the features. The um coariance between the features and the targets and we have the mean of the features and the mean of the target. [clears throat]

0:49 And we also talked about the special case of what's called simple linear regression which is where you use just one feature. And in this case all these these matrices and vectors they turn into scalers. And so we have these simpler expressions. We just have one intercept and one slope coefficient. And we'll be returning to this a little bit later today. We also discussed um the goodness of fit R squared goodness of fit which is a way of understanding from your um your fitted data set whether your fit is good or bad and we have a number R squar where with a perfect fit that would be R square is one. Um if the data was maximally difficult for linear le

1:40 squares and you computed the linear le squares fit anyway you would get r² equals z. Um if you do something foolish and compute coefficients that are worse than least squares then you could get a negative um r 2. So that would be like even worse than um yeah worse than than you would get with le squares. So we talked about that and um so the next thing I talk about is uh just a little bit of discussion of how

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

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, Prof. Schniter.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.