CS 189/289A
Introduction to Machine Learning

Jonathan Shewchuk

Spring 2023
Mondays and Wednesdays, 6:30–8:00 pm
Hearst Field Annex A1
Begins Wednesday, January 18
Discussion sections begin Tuesday, January 24

Contact:
Use Ed Discussion for public and private questions that can be viewed by all the TAs. I check Ed Discussion far more often and reliably than email.
For very personal issues, send email to jrs@berkeley.edu.

My office hours:
Mondays, 5:10-6:00 pm
Fridays, 5:40-6:30 pm
and by appointment.
(I'm usually free after the lectures too.)

 

This class introduces algorithms for learning, which constitute an important part of artificial intelligence.

Topics include

Useful Links

Prerequisites

You should take these prerequisites quite seriously. If you don't have a solid intuitive understanding of linear algebra, probability, and gradients, as well as substantial programming experience with some attention to data structures, I strongly recommend not taking CS 189. However, the prerequisites are not formally enforced—rather, they're enforced by the fact that you won't understand the class without them.

If you want to brush up on prerequisite material:

Textbooks

Both textbooks for this class are available free online. Hardcover and eTextbook versions are also available.


Homework and Exams

You have a total of 6 slip days that you can apply to your semester's homework. We will simply not award points for any late homework you submit that would bring your total slip days over six. If you are in the Disabled Students' Program and you are offered an extension, even with your extension plus slip days combined, no single assignment can be extended more than 5 days. (We have to grade them sometime!)

The following homework due dates and midterm date are tentative and may change.

The CS 289A Project has a proposal due Monday, April 10. The video is due Monday, May 8, and the final report is due Tuesday, May 9. Please sign up your group for a ten-minute meeting slot with one of the TAs. If you need serious computational resources, our former Teaching Assistant Alex Le-Tu has written lovely guides to using Google Cloud and using Google Colab.

Homework 1 is due Wednesday, January 25 at 11:59 PM. (Warning: 200 MB zipfile. Here's just the written part.)

Homework 2 is due Wednesday, February 8 at 11:59 PM. (PDF file only.)

Homework 3 is due Wednesday, February 22 at 11:59 PM. (Warning: 22 MB zipfile. Here's just the written part.)

Homework 4 is due Friday, March 10 at 11:59 PM. (Here's just the written part. We also offer a LaTeX template you may use to fill in your solutions.)

Homework 5 is due Friday, March 31 at 11:59 PM. (Here's just the written part.)

Homework 6 is due Wednesday, April 19 at 11:59 PM. (Warning: 305 MB zipfile. Here's just the written part.)

Homework 7 is due Friday, May 5 at 11:59 PM. (Here's just the written part.)

The Midterm took place on Monday, March 20 at 7:00–8:30 PM in Wheeler Auditorium (150 Wheeler Hall). Previous midterms are available: Without solutions: Spring 2013, Spring 2014, Spring 2015, Fall 2015, Spring 2016, Spring 2017, Spring 2019, Summer 2019, Spring 2020 Midterm A, Spring 2020 Midterm B, Spring 2021, Spring 2022, Spring 2023. With solutions: Spring 2013, Spring 2014, Spring 2015, Fall 2015, Spring 2016, Spring 2017, Spring 2019, Summer 2019, Spring 2020 Midterm A, Spring 2020 Midterm B, Spring 2021, Spring 2022, Spring 2023.

The Final Exam took place on Friday, May 12 at 3–6 PM. Previous final exams are available. Without solutions: Spring 2013, Spring 2014, Spring 2015, Fall 2015, Spring 2016, Spring 2017, Spring 2019, Spring 2020, Spring 2021, Spring 2022, Spring 2023. With solutions: Spring 2013, Spring 2014, Spring 2015, Fall 2015, Spring 2016, Spring 2017, Spring 2019, Spring 2020, Spring 2021, Spring 2022, Spring 2023.

Lectures

Now available: The complete semester's lecture notes (with table of contents and introduction).

The references below to sections in Introduction to Statistical Learning with Applications in R (ISL) are for the first edition. I will update them to the second edition when time permits.

Lecture 1 (January 18): Introduction. Classification, training, and testing. Validation and overfitting. Read ESL, Chapter 1. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's the captioned version of the screencast (screen only).

Lecture 2 (January 23): Linear classifiers. Decision functions and decision boundaries. The centroid method. Perceptrons. Read parts of the Wikipedia Perceptron page. Optional: Read ESL, Section 4.5–4.5.1. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's the captioned version of the screencast (screen only).

Lecture 3 (January 25): Gradient descent, stochastic gradient descent, and the perceptron learning algorithm. Feature space versus weight space. The maximum margin classifier, aka hard-margin support vector machine (SVM). Read ISL, Section 9–9.1. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's the captioned version of the screencast (screen only).

Lecture 4 (January 30): The support vector classifier, aka soft-margin support vector machine (SVM). Features and nonlinear decision boundaries. Read ESL, Section 12.2 up to and including the first paragraph of 12.2.1. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's the captioned version of the screencast (screen only).

Lecture 5 (February 1): Machine learning abstractions: application/data, model, optimization problem, optimization algorithm. Common types of optimization problems: unconstrained, constrained (with equality constraints), linear programs, quadratic programs, convex programs. Optional: Read (selectively) the Wikipedia page on mathematical optimization. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's the captioned version of the screencast (screen only).

Lecture 6 (February 6): Decision theory: the Bayes decision rule and optimal risk. Generative and discriminative models. Read ISL, Section 4.4.1. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 7 (February 8): Gaussian discriminant analysis, including quadratic discriminant analysis (QDA) and linear discriminant analysis (LDA). Maximum likelihood estimation (MLE) of the parameters of a statistical model. Fitting an isotropic Gaussian distribution to sample points. Read ISL, Section 4.4. Optional: Read (selectively) the Wikipedia page on maximum likelihood estimation. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 8 (February 13): Eigenvectors, eigenvalues, and the eigendecomposition. The Spectral Theorem for symmetric real matrices. The quadratic form and ellipsoidal isosurfaces as an intuitive way of understanding symmetric matrices. Application to anisotropic normal distributions (aka Gaussians). Read Chuong Do's notes on the multivariate Gaussian distribution. My lecture notes (PDF). The lecture video. However, the screen recording failed, so you should probably watch my 2021 lecture instead.

Lecture 9 (February 15): Anisotropic normal distributions (aka Gaussians). MLE, QDA, and LDA revisited for anisotropic Gaussians. Read ISL, Sections 4.4 and 4.5. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

February 20 is Presidents' Day.

Lecture 10 (February 22): Regression: fitting curves to data. The 3-choice menu of regression function + loss function + cost function. Least-squares linear regression as quadratic minimization. The design matrix, the normal equations, the pseudoinverse, and the hat matrix (projection matrix). Logistic regression; how to compute it with gradient descent or stochastic gradient descent. Read ISL, Sections 4–4.3. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 11 (February 27): Newton's method and its application to logistic regression. LDA vs. logistic regression: advantages and disadvantages. ROC curves. Weighted least-squares regression. Least-squares polynomial regression. Read ISL, Sections 4.4.3, 7.1, 9.3.3; ESL, Section 4.4.1. Optional: here is a fine short discussion of ROC curves—but skip the incoherent question at the top and jump straight to the answer. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 12 (March 1): Statistical justifications for regression. The empirical distribution and empirical risk. How the principle of maximum likelihood motivates the cost functions for least-squares linear regression and logistic regression. The bias-variance decomposition; its relationship to underfitting and overfitting; its application to least-squares linear regression. Read ESL, Sections 2.6 and 2.9. Optional: Read the Wikipedia page on the bias-variance trade-off. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 13 (March 6): Ridge regression: penalized least-squares regression for reduced overfitting. How the principle of maximum a posteriori (MAP) motivates the penalty term (aka Tikhonov regularization). Subset selection. Lasso: penalized least-squares regression for reduced overfitting and subset selection. Read ISL, Sections 6–6.1.2, the last part of 6.1.3 on validation, and 6.2–6.2.1; and ESL, Sections 3.4–3.4.3. Optional: This CrossValidated page on ridge regression is pretty interesting. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 14 (March 8): Decision trees; algorithms for building them. Entropy and information gain. Read ISL, Sections 8–8.1. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 15 (March 13): More decision trees: multivariate splits; decision tree regression; stopping early; pruning. Ensemble learning: bagging (bootstrap aggregating), random forests. Read ISL, Section 8.2. My lecture notes (PDF). The animations I showed in class are available in this directory. The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 16 (March 15): Kernels. Kernel ridge regression. The polynomial kernel. Kernel perceptrons. Kernel logistic regression. The Gaussian kernel. Optional: Read ISL, Section 9.3.2 and ESL, Sections 12.3–12.3.1 if you're curious about kernel SVM. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

The Midterm took place on Monday, March 20 at 7:00–8:30 PM in Wheeler Auditorium (150 Wheeler Hall). The midterm covers Lectures 1–13, the associated readings listed on the class web page, Homeworks 1–4, and discussion sections related to those topics.

Lecture 17 (March 22): Neural networks. Gradient descent and the backpropagation algorithm. Read ESL, Sections 11.3–11.4. Optional: Welch Labs' video tutorial Neural Networks Demystified on YouTube is quite good (note that they transpose some of the matrices from our representation). Also of special interest is this Javascript neural net demo that runs in your browser. Here's another derivation of backpropagation that some people have found helpful. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

March 27–31 is Spring Recess.

Lecture 18 (April 3): Neuron biology: axons, dendrites, synapses, action potentials. Differences between traditional computational models and neuronal computational models. Backpropagation with softmax outputs and logistic loss. Unit saturation, aka the vanishing gradient problem, and ways to mitigate it. Optional: Try out some of the Javascript demos on this excellent web page—and if time permits, read the text too. The first four demos illustrate the neuron saturation problem and its fix with the logistic loss (cross-entropy) functions. The fifth demo gives you sliders so you can understand how softmax works. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 19 (April 5): Heuristics for faster training. Heuristics for avoiding bad local minima. Heuristics to avoid overfitting. Convolutional neural networks. Neurology of retinal ganglion cells in the eye and simple and complex cells in the V1 visual cortex. Read ESL, Sections 11.5 and 11.7. Here is the video about Hubel and Wiesel's experiments on the feline V1 visual cortex. Here is Yann LeCun's video demonstrating LeNet5. Optional: A fine paper on heuristics for better neural network learning is Yann LeCun, Leon Bottou, Genevieve B. Orr, and Klaus-Robert Müller, “Efficient BackProp,” in G. Orr and K.-R. Müller (Eds.), Neural Networks: Tricks of the Trade, Springer, 1998. Also of special interest is this Javascript convolutional neural net demo that runs in your browser. Some slides about the V1 visual cortex and ConvNets (PDF). My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 20 (April 10): Unsupervised learning. Principal components analysis (PCA). Derivations from maximum likelihood estimation, maximizing the variance, and minimizing the sum of squared projection errors. Eigenfaces for face recognition. Read ISL, Sections 10–10.2 and the Wikipedia page on Eigenface. Optional: Watch the video for Volker Blanz and Thomas Vetter's A Morphable Model for the Synthesis of 3D Faces. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 21 (April 12): The singular value decomposition (SVD) and its application to PCA. Clustering: k-means clustering aka Lloyd's algorithm; k-medoids clustering; hierarchical clustering; greedy agglomerative clustering. Dendrograms. Read ISL, Section 10.3. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 22 (April 17): The geometry of high-dimensional spaces. Random projection. The pseudoinverse and its relationship to the singular value decomposition. Optional: Mark Khoury, Counterintuitive Properties of High Dimensional Space. Optional: The Wikipedia page on the Moore–Penrose inverse. For reference: Sanjoy Dasgupta and Anupam Gupta, An Elementary Proof of a Theorem of Johnson and Lindenstrauss, Random Structures and Algorithms 22(1)60–65, January 2003. My lecture notes (PDF). The lecture video. In case you don't have access to bCourses, here's a backup screencast (screen only).

Lecture 23 (April 19): Learning theory. Range spaces (aka set systems) and dichotomies. The shatter function and the Vapnik–Chervonenkis dimension. Read Andrew Ng's CS 229 lecture notes on learning theory. For reference: Thomas M. Cover, Geometrical and Statistical Properties of Systems of Linear Inequalities with Applications in Pattern Recognition, IEEE Transactions on Electronic Computers 14(3):326–334, June 1965. My lecture notes (PDF). The lecture video.

Lecture 24 (April 24): AdaBoost, a boosting method for ensemble learning. Nearest neighbor classification and its relationship to the Bayes risk. Read ESL, Sections 10–10.5, and ISL, Section 2.2.3. For reference: Yoav Freund and Robert E. Schapire, A Decision-Theoretic Generalization of On-Line Learning and an Application to Boosting, Journal of Computer and System Sciences 55(1):119–139, August 1997. Freund and Schapire's Gödel Prize citation and their ACM Paris Kanellakis Theory and Practice Award citation. For reference: Thomas M. Cover and Peter E. Hart, Nearest Neighbor Pattern Classification, IEEE Transactions on Information Theory 13(1):21–27, January 1967. For reference: Evelyn Fix and J. L. Hodges Jr., Discriminatory Analysis---Nonparametric Discrimination: Consistency Properties, Report Number 4, Project Number 21-49-004, US Air Force School of Aviation Medicine, Randolph Field, Texas, 1951. See also This commentary on the Fix–Hodges paper. My lecture notes (PDF). The lecture video.

Lecture 25 (April 26): The exhaustive algorithm for k-nearest neighbor queries. Speeding up nearest neighbor queries. Voronoi diagrams and point location. k-d trees. Application of nearest neighbor search to the problem of geolocalization: given a query photograph, determine where in the world it was taken. If I like machine learning, what other classes should I take? For reference: the best paper I know about how to implement a k-d tree is Sunil Arya and David M. Mount, Algorithms for Fast Vector Quantization, Data Compression Conference, pages 381–390, March 1993. For reference: the IM2GPS web page, which includes a link to the paper. My lecture notes (PDF). The lecture video.

The Final Exam took place on Friday, May 12, 3–6 PM.

Discussion Sections and Teaching Assistants

Sections begin to meet on January 24.


Some of our office hours are online or hybrid. To attend an online office hour, submit a ticket to the Online Office Hour Queue at https://oh.eecs189.org and attend the office hour through Zoom at this Zoom link.

Your Teaching Assistants are:
Rohit Agarwal
Samuel Alber
Anastasios Angelopoulos
Dasheng Bi
Jason Ding
Eve Fleisig
Tanmay Gautam
Jonathan Lu
Ziye Ma
Mrunali Manjrekar
Sara Pohland
Bill Peebles
Arvind Rajaraman
Kamyar Salahi
Chawin Sitawarin
John So
Anton Than

Grading

 

Supported in part by the National Science Foundation under Awards CCF-0430065, CCF-0635381, IIS-0915462, CCF-1423560, and CCF-1909204, in part by a gift from the Okawa Foundation, and in part by an Alfred P. Sloan Research Fellowship.


Copyright 2023 by Jason Diwa