CSci574 / AI 520 Machine Learning: Classroom Session 09/29/2026
Overview
Derek Harter reviews project and Assignment 3 expectations, then explains how polynomial feature expansion lets linear regression fit nonlinear relationships and how learning curves reveal underfitting and overfitting. Using noisy quadratic data, NumPy, and scikit-learn, he compares model degrees, train-versus-validation error, and the bias–variance tradeoff as preparation for Assignment 4 and regularization.
Key takeaways
- Polynomial regression can use ordinary linear-regression optimization: expand x into columns such as x and x², then fit a linear model over the expanded feature space.
- Scikit-learn’s `PolynomialFeatures` creates both powers and cross-feature interactions, such as a²b, which becomes cumbersome to construct manually for multiple inputs.
- A high-degree polynomial may minimize training error by fitting noise, yet produce unstable predictions for unseen inputs, especially near the boundaries of the observed range.
- Learning curves compare error on progressively larger training subsets with error on held-out validation data; a persistent gap or rising validation error is evidence of overfitting.
- Underfitting is associated with high bias and insufficient model capacity, while overfitting is associated with high variance and poor generalization; model selection should consider both training and validation performance.
Chapters
- By Sunday, students should accept the class-project assignment, clone its repository, and edit the top-level README.
- The README should name and link the dataset, describe its features and labels, identify whether the task is classification or regression, and sketch a planned analysis.
- Derek Harter uses the submissions to check for duplicate datasets and datasets unsuitable for the project.
- Assignment 3 implementations of the loss gradient, prediction function, and fixed-iteration gradient descent loop were generally correct.
- Students must divide work into multiple Git commits rather than submitting the entire assignment in one commit.
- Commit history helps Derek Harter understand students’ progress and estimate time spent on individual tasks.
- Python functions should include NumPy-style docstrings describing each argument, its type, and the return value.
- Students should inspect the autograder after each commit and compare its test results with local runs; hard-coded paths can pass locally but fail in the grading environment.
- Notebook cells must contain the requested work, not merely pass execution checks; restart the kernel and run all cells to verify the notebook runs cleanly.
- A committed notebook with saved outputs lets Derek Harter inspect rendered results in JupyterHub and spot-check figures without cloning and rerunning the assignment.
- The expected submission usually modifies the source task file and notebook; the autograder does not automatically save notebook outputs back into the repository.
- Assignment 4 and the first test are due within roughly two weeks; the next assignment focuses on fitting nonlinear data with polynomial regression.
- Harter generates 100 noisy samples from a quadratic relationship containing an intercept, an x term, and an x² term.
- Without noise, the generating parabola could be recovered exactly; noise makes the best-fit parameters differ from the original values.
- Real datasets may follow polynomial, exponential, or other nonlinear relationships, even when their underlying form is not known.
- NumPy’s `polyfit` requires the user to specify a degree, such as degree 2; it does not automatically choose the polynomial complexity.
- Because the example data includes noise, the fitted coefficients approximate rather than exactly recover the generating parameters.
- `polyfit` returns coefficients from the highest power down to the constant term, unlike scikit-learn’s usual intercept-and-coefficient arrangement.
- A quadratic model can be fit with the same linear-regression optimizer by treating x and x² as separate features, with an intercept for the constant term.
- Scikit-learn’s `PolynomialFeatures(degree=2, include_bias=False)` converts a single input feature into columns for x and x².
- A scikit-learn `LinearRegression` estimator then fits the expanded features and supplies its own intercept.
- With multiple input features, nonlinear models often need interaction terms as well as separate powers of each feature.
- For features a and b, degree-three expansion can include terms such as a²b and ab² alongside their individual powers.
- `PolynomialFeatures` generates these combinations automatically, avoiding manual construction of an increasingly large feature matrix.
- Harter compares degree-one, degree-two, and degree-300 fits to data generated from a quadratic relationship.
- The degree-300 curve wiggles to follow noisy training points, showing how adding many parameters can fit noise as well as the underlying pattern.
- Such a curve can make wildly different predictions for nearby unseen inputs, especially near the edges of the training range.
- An underpowered model tends to retain high training error because it cannot represent the data’s underlying relationship.
- An overfit model can achieve low training error while performing poorly on held-out data that was not used during fitting.
- The desired model balances representation power and generalization; training performance alone cannot establish that a model is useful.
- The learning-curve routine repeatedly fits a model using progressively larger subsets of training data and measures mean squared error.
- It plots training error alongside error on held-back validation data, which remains unseen during each fit.
- The example has 10,000 samples, with about 80% assigned to training; plotting only the first 150 training-set sizes can make early behavior easier to inspect.
- For an overfit model, training error can keep falling while validation error remains much higher or worsens, so the curves fail to converge.
- A high-degree polynomial pipeline combines `PolynomialFeatures` with `LinearRegression` and behaves like a single estimator with `fit` and `predict` methods.
- Learning curves for thousands of training-set sizes can be slow; axis limits help reveal validation-error growth that might otherwise be compressed visually.
- High bias corresponds to underfitting from an overly restrictive model; high variance corresponds to overfitting noise and unstable predictions on unseen data.
- With the known quadratic example, the degree-two model reaches lower error than the degree-one model while its training and validation curves converge.
- The best polynomial degree can be assessed by comparing training and validation error across degrees; the next class session will introduce regularization techniques to reduce overfitting.
Transcript excerpt
0:16 I am. So, I'm gonna get started. Can you guys uh hear me online? Okay. >> Yes, >> all right. Thank you. [snorts] Okay. Um Okay. Um, so where we're at, um, I did get back the assignment three. I'm gonna maybe review that a little bit. I had one or two things to say, although, um, most everybody was, you know, had the actual content of the assignment pretty much working. So, it's mostly just general requirement stuff that I want to remind people about. Um, I didn't check uh, I did I do think I finally got this up. Um and hopefully I got all the dates
1:03 right but I am looking for um some initial work um at the end of this week. So this is coming up on this Sunday here. So the task is if you haven't seen this for the class project is to select a data set. Um and then uh I don't remember if I've accepted this yet. Here we go and accept it. Um if you read this is pretty much kind of an empty project. Uh there's a few folders in there. Um um and again I'll I'll probably talk more about the class project as we as we go along here. But I am hoping people take the opportunity to learn a little bit about you know tip typical standard practices about how you lay out a project and stuff like that.
1:50 But yeah, for this Sunday, I'm basically um looking for that you've you've accepted the assignment. So that means you'll have a repository. You did a clone of it. And you basically should modify the top level read me here. So you know, you should put in the name of your data set. If you got an URL that I
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, Derek Harter.