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.
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
.
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