-1

I have a dataset that I want to build a classification model for it. Given that scikit-learn provides confusion matrix implementation confusion_matrix(test_y, pred_r), I want to use it to calculate the accuracy of my model instead of directly using .predict. To do so, should I just look for false positive or true positive or the combination of both?

Thank you

Judas
  • 103
  • 1
  • 9
  • You can use the `.score()` method of the estimator instead of predict. Also, inbuilt `accuracy_score()` is also there which can calculate accuracy from `test_y` and `pred_r` – Vivek Kumar Oct 28 '17 at 17:40

1 Answers1

1

For finding the accuracy, just do this:

accuracy = (TP + TN)/Total
enterML
  • 2,110
  • 4
  • 26
  • 38
  • Thank you very much. `Total` here is the total samples in the dataset or just in the `test` dataset ( I use train_test_split)? – Judas Oct 28 '17 at 16:02
  • Total is the number of samples in the dataset on which you are doing the confusion matrix. It can be training set or the validation set. The number of samples changes accordingly – enterML Oct 28 '17 at 16:11