Machine Learning Basics

20% of all emails are spam. A certain word appears in 50% of spam emails and in 5% of non-spam emails. Which is closest to the probability that an email containing this word is spam?

  1. A0.10
  2. B0.50
  3. C0.71
Show answer and explanation

Answer: C. 0.71

By Bayes' theorem, P(spam | word) = P(word | spam) × P(spam) ÷ P(word). The numerator is 0.5 × 0.2 = 0.10, and the probability of containing the word is P(word) = 0.5 × 0.2 + 0.05 × 0.8 = 0.14, so the answer is 0.10 ÷ 0.14 ≈ 0.71. Naive Bayes classification performs this calculation by assuming that several words (features) are mutually independent within each class and multiplying their probabilities, and it has long been used for spam detection.

  • A. This is 0.5 × 0.2 = 0.10, the probability that an email is spam and contains the word, not divided by the probability of containing the word, 0.14.
  • B. This is P(word | spam), the probability that a spam email contains the word; the condition is the reverse of the required P(spam | word).
  • C. Correct. 0.10 ÷ 0.14 ≈ 0.71.
Practice this topic Back to topic

Related calculators

Books on Machine Learning Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Machine Learning Basics questions

  1. Which logic function cannot be represented by a simple perceptron consisting only of input and output layers (a single neuron that outputs 0 or 1 with a threshold)?
  2. In a three-class classification, the values input to the softmax function (logits) are 3, 1 and 0. About how many times the second class's output (probability) is the first class's output? Which is closest?
  3. A small neural network with inputs x₁ = 1 and x₂ = 2 has two hidden neurons h₁ = ReLU(x₁ + x₂ − 1) and h₂ = ReLU(x₁ − 2x₂ + 1), and output y = 2h₁ + 3h₂ + 1. What is the value of y?
  4. Let p be the probability that a model outputs for the correct class. Which of the following describes the cross-entropy loss −log p used to train classifiers?
  5. In gradient descent, the gradient of the loss ∂L/∂w at weight w = 2.0 is 0.5 and the learning rate is 0.1. What is the weight after one update?