1. Home
  2. Explore
  3. Computer Science
  4. Machine Learning Course Intro

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Machine Learning Course Intro

Introduction to Machine Learning — Course Overview and Foundations

Course Logistics

This quarter features two instructors who alternate every few weeks. The teaching team includes one head TA (also course coordinator) and approximately 12 TAs, with additional TAs added if enrollment increases. All course information is consolidated on a single course website, which links to several Google Docs covering logistics, syllabus, lecture notes, and final project guidelines. The information presented in lectures is a subset of what is available online, so students are encouraged to read the documents thoroughly and check them before asking questions.

Key resources:

  • Course website with links to Google Docs

  • Canvas for lecture recordings and course calendar

  • Ed platform for Q&A (preferred communication method over email; private and public posts are available)

  • Gradescope for homework submission

Prerequisites

The course is mathematically intensive. While some students find it manageable, most report it as challenging. A solid background in the following areas is strongly recommended — at least two of the three should be well-known:

  • Probability (at the level of CS109 or Stats116): Familiarity with distributions, random variables, expectation, conditional probability, variance, and density functions.

  • Linear algebra (from Math 51/104/113/205): Specifically eigenvalues and eigenvectors, matrix operations.

  • Programming — especially Python and NumPy: Basic knowledge is essential. Students who know C++ but not Python can adapt, but no programming experience at all will make the course very difficult because homeworks combine math derivations with coding, and debugging requires distinguishing syntax errors from mathematical mistakes.

TA lectures will offer refreshers on Python/NumPy, linear algebra, and probability during the first three weeks.

Honor Code and Collaboration

The course has a strict honor code, and violations have occurred in the past. Key rules:

  • Collaboration allowed: Students may discuss homework problems in study groups, but each student must write up solutions independently and list the names of collaborators.

  • Prohibited: Copying, referring to, or looking at written or coding solutions from previous years (including official solutions, solutions posted online, or solutions from prior years by yourself or others). This applies to all homework and project work.

  • Enforcement: Code is checked using software, and TAs investigate violations. Students are advised not to intentionally violate the code; if they follow the rules they have nothing to worry about.

Course Components

  • Homeworks: 4 homeworks (math and programming components)

  • Midterm exam: No final exam

  • Course project: Groups of 1–3 people. Students apply machine learning to a topic of interest. Previous projects have spanned music, finance, pure algorithms, and many other areas. The final project deadline is Monday of finals week — no late days allowed due to strict grading deadlines (especially for graduating students).

  • TA lectures (optional): Two types:

    • Friday sections (6–7 weeks): First three weeks review basics (programming, linear algebra, probability). Later weeks cover advanced topics not required for the course but interesting for some students.

    • Discussion sections (led by TAs): Smaller, interactive sessions bridging lecture content and homework. TAs work through problems similar to homework (sometimes simpler), allowing students to present solutions and discuss. Two sessions with the same material; students are free to attend consistently or intermittently.

What is Machine Learning?

Machine learning has been defined in two classic ways, both of which capture core ideas.

Arthur Samuel (1959): Machine learning is the "field of study that gives computers the ability to learn without being explicitly programmed."

Tom Mitchell (1997): "A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E."

Key concepts from these definitions:

  • Experience (E): Typically data — examples from the past, whether collected from human play, self-play, sensors, or other sources. More experience (more data) should improve performance.

  • Task (T): The goal the program should accomplish (e.g., winning a game, predicting a price).

  • Performance measure (P): A metric to evaluate how well the program performs the task (e.g., win rate, prediction accuracy). Different tasks require different measures, and much research focuses on choosing the right formulation and optimizing performance.

  • Learning: The program's performance must improve with more experience. If adding data does not improve performance, the program is not truly learning — it is merely following a fixed explicit program.

Taxonomy of Machine Learning Tasks

While not all-encompassing, a common high-level taxonomy divides machine learning into three categories, often with overlaps:

  • Supervised learning

  • Unsupervised learning

  • Reinforcement learning

These are not strictly separate — for example, reinforcement learning often uses supervised learning as a component. Some problems may require combining all three.

Supervised Learning

Supervised learning is the first major topic of the course (Lectures 2–7). The goal: given a dataset of input-output pairs, learn a function that maps inputs to outputs, so that for a new input you can predict the output.

House Price Prediction Example

  • Input (features): For one house, the size (square feet) — a one-dimensional numerical feature.

  • Output (label): The price of the house — a continuous real number.

  • Dataset: nnn samples, each a pair (x(i),y(i))(x^{(i)}, y^{(i)})(x(i),y(i)), where x(i)x^{(i)}x(i) is the size and y(i)y^{(i)}y(i) is the price. The superscript (i)(i)(i) indexes examples; subscripts indicate coordinates (e.g., x1(i)x^{(i)}_1x1(i)​ is the first coordinate of the iii-th example).

The goal is to predict yyy for a new xxx (e.g., 800 sq ft) not seen in the dataset. A simple approach is linear regression: fit a line y=θ0+θ1xy = \theta_0 + \theta_1 xy=θ0​+θ1​x and read off the corresponding price. A more flexible approach is polynomial regression (e.g., quadratic) which may fit the data better.

Features: Inputs are often multi-dimensional. For a house, size and lot size are two features; the input becomes a two-dimensional vector. In general, features can be high-dimensional (number of floors, condition, ZIP code, etc.). Terminology: inputs are also called features, predictors, or independent variables; outputs are called labels, targets, or dependent variables. The instructor will use "input" and "output" to reduce ambiguity.

Notation: x(i)x^{(i)}x(i) denotes the iii-th example, a ddd-dimensional vector. xj(i)x^{(i)}_jxj(i)​ is the jjj-th coordinate. y(i)y^{(i)}y(i) is the output for that example.

Types of Supervised Problems

Two main types based on the nature of the label yyy:

  • Regression: yyy is a continuous real number (e.g., price, temperature, stock price).

  • Classification: yyy is a discrete variable (e.g., house vs. townhouse, digit 0–9, spam vs. not spam). For binary classification, the two classes are often represented as 0 and 1 (or -1 and +1). Multi-class classification involves more than two discrete categories.

Classification Example

Using the house example but predicting residence type: given size and lot size, the label is either house (triangle) or townhouse (circle). The data can be visualized in a 2D scatter plot where each point's shape indicates its class. A linear classifier draws a decision boundary (a line) to separate the classes. New points are classified based on which side of the line they fall.

Broader Applications

  • Image classification (e.g., ImageNet dataset): Input xxx is raw pixels (a matrix of numbers), output yyy is the object category. ImageNet was instrumental in the deep learning revolution over the past 5–10 years.

  • Object detection: Output becomes a bounding box (4 numbers) to localize objects.

  • Machine translation: Input is an English sentence, output is a Chinese sentence (or any language). Here yyy is a discrete set but enormous — the set of all possible sentences. This is a more complex classification-like problem that requires special treatment.

Note: The course covers foundational techniques; specific vision or NLP applications are best learned in dedicated courses.

Infinite-Dimensional Features (Lectures 6–7)

Sometimes we want to use combinations of raw features (e.g., x1⋅x2x_1 \cdot x_2x1​⋅x2​, x12x_1^2x12​, sin⁡(x1)\sin(x_1)sin(x1​)). Creating all possible transformations can lead to an infinite-dimensional feature space. The challenge: how to choose the best features without overfitting? The answer lies in kernel methods (covered later), which allow working implicitly with infinite-dimensional features while keeping runtime finite — a key insight for modern machine learning.

Unsupervised Learning

Unsupervised learning (Lectures 12–13, led by Chris) deals with data that has no labels. You only have inputs x(i)x^{(i)}x(i), without corresponding outputs yyy. The goal is to discover hidden structure in the data.

Clustering Example

Returning to the house/townhouse dataset but without the labels: you only see a scatterplot of points. Even without labels, a human can perceive two distinct groups — suggesting two types of residents. Clustering algorithms partition the data into groups where points in the same group are more similar to each other than to points in other groups.

K-means clustering and mixture of Gaussians are two classic algorithms covered in the course.

Applications of Unsupervised Learning

  • Gene clustering (Daphne Koller's group): By clustering individuals based on genetic markers, subgroups emerge that correlate with response to specific medicines. This enables personalized treatment.

  • Latent topic modeling (e.g., Latent Dirichlet Allocation — LDA): Given a large collection of documents (e.g., blog posts), the algorithm discovers topics — groups of words that tend to appear together. For example, a topic about space travel might have words like "shuttle", "space", "launch", "booster". Reordering the word-document frequency matrix reveals a block-diagonal structure where each block corresponds to a topic. This helps social scientists, historians, and psychologists understand large text corpora without manual labeling.

  • Word embeddings (e.g., word2vec, 2013): From a massive unlabeled dataset like Wikipedia, each word is mapped to a continuous vector. Similar words have similar vectors; moreover, directional differences encode semantic relationships. For example:

    • Vector(Italy) – Vector(Rome) ≈ Vector(France) – Vector(Paris) ≈ Vector(Germany) – Vector(Berlin). This means if you have the vector for "USA", you can find its capital by moving along that same direction — likely arriving near "Washington D.C." (though ambiguity due to multiple meanings of "Washington" complicates things).

  • Hierarchical clustering of word vectors: Scientific words can be grouped into areas (math, physics, etc.), with subareas overlapping (e.g., mathematical physics lies between math and physics vectors).

Foundation Models (Large Language Models)

Recent advances (roughly 2018–2020) have produced large language models trained on massive text corpora (trillions of words). These models, such as GPT-3, are extremely expensive to train (one training run can cost $10 million) but extremely versatile. They are called "foundation models" because they serve as a base for many tasks.

Key property: A single model trained on unlabeled data (e.g., all of Wikipedia or more) can perform multiple tasks without task-specific fine-tuning — simply by interacting through natural language prompts.

Examples of GPT-3 capabilities:

  • Story generation: Given a starting paragraph, the model generates coherent, human-like continuation.

  • Question answering: From a passage, the model answers reading-comprehension questions.

  • Word unscrambling: Given scrambled letters, it rearranges them into a word.

  • Arithmetic: "95 × 45" yields the correct answer — not because all products are memorized, but because the model learns numerical patterns from the corpus and extrapolates.

Concerns:

  • Data poisoning: Adversaries could corrupt a small fraction of training data to cause the model to learn incorrect behaviors — a significant risk when training on internet-scale data.

  • Memorization vs. generalization: The model may memorize some facts, but it also generalizes to unseen examples (e.g., new multiplication problems).

The course will include one lecture specifically on large language models and foundation models (a new addition this year).

Reinforcement Learning

Reinforcement learning (RL) appears in the final two to three lectures of the course. The core idea: learning to make sequential decisions where each decision has long-term consequences.

Key Characteristics

  • Task: The agent must take a sequence of actions (e.g., moves in chess, joint torques for a robot) to maximize cumulative reward.

  • No fixed dataset: Unlike supervised/unsupervised learning, RL often interacts with an environment, collecting data as it goes. The loop: try a policy → observe outcome → improve policy → try again. Thus the dataset grows over time.

  • Evaluation: Performance is measured by cumulative reward (e.g., total points in a game, distance walked by a robot). The agent must balance exploration (trying new actions) and exploitation (using known good actions).

Example: Humanoid Robot Walking

In simulation, a humanoid robot learns to walk to the right. Early iterations produce clumsy, falling movements. Over time (e.g., 80–210 iterations), the robot learns a stable gait. The optimal strategy for the robot may not look human-like due to biomechanical differences, but it achieves the goal.

Feedback Timing

The typical formulation gives immediate feedback after each action. However, many real-world problems have delayed rewards — you may not know the outcome of a move until many steps later (e.g., chess, nuclear plant control). Other constraints include:

  • Deployment constraints: You might only be allowed to update your policy a few times (e.g., for safety or cost). RL must then be sample-efficient.

  • Safety constraints: In nuclear plant control, the policy must never cause dangerous states, which adds another layer of complexity to the optimization.

Relationship to Supervised/Unsupervised Learning

RL often incorporates supervised learning components (e.g., approximating value functions). It is not a completely isolated field; many modern systems blend all three paradigms.

Other Topics in the Course

  • Deep Learning Basics (2 lectures): The use of neural networks as flexible model parametrizations. Deep learning has driven much of the recent progress in machine learning since 2013–2014. It can be applied to supervised, unsupervised, and reinforcement learning tasks.

  • Learning Theory (1–2 lectures): Understanding trade-offs between model complexity, feature selection, and generalization. How to minimize test error and make principled decisions about algorithm design.

  • Practical ML Tuning (1 lecture): Insights from learning theory applied to real-world practice — what decisions matter most when implementing ML models.

  • Guest Lecture: Fairness and Robustness (by James Zou): Machine learning systems have significant societal impact, and issues of bias, fairness, and adversarial robustness are critical. This lecture covers these broader aspects, noting that the instructor is not an expert in this area but the guest is.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent