CSci574 / AI 520 Machine Learning: Classroom Session 10/15/2026
Overview
Derek Harter explains the two-hour, three-question midterm and reviews Assignment 4, using polynomial regression to illustrate underfitting, overfitting, regularization, and model selection. The examples include degree-2 and degree-100 models, Lasso and Ridge regression, and scikit-learn grid search with five-fold cross-validation; Harter also clarifies notebook submission requirements and individual-test rules.
Key takeaways
- The midterm requires three Python-based questions in two hours, so students should prepare the provided IPython notebook and verify their scikit-learn environment before beginning.
- A degree-2 polynomial underfits Assignment 4's degree-6 data at roughly 0.3 error, while a degree-100 model can reach training RMSE near 0.04 and overfit unseen data.
- Lasso's alpha is especially sensitive in this example: small changes near zero can change how many coefficients survive, making systematic tuning more useful than guesswork.
- Five-fold cross-validation over 1,000 logarithmically spaced alpha values selected approximately 8 × 10^-5 for Lasso, with RMSE around 0.12.
- When there is a reason to expect polynomial structure, searching degrees directly with a PolynomialFeatures and LinearRegression pipeline can be cleaner and more informative than regularizing an unnecessarily powerful model.
- For the midterm, a single runnable notebook with all three answers should be attached in MyLearningOnline; the test is open-resource but individual.
Chapters
- The online midterm has a two-hour limit, three multi-part questions, and is due Sunday at midnight.
- Students should download the provided IPython notebook before starting and use Python 3.13 or a recent version.
- Expected libraries include scikit-learn, NumPy, pandas, and Matplotlib for regression, classification, and plots.
- Questions will resemble assignment tasks, including linear regression and logistic regression with scikit-learn.
- The class is moving beyond parametric linear and logistic regression toward support vector machines, decision trees, and k-nearest neighbors.
- Unsupervised learning is planned for a later part of the course.
- Assignment 4 builds on the previous assignment by showing how parameter-fitting techniques can also fit nonlinear polynomial models.
- Assignment 4 generated data from a degree-6 polynomial with coefficients including values such as 2, 1, and -1, alongside zero-valued terms.
- Lasso can drive unnecessary coefficients to zero, but choosing alpha may not reliably reveal the true polynomial degree.
- Harter advises completing every requested discussion and using Markdown headers, bold text, and other formatting in notebooks and project READMEs.
- Notebooks run from the notebook subdirectory, so data files are typically reached by navigating up one directory and into data.
- Assignment utilities can provide the project root path, allowing code to locate data whether run from the project root or a subdirectory.
- Correctly loading and plotting the data should reveal the generated polynomial relationship over an x-range from -1 to 1.
- A degree-2 polynomial underfits the degree-6 generated relationship, with error around 0.3.
- A degree-100 model can fit training data much more closely, reaching training RMSE around 0.04, while initially performing poorly on unseen data.
- Limiting the plot's y-axis helps reveal training behavior that would otherwise be visually compressed by extreme predictions.
- The known generating function lets the example compare fitted curves with the true noiseless polynomial, a comparison unavailable for ordinary real-world data.
- Trying different alpha values shows how regularization can move a model from overfitting toward underfitting.
- For this dataset, Lasso required alpha values close to zero, and small changes could substantially alter which coefficients remained nonzero.
- Ridge produced a more stable-looking fit in the example, with alpha around 0.01 and error near 0.05.
- A useful model should reduce error on both training and test data rather than merely achieving a very low training error.
- A grid search evaluates 1,000 Lasso alpha values spaced logarithmically from approximately 10^-15 to 1.
- Five-fold cross-validation estimates performance across data splits and selects the alpha with the lowest root mean squared error.
- The example's best alpha is about 8 × 10^-5, with RMSE around 0.12.
- Plotting results across alpha values shows a useful region near 10^-5 to 10^-4 rather than a single isolated optimum.
- When the data is known to follow a polynomial, directly searching polynomial degree from 2 through 100 is more targeted than relying only on regularization.
- A scikit-learn pipeline combines PolynomialFeatures with LinearRegression, and cross-validation compares candidate degrees.
- The degree search can recover a strong estimate of the generating function and coefficients such as 2, 2, 0, -2, -1, 0, and -1.
- Artificially generated data makes underfitting, overfitting, regularization, and feature engineering easier to study because the true function is known.
- Harter recommends reviewing Assignments 1 through 4 because the midterm questions will resemble their coding tasks.
- The test is open-resource but must be completed individually, without collaborating or asking others for help during the attempt.
- Students should submit a runnable IPython notebook containing answers to all three questions, preferably as one attachment to the final question.
- Separate notebook uploads after individual questions are acceptable, but at least one notebook attachment is required through MyLearningOnline.
Transcript excerpt
0:03 I'm going to start recording. Okie doke. I'm going to go and get started. So, so yeah, sorry about Tuesday. I I I mean I wasn't expecting to get pulled away. Family thing.
0:50 So, but kind of like I said in my message, I wasn't certain that I was going to have a lot of stuff to say for both Tuesday and Thursday, but um So, the the the main thing we have to go through is make sure that everybody is aware of the test. So, I'm going to start with that and maybe end with that as well. Just to check if anybody has any questions about the format or what they need to do. So, it should be open now. And I did check it. So, I think everything is set up to go. Let me just do a real quick. So, um I mean, you know, there's various ways you can do this, but usually if you go to your content, I think you should be able to see. So, you should go ahead and start probably by
1:38 downloading the There is a iPython notebook. And then the other thing is yeah, before you actually start the tests, have the iPython notebook. And so, you know, there's no you know, there's no assignment to accept or anything. I would recommend that you go ahead and like reuse your most recent assignment environment that you have set up set up. So, you know, like if you did complete assignment five successfully assignment five um assignment four successfully the last one that we just did. Um you ought to be able to download this notebook and just put it in the the same place and like if you're using the class dev containers of course, you want to start your doctor
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.