Issue
I have created an algorithm that returns a binary classification as probabilities, here is the output of a prediction:
pred = [0.0139619, 0.986038]
What I need to do now is average these two values and get a scalar between 0 and 1 that summarizes the predicted probabilities, just as an example:
averaged_pred = 0.974 # In range 0 to 1
How can I implement this?
Solution
It's very hard to understand what you actually are trying to do as there are many other variables that we should know about. For example, which value in the array is true, and which is false.
I will try my best to explain, assuming 0.0139619 is True:
In binary classification, you have data for true, and for false. Now in binary, true is represented as 1, and false is represented as 0, hence why binary is only 0s and 1s.
Now, construct a probability distribution with these values. Well, for true, we don't have a number, but we do have a value; true, and in binary, true is 1. So, we divide the value, 1, by the probability as a percentage. This would leave us with 1 / 98.6038. We can now do the same for false. False in binary is 0, so we can do 0 / 1.39619. Finally, because we are trying to get the average, we add them both together. This gives us the average probability between 2 binomial values.
To do this in python, we simply need to create a for loop:
pred = [0.0139619, 0.986038] #The Probablility From Binary Classification
quantity = [1, 0] #The Values Of The Widgits, Here It Is True And False
for i in pred:
indx = pred.index(i)
prob_individual += (quantity[indx] / (i * 100))
print(prob_individual)
Basically, this finds out what the value of pred is and what the value of quantity is. It does the calculation and adds it each time to a variable called prob_individual. At the end it prints this value.
Answered By - The Pilot Dude
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.