1. Home
  2. Explore
  3. Computer Science
  4. Naive Bayes ML Lecture

Study methods

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

Naive Bayes ML Lecture

Speaker 1Speaker 2

Naive Bayes ML Lecture

3:22
0:00-3:22
  1. Corey

    Alright Anna, today we're diving into one of the first machine learning algorithms from CS109: Naive Bayes. I'm excited because it's such a clean introduction to classification.

  2. Anna

    Me too, Corey. And the lecture started with a beautiful personal story about the professor's daughter and cochlear implants, reminding us how technology can change lives. But then we got into the math.

  3. Corey

    Right, the core idea: we have training data with inputs and outputs. The inputs are features like whether a user liked certain movies, and the output is a label like whether they like a target movie. The goal is to build a classifier that predicts the label from the features.

  4. Anna

    And to do that, we need to estimate parameters for a probabilistic model. The lecture reminded us of two approaches: Maximum Likelihood Estimation and Maximum a Posteriori estimation. MLE picks parameter values that make the data most likely, while MAP adds a prior to also consider how likely the parameters themselves were before seeing data.

  5. Corey

    Exactly. For a Bernoulli like estimating the probability of liking a movie, MLE is just counting fractions. MAP with a Beta(2,2) prior – the LaPlace prior – adds one imaginary success and one imaginary failure, so you never get probabilities of 0 or 1. That's important because multiplying by zero in Naive Bayes kills everything.

  6. Anna

    Good point. Now, the first attempt at a classifier was Brute Force Bayes. The idea: for a given input X, compute the probability of each possible output Y given X, and pick the Y with the highest probability. That's the ARG MAX formulation.

  7. Corey

    Right, and we can use Bayes' rule to flip that into P(X|Y) times P(Y), dropping the denominator because it's constant in the ARG MAX. That works fine with one feature – you just need a few conditional probabilities. But when you have many features, say 100 binary features, the number of parameters explodes to 2^101 – more than atoms in the universe.

  8. Anna

    That's the exponential problem. So computer scientists made a bold assumption: the features are conditionally independent given the output. That's the Naive Bayes assumption. It's almost certainly false – if you like one Star Wars movie, you're more likely to like another – but it makes the math tractable.

  9. Corey

    Yes, and it reduces the joint probability P(X|Y) to a product of individual probabilities P(X_i|Y). So the number of parameters becomes linear in the number of features. Training is just counting: estimate P(Y) and each P(X_i|Y) from the data. MLE uses raw counts, MAP adds LaPlace smoothing to avoid zeros.

  10. Anna

    And then classification for a new example: you compute the product of P(Y) and all the P(X_i|Y) for each possible Y, and pick the Y that gives the highest value. Often we take logs to avoid numerical underflow, since probabilities are tiny.

  11. Corey

    The lecture also covered evaluation. You hold out a test set with known labels, then measure accuracy, precision, and recall. Precision is about not calling a real email spam; recall is about catching all spam. Naive Bayes was famously used for spam filtering at Google and worked well because the independence assumption, though wrong, was good enough.

  12. Anna

    So the big takeaways: Naive Bayes is a simple, fast classifier based on counting and conditional independence. It's a great first machine learning algorithm, and you'll implement it on the final assignment. Any questions before we wrap?

  13. Corey

    I think we've covered all the essentials. Let's leave it here – and happy Thanksgiving!

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent