'How can I get a probability from a binary classification? Can I treat a binary output like a continuous to calculate a probability?

I have a binary classification task with classes 0 and 1, I am interested in the probability of an input to be in one class, I have tried with Probabilistic neural networks but i just get 0s and 1s. ¿does anyone know a algorithm to get both: The probability and the classification 1 or 0? Ps. I`m using python.

If I use a regression model with a Sigmoid function to keep the result between 0 and 1, Can I interpret the output as a probability?



Solution 1:[1]

Try logistic regression. It will give you a probability between 0 and 1, and you can choose an arbitrary threshold (e.g., 0.5) to give you a classification.

https://en.wikipedia.org/wiki/Logistic_regression

https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aku