Reputation: 87
I am trying to use the predict_proba(X) from scikit learn to output probabilities, it returns a 2-d array with the probability of each class.
My understanding is that the function return logits, I am trying to convert them to Sigmoid using the following function
def sigmoid(x):
return 1 / (1 + math.exp(-x))
If the 2-D array is of the form
probability class 1 | probability class 2 |
---|---|
0.8 | 0.2 |
0.7 | 0.3 |
What is the logic to just return a single probability based on these rows and the sigmoid function?
Thank you in advance
Upvotes: 0
Views: 1173
Reputation: 743
predict_proba() gives you the probabilities for the target (0 and 1 in your case) in array form. The number of probabilities for each row is equal to the number of categories in target variable (assuming 2 in your case).
So if you want only probabilities of getting the output as only 1, then you could do
model.predict_proba(test)[:,1]
Alternately, if you want only the probabilities of getting zero then
model.predict_proba(test)[:,0]
Upvotes: 2