CSci574 / AI 520 Machine Learning: Classroom Session 10/06/2026
Overview
Derek Harter reviews CSci574/AI 520 deadlines and project expectations, then explains logistic regression for binary classification: the sigmoid maps linear scores to probabilities, and log loss gives a cost suited to those probabilities. He connects the loss to gradient descent and demonstrates how scikit-learn’s fitted probabilities define decision boundaries on Iris data, including a contour plot for two features.
Key takeaways
- Logistic regression converts a linear score into a probability with the sigmoid function, then typically predicts class 1 above 0.5 and class 0 below 0.5.
- Binary cross-entropy penalizes confident wrong predictions sharply: for a true class of 1 it uses negative log probability, and for class 0 it uses negative log of one minus that probability.
- Logistic regression’s sigmoid makes the optimization nonlinear, so it cannot use the linear-regression normal equation and instead requires gradient descent or another optimizer.
- A scikit-learn classifier’s predict_proba output reveals confidence, while predict applies a decision threshold to return class labels.
- A two-feature decision boundary can be visualized by evaluating predicted probabilities over a mesh grid and drawing the 0.5 contour; overlapping Iris classes can still produce mistakes.
- Lasso’s L1 regularization can set polynomial-regression coefficients to zero, while regularization choices should be documented and checked for underfitting or overfitting.
Chapters
- Assignment 4 remains due Sunday at midnight; Derek Harter encouraged students to finish before the half-week break.
- Students who had not accepted the class project or updated its README could still complete those steps that day or the next to receive credit.
- Harter recommended making project progress throughout the term, including regular Git commits, rather than leaving the work until the final week.
- Several assignment tasks ask students to create underfit and overfit models and use ridge and lasso regression.
- Lasso uses L1 regularization, which can drive unhelpful polynomial coefficients to zero and help assess which polynomial terms matter.
- Students should complete the assignment table and describe how they manually selected regularization parameters to avoid underfitting or overfitting.
- Harter recommended using Jupyter notebooks for projects, with multiple notebooks when a larger project benefits from being divided into parts.
- A readable notebook should combine runnable code cells with explanations in Markdown cells, using headings, bullets, and tables where appropriate.
- The lecture turns from linear and polynomial regression to logistic regression as a method for classification.
- Binary logistic regression applies the sigmoid, or logistic, function to a linear score such as theta multiplied by the input vector.
- The sigmoid maps scores from negative to positive infinity into values between 0 and 1, interpretable as predicted probabilities.
- A probability below 0.5 is classified as class 0 and one above 0.5 as class 1; a score of zero maps to probability 0.5.
- Mean squared error, used earlier for regression, is not the standard cost for logistic regression’s probability-based predictions.
- A useful classification cost should be small when the predicted probability agrees with the true 0-or-1 label and large when the model is confidently wrong.
- The lecture introduces negative logarithms to create costs with that behavior for each of the two possible labels.
- For a true label of 1, the cost uses the negative log of the predicted probability; predictions near 1 have low cost, while predictions near 0 have high cost.
- For a true label of 0, the mirrored term uses the negative log of one minus the predicted probability.
- The two cases combine into a single expression summed over training examples, commonly called binary cross-entropy or log loss.
- The derivative of logistic regression’s cost has a form similar to the linear-regression gradient, but it uses sigmoid predictions rather than an unconstrained linear output.
- This similarity means gradient-descent code for regression can be adapted by applying the sigmoid when calculating predictions, costs, and gradients.
- Unlike linear regression, the nonlinear sigmoid prevents solving for parameters with the normal equation, so an optimizer such as gradient descent is needed.
- Harter demonstrates binary classification on the Iris dataset by distinguishing Virginica flowers from non-Virginica flowers.
- A logistic-regression decision boundary separates the two predicted classes; with a single feature, the example places the threshold near petal width 1.66.
- A scikit-learn output-format change caused an array-versus-scalar error in the notebook; Harter refreshed the class repository and showed that the single value must be extracted.
- The scikit-learn workflow creates a LogisticRegression estimator and fits it to labeled feature data.
- The predict method returns class labels, while predict_proba provides probability estimates that reveal confidence in the classification.
- In the Iris example, petal-width values on opposite sides of the approximately 1.66 threshold receive different binary predictions.
- For petal length and petal width, the example extracts fitted model parameters to represent the decision boundary in two dimensions.
- A mesh grid samples petal length from about 2.9 to 7 and petal width from about 0.8 to 2.7; the model predicts probabilities across the grid.
- A contour at probability 0.5 shows the classification boundary, with values on opposite sides assigned to Virginica and non-Virginica.
- Some Iris points remain misclassified because one linear boundary cannot perfectly separate the training data.
- Harter deferred a full explanation of softmax regression, noting it can extend the probability-based approach to multiclass classification.
- He opened the floor for final questions before the next meeting and reiterated that Assignment 4 was due Sunday.
- A student who had missed the project acceptance deadline was told to complete the README and selection steps that day or the next; Harter also acknowledged a pending email.
Transcript excerpt
0:03 So, I only have one person online. Can you hear me online? Okay. >> Hello, professor. Yeah, all good. >> All right. Thank you. Um, what else? All right. All right. Yeah, let's go and get started. Um, I might keep it relatively short today. Uh so yeah u we just have a half week this week. Um I am keeping the you know some reminders about uh our assignment four um is still pending. Um so you know if you are taking a break like I am I'm probably not going to get uh well I mean I I do plan on grading these as usual probably on the Monday
0:49 after. But I am going to be kind of doing some other stuff uh Thursday and Friday and Saturday. Uh but anyway, yeah, if you're planning on taking a break like me, I'd encourage you to maybe, you know, get it done beforehand if if you can. But uh but yeah, I'll leave the deadline as Sunday kind of as usual for this class, midnight. So don't don't forget the assignment for um I did look through I mean there was a deadline uh this Sunday uh to pick your uh project uh for the um uh hopefully I had that on the previous announcement. Um so yeah, maybe I didn't have it on there. So um I'm I'm just remind people about that again. That deadline did
1:36 pass. you were supposed to have accepted the class project assignment. There should be a link. Uh so you should be able to accept it just like any other assignment, but also update the readme. Um so I had at least two people didn't uh do that yet. So um I'm still giving you a chance to do that if you're
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.