0

I have something to ask.

I've trained my sklearn Logistic Regression classifier with 10 thousand training data in Python. I have 2 thousand test data and I use accuracy score to show the accuracy and confusion matrix.. but both only show overall accuracy of all test data.

what I want is for example:

Test data 1: "abc"

Accuracy of class A given test data: 80%

Accuracy of class B given test data: 10%

Accuracy of class C given test data: 10%

Test data 2: "def"

Accuracy of class A given test data: 50%

Accuracy of class B given test data: 30%

Accuracy of class C given test data: 20%

and so on for the rest of all the test data. and I want to show it in table like this. example

is it possible to that using sklearn?

Indra
  • 49
  • 2
  • 11

1 Answers1

0

Based on the example provided by you, I think what you are asking is probabilistic prediction for each of your test data points. You can do it easily by using the predict_proba method of the LogisticRegression class (http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html#sklearn.linear_model.LogisticRegression.predict_proba). This will give you the probabilities of each of the classes. The returned matrix should have a size of 2000 x 3 in your case. You can multiply them by 100 to get the necessary percentages for each of your class.

Hope that helps.

Abhinav Arora
  • 3,281
  • 18
  • 20