0
votes

I have a binary classification problem and I would like to get the predicted class probabilities for both the classes. Something like this...

0 0.25 0.15
0  0.2 0.19
1 0.19 0.25

Each line contains the item's actual class, the predicted probability for membership of class-0, and the predicted probability for membership of class-1.I could get the predicted probability for class-1 using the predict function

predict(mod,newx=ValidX,type="response")

Please advice on how to get the probabilities for class-0. Thanks in advance.

2
Subtract from 1 the result?Hugh

2 Answers

1
votes

Since this is a binary classification, the Prob(C2) = 1 - Prob(C1)

1
votes

I have no experience with R, but this seems more like a general machine learning question to me. With regards to your problem (i.e binary classification with a single output), the answer provided by tyumru is probably the one you should consider.

That being said, some machine learning algorithms will output the probability for each class out of the box. For instance, if you use a neural network with the softmax activation function on the output layer, you will get a probability per class.