Logistic Regression & Naive Bayes Questions with Answers

7 practice questions on Logistic Regression & Naive Bayes (Machine Learning) with answers and step-by-step solutions. Try 7 samples below, then practise all 7 free in the AptiNest app.

Sample questions

Question 1Easy

Which loss is normally minimised when training logistic regression?

  1. Mean squared error with a linear output
  2. Binary cross-entropy (log loss)
  3. Hinge loss
  4. Gini impurity

Answer: B. Binary cross-entropy (log loss)

Explanation

Log loss is the negative log-likelihood of the labels and is convex for logistic regression.

Step-by-step solution

  1. Model gives p = P(y=1).
  2. Loss = -[y log p + (1-y) log(1-p)].
  3. Minimise it by gradient descent.

Why the other options are wrong

  • A. MSE with sigmoid makes a non-convex surface; log loss is the standard.
  • C. Hinge loss belongs to SVMs.
  • D. Gini is a decision-tree split criterion.

Question 2Easy

Logistic regression's decision boundary with a 0.5 threshold is

  1. A circle
  2. Always vertical
  3. Linear in the feature space
  4. A tree of splits

Answer: C. Linear in the feature space

Explanation

The boundary is where w.x + b = 0, which is a line, plane or hyperplane.

Step-by-step solution

  1. p = 0.5 when z = 0.
  2. z = w.x + b = 0 is linear.
  3. So the boundary is a hyperplane.

Why the other options are wrong

  • A. A circle needs squared features or a non-linear model.
  • B. The boundary depends on the learned weights.
  • D. That describes decision trees.

Question 3Easy

Despite its name, logistic regression is mainly used for

  1. Regression of continuous values
  2. Clustering
  3. Dimensionality reduction
  4. Classification

Answer: D. Classification

Explanation

Logistic regression applies a sigmoid to a linear combination of features to output a class probability.

Step-by-step solution

  1. Linear score z = w.x + b.
  2. Sigmoid maps z to (0,1).
  3. Threshold gives the class.

Why the other options are wrong

  • A. It models the probability of a class, not a continuous target.
  • B. Clustering is unsupervised; logistic regression needs labels.
  • C. That is PCA and similar methods.

Question 4Easy

What does the 'naive' assumption in Naive Bayes state?

  1. Features are conditionally independent given the class
  2. All features have the same variance
  3. Classes are equally likely
  4. Every feature follows a normal distribution with zero mean and unit variance

Answer: A. Features are conditionally independent given the class

Explanation

P(x1..xn | class) is factored as the product of P(xi | class), which is rarely exactly true but works well in practice.

Step-by-step solution

  1. Bayes rule needs P(x | class).
  2. Assume features independent given class.
  3. So the likelihood becomes a product.

Why the other options are wrong

  • B. Variance is not assumed equal in this way.
  • C. Priors can differ; that is not the naive assumption.
  • D. Only Gaussian NB assumes normality, and not zero mean.

Question 5Easy

Laplace (add-one) smoothing in Naive Bayes is used to

  1. Avoid zero probabilities for feature values unseen in training
  2. Speed up training
  3. Remove outliers
  4. Balance the classes by duplicating the minority samples

Answer: A. Avoid zero probabilities for feature values unseen in training

Explanation

If a word never appeared with a class, its likelihood is 0 and wipes out the whole product; adding 1 to counts prevents that.

Step-by-step solution

  1. Unseen value gives count 0.
  2. Product of likelihoods becomes 0.
  3. Add 1 to every count to avoid this.

Why the other options are wrong

  • B. It adds a small count; it does not make training faster.
  • C. Smoothing deals with zero counts, not outliers.
  • D. Class balance needs resampling or weights, not smoothing.

Question 6Medium

In logistic regression, if the linear score z = 0, what is the predicted probability of class 1?

  1. 0
  2. 0.5
  3. 1
  4. Undefined

Answer: B. 0.5

Explanation

sigmoid(0) = 1/(1+e^0) = 0.5.

Step-by-step solution

  1. sigmoid(z) = 1/(1+e^-z).
  2. z = 0 gives e^0 = 1.
  3. 1/2 = 0.5.

Why the other options are wrong

  • A. Sigmoid never reaches exactly 0 for finite z.
  • C. Sigmoid never reaches exactly 1 for finite z.
  • D. Sigmoid is defined for every real z.

Question 7Hard

In a spam filter, P(spam)=0.4, P(word|spam)=0.5, P(word|not spam)=0.1. Using Bayes' rule, P(spam|word) equals

  1. 0.5
  2. 0.4
  3. 0.769
  4. 0.833

Answer: C. 0.769

Explanation

Numerator 0.5*0.4 = 0.20. Denominator 0.20 + 0.1*0.6 = 0.26. 0.20/0.26 = 0.769.

Step-by-step solution

  1. P(word) = 0.5*0.4 + 0.1*0.6 = 0.26.
  2. P(spam|word) = 0.20/0.26.
  3. = 0.769.

Why the other options are wrong

  • A. This is just P(word|spam), ignoring the prior and the other class.
  • B. This is only the prior probability.
  • D. This assumes equal priors: 0.5/(0.5+0.1). The given prior of 0.4 pulls it down.

Practise all 7 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Machine Learning topics · All topics