1. Home
  2. Data Science
  3. Scikit-learn
  4. In sklearn.metrics.confusion_matrix(y_true, y_pred), how…

Added 30 Nov -0001

In sklearn.metrics.confusion_matrix(y_true, y_pred), how is the matrix laid out?

  1. Rows are predicted classes and columns are true classes, in label order
  2. Rows are true classes and columns are predicted ones, ordered by frequency
  3. Rows are predicted classes and columns are true ones, sorted by support
  4. Rows are the true classes and columns are predicted ones, in label order Correct answer

Correct answer

D. Rows are the true classes and columns are predicted ones, in label order

19 views

MCQSEXAM

Explanation

confusion_matrix returns C[i][j] as the number of samples with true label i and predicted label j, so rows are actual classes and the diagonal counts correct predictions. Reading it transposed is a common error that swaps precision and recall. Pass labels= to fix the order when some classes are missing from a split.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is D? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Scikit-learn MCQs

Practise all Scikit-learn MCQs

Similar MCQs