1. Home
  2. Explore
  3. Computer Science
  4. Introduction to Machine Learning

Study methods

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

Introduction to Machine Learning

Speaker 1Speaker 2

Introduction to Machine Learning

16:49
0:00-16:49
  1. Michael

    Welcome to Introduction to Machine Learning, 6.036 and its graduate version, 6.862. Let’s start with the practical rhythm: lectures are live on Tuesdays, starting at 9:35 a.m. Boston time and ending five minutes before 11. That five-minute buffer is meant to help you get between classes.

  2. Simon

    And because the lecture is synchronous, you can participate while it’s happening. One time-zone detail: use Boston time rather than assuming the schedule will always be labeled EDT or EST, since daylight saving changes during the semester.

  3. Michael

    There are two course numbers. The graduate-course admissions process for 6.862 has been finalized, but you can still take 6.036 whether you’re switching from 6.862 or signing up fresh. The main course website is the central place to find information and materials. If you’re in 6.862, also check its separate Canvas site, especially for project information.

  4. Simon

    For questions, the course uses Discourse rather than Zoom chat. You can ask there about logistics or course content, and staff will respond. If a question would benefit the whole class, it may be brought into lecture. For a question connected to today’s lecture, choose the Lecture 1 category.

  5. Michael

    The slides, course notes, saved iPad writing, and lecture recording are expected to be available on the course website. The recording is useful if you can’t attend live or want to review. One important reminder: Zoom chat won’t be monitored for general questions, so put those on Discourse.

  6. Simon

    The course has some computing prerequisites: you should be comfortable programming in Python, using NumPy, working with algorithms, and reading pseudocode. The math background includes matrix operations such as multiplication, transpose, and inverse; points and planes in higher-dimensional spaces; gradients; and basic discrete probability, including randomness, independence, and conditioning.

  7. Michael

    The staff strongly recommend doing the readiness assessment linked from the course website’s welcome section. It’s a way to check whether the prerequisite material feels familiar before the course gets going. And there’s a large instructional team—lecturers, teaching assistants, and lab assistants—so students will meet staff in labs and office hours, not just in lecture.

  8. Simon

    There’s also a schedule survey to complete or update by noon on the first Tuesday. It helps staff assign students to lab times. The first lab is this week and is intended to be relaxed: much of it is about checking that the setup works. Lab assignments are expected later that day, with instructions for self-swapping where space permits.

  9. Michael

    Labs are synchronous and interactive, so students need to attend their assigned time. They’re organized into groups called MLyPods, generally around ten students, with some possible adjustments early on. Within a pod, students work in smaller groups of roughly two or three on problems, can ask staff questions, and check in with staff at the end.

  10. Simon

    The weekly learning routine has several pieces. Exercises will generally be due at 9 a.m. before Tuesday lecture; there were none due on the first day, and the first set is due the following week. They’re intended to get you ready for lecture by encouraging you to do some preparation and reading.

  11. Michael

    There’s also weekly homework, linked from the course site under the week’s materials. The first homework is due Wednesday, September 9. A weekly nano quiz replaces the usual large midterm and final: there’s no big midterm or final exam in this class. The first quiz, in lab this week, is ungraded and mainly lets everyone try the format.

  12. Simon

    Starting the following week, the nano quiz becomes a real weekly assessment. You’ll have a 24-hour window to complete it before your lab section, but once you start, the quiz is timed. Office hours are another support option, with sessions at various times on most days and the first ones expected to begin Sunday. Students in 6.862 should also follow the project information on Canvas.

  13. Michael

    All right, from course setup to the subject itself: why study machine learning? A quick answer is that it’s widely used. We’ll look at examples, then build a precise picture of what the field is doing and how to judge whether its methods are useful.

  14. Simon

    Consider the search for exoplanets—planets outside our solar system. Scientists have telescope data with signals that may indicate a planet. A machine-learning method can help distinguish genuine exoplanets from other explanations for those signals.

  15. Michael

    In neonatal seizure recognition, the data can include EEG recordings and observed movements. Interpreting those signals can take considerable effort, so a method might help decide whether a candidate movement indicates a seizure or something normal. That decision could help medical practitioners provide appropriate care.

  16. Simon

    Other examples involve text. Researchers analyzing Supreme Court petitions wanted to identify topics and themes across thousands of documents. The Bureau of Labor Statistics also has interview and survey text that needs to be assigned codes, such as whether it concerns an occupation or a workplace injury. Automating parts of those tasks could save labor, particularly when human annotators are expensive to train or don’t always agree.

  17. Michael

    Email filtering is another familiar case. A system can use the text of an email to decide whether it’s phishing—a deceptive attempt to obtain a password or other sensitive information—or not. The aim is to catch harmful messages before they reach someone’s inbox.

  18. Simon

    And some applications raise serious concerns. Facial recognition might use surveillance images to identify a person. If the identification is wrong, the consequences could be severe, especially if someone is mistakenly suspected of a crime. In finance, data such as satellite images of farms and weather information might be used to assess whether a farmer should receive a loan.

  19. Michael

    Across these examples, a common pattern emerges: we have data, and we use a method to make a decision. Machine learning can sometimes save time, energy, and resources, and potentially bring automation to new areas. But it matters for more than its practical applications.

  20. Simon

    Right. These systems can influence medical care, financial decisions, security, and people’s experience of government. Understanding machine learning helps us understand decisions that affect everyday life. It also helps us evaluate claims: when someone says a method works, we should ask whether it really works, whether it works as intended, and what effects it has.

  21. Michael

    Machine learning is a tool, not magic. A striking study tried to predict future outcomes for children using very rich sociological data and modern methods, yet the predictions were not very good. One goal of this course is to understand when machine learning can work well, when it may not, and how we can recognize the difference.

  22. Simon

    And the foundation is mathematics. That’s why the course has math prerequisites, and why the material will use mathematical ideas throughout. To see how the pieces fit together, let’s formalize a simple version of the seizure example.

  23. Michael

    Suppose we have observations of newborns from the past and want to predict whether a future newborn will have a seizure. The past observations are our training data. Let n be the number of training examples, and use i to index an example, from 1 through n.

  24. Simon

    Each example has a feature vector, written x superscript i, and a label, written y superscript i. The feature vector records measured properties; the label is the outcome we want to predict. In a cartoon with two features, we might let x one represent oxygen intake and x two represent movement, and use labels minus one and plus one for no seizure and seizure.

  25. Michael

    That two-dimensional drawing is just for visualization. Real data can have many more features: the neonatal seizure example discussed had a 55-dimensional representation. Creating the features from complex EEG information is itself a substantial task; for now, we assume the features have already been produced.

  26. Simon

    We can write the full training set as D sub n: a collection of n feature-and-label pairs. If we plot two features, each newborn is a point in the plane, and the label tells us which class it belongs to. Looking at labeled examples gives us an intuition that we might predict the label of a new point based on where it lies.

  27. Michael

    That intuition needs two things made precise: how we label new points, and what makes a labeling good. To start with the first, a rule that takes any possible feature vector x and returns a label y is a function. We call such a function a hypothesis, often written h.

  28. Simon

    For example, the rule that outputs plus one for every possible x is a hypothesis: it is a function from feature space to labels. But it’s not a useful one in this example, because it predicts that every newborn has a seizure. Being a hypothesis only means it defines a prediction rule; it doesn’t mean the rule is good.

  29. Michael

    A hypothesis class, written script H, is a collection of hypotheses. One class we’ll study consists of linear classifiers: rules that label one side of a line plus one and the other side minus one. A line by itself isn’t a classifier, because it doesn’t yet say what label to assign. The labels on both sides turn it into a function over the whole space.

  30. Simon

    To express these lines in any number of dimensions, take a feature vector x and a direction vector theta. Treat both as column vectors in the same d-dimensional space. Their dot product is theta transpose x: theta transpose is one-by-d, x is d-by-one, so the product is a one-by-one value—a scalar.

  31. Michael

    Geometrically, theta transpose x divided by the length of theta is the signed projection of x onto the direction theta: it tells us how much of x lies along that direction. If x is perpendicular to theta, the projection is zero. Multiplying theta by a positive scale doesn’t change its direction, so it doesn’t change the projection onto that direction.

  32. Simon

    All points whose projection onto theta is zero form a line in two dimensions, or a corresponding hyperplane in higher dimensions. Points with projection equal to a fixed value form a parallel hyperplane. This gives us a way to describe a separating boundary without relying on the familiar high-school formula y equals m x plus b.

  33. Michael

    That old formula is especially confusing here because its y is a coordinate, while y in our learning problem denotes a label. Instead, we use the feature vector x, the direction theta, and an offset. One convenient way to write the boundary is theta transpose x plus theta naught equals zero.

  34. Simon

    The parameter theta determines the direction of the boundary, and theta naught shifts its position. In the projection-based description, if the projection equals negative b, then the boundary can be written theta transpose x plus b times the length of theta equals zero. Calling that constant term theta naught gives the compact form.

  35. Michael

    Once the boundary is defined, the classifier assigns plus one on the side where theta transpose x plus theta naught is positive, and minus one where it’s negative. For this course’s definition, points exactly on the boundary get minus one. That equality convention is a choice, but it makes the rule complete.

  36. Simon

    We can write a particular classifier as h with parameters theta and theta naught. The semicolon separates those parameters from the input: h is still a function that takes x and returns a label, while theta and theta naught identify which particular function we mean. The collection of all such linear classifiers is the hypothesis class script H.

  37. Michael

    So far, we have described possible prediction rules, but we haven’t used the data to choose one. To choose intelligently, we need to say what ‘good’ means. Ultimately, we want a classifier to predict well on future examples—newborns it hasn’t seen before.

  38. Simon

    We can start by defining how costly a single prediction is. A loss function, written L, takes a guess and the actual outcome. A loss is like negative utility: lower is better, and a larger loss means a worse outcome. The zero-one loss is the simplest classification example: zero if the guess matches the truth, and one if it doesn’t.

  39. Michael

    But zero-one loss treats all mistakes equally, and that may not match the real costs. In the seizure example, diagnosing a seizure when there isn’t one may use staff time and resources. Missing a real seizure could prevent the newborn from receiving needed attention and could have much worse consequences.

  40. Simon

    That motivates an asymmetric loss: the cost of guessing plus one when the truth is minus one can differ from the cost of guessing minus one when the truth is plus one. How to balance those costs is an important application-specific decision. The loss should reflect what matters in the situation, not just whether the answer was wrong.

  41. Michael

    If n new examples arrived, we could calculate an average loss over them: for each new point, compare the classifier’s prediction h of x with its observed label y, then average the losses. We call that test error when we’re evaluating on held-out or future data. It directly describes the kind of performance we care about.

  42. Simon

    The catch is that truly future examples—and their labels—aren’t available yet. We can’t calculate performance on the next 500 newborns before they arrive and their outcomes are known. So we need ways to reason about future performance without having the future data in hand; that question remains for later in the course.

  43. Michael

    A quantity we can calculate now is training error: the average loss on the n examples in D sub n. It compares each training label with the prediction made by h on that example. Training error is a useful quantity to study, but it isn’t automatically the same as performance on future data.

  44. Simon

    Training error lets us compare two classifiers: if h has lower training error than h tilde, we prefer h according to this particular measure. In principle, we might try to choose the classifier in a class with the smallest training error. But finding that best classifier can be computationally difficult, so we’ll need to explore practical learning methods.

  45. Michael

    That brings us to a distinction between a classifier and a learning algorithm. A classifier takes one feature vector x and returns one label. It doesn’t need a dataset as an input. A learning algorithm takes an entire dataset D sub n and returns a classifier, ideally one that will predict well.

  46. Simon

    Give the learning algorithm a different dataset and it may return a different classifier. The algorithm itself is a function from datasets to classifiers, whereas the classifier it produces is a function from feature vectors to labels. They act on different kinds of inputs.

  47. Michael

    Here’s a deliberately simple example. Imagine someone has already generated a trillion candidate linear classifiers by sampling different lines. Our learning algorithm considers the first k candidates, calculates each one’s training error on the input dataset, and returns the candidate with the smallest training error.

  48. Simon

    The value k is a hyperparameter: it changes how the learning algorithm operates but isn’t part of the input dataset. That’s different from theta and theta naught, which are parameters specifying a particular classifier. The algorithm finds the index j that minimizes the training error among the first k candidates, then returns classifier j.

  49. Michael

    If k equals one, there’s no real choice: the algorithm returns the first classifier. If k equals two, it compares the first and second and returns whichever has lower training error. Therefore, the training error with k equal to two can’t be greater than with k equal to one; it may be lower, or it may tie.

  50. Simon

    More generally, as k grows, the algorithm has more candidates to choose from, so its minimum training error can only stay the same or decrease. But that fact alone doesn’t establish that it will do better on future data. Choosing a classifier with low training error and evaluating whether it generalizes are separate concerns.

  51. Michael

    That’s a useful first map of the subject: we have data, hypotheses, hypothesis classes, losses, error measures, and learning algorithms that turn datasets into classifiers. The simple search over sampled lines helps define these ideas, but it isn’t presented as the final or necessarily best method.

  52. Simon

    The questions we’ll keep pursuing are what makes a prediction good, how to choose a classifier effectively, and how to assess performance when the future data we care about hasn’t arrived yet. The first lecture has set up those questions; the deeper answers come as we work through the course.

  53. Michael

    That’s our starting point for machine learning: formalizing how data can support decisions, while staying clear-eyed about the limits of our methods and the consequences of their predictions. We’ll continue in lab this week, and meet again for lecture next Tuesday.

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent