Classification in Depth with Scikit-Learn

# How Naive Bayes Classifier works?

Explore the fundamentals of the Naïve Bayes Classifier in this interactive lab, where you'll learn through examples and exercises how to apply this simple yet powerful algorithm for classification tasks, such as spam detection and sentiment analysis, using Python. Gain practical skills in model training and evaluation.
Project Created by

## Project Activities

All our Data Science projects include bite-sized activities to test your knowledge and practice in an environment with constant feedback.

All our activities include solutions with explanations on how they work and why we chose them.

codevalidated

### Bayes' theorem

Suppose we have a box of 20 marbles, 5 of which are red and 15 of which are blue. We randomly pick a marble from the box without looking, and we want to calculate the probability that the marble is red, given that it is round. Let's say we know that 3 out of the 5 red marbles are round, and 8 out of the 15 blue marbles are round.

``````# Prior probability of the marble being red
p_red = 0.25

# Likelihood probability of the marble being round given it is red
p_round_given_red = 0.6

# Likelihood probability of the marble being round given it is blue
p_round_given_blue = 8 / 15
``````

Let's use Bayes' theorem to calculate the probability of the marble being red given that it is round. Store the result in `p_red_given_round`.

codevalidated

### Performance evalution

Let's evaluate the performance of the classifier by comparing its predictions to the true labels of the testing data.

Store the accuracy in `accuracy_test`

multiplechoice

multiplechoice

multiplechoice

### Naïve Bayes is a type of unsupervised learning algorithm. True or False?

Project Created by

#### Verónica Barraza

This project is part of

## Classification in Depth with Scikit-Learn

Explore other projects