Scikit-learn Ridge classifier: extracting class probabilities

Madison May

I'm currently using sklearn's Ridge classifier, and am looking to ensemble this classifier with classifiers from sklearn and other libraries. In order to do this, it would be ideal to extract the probability that a given input belongs to each class in a list of classes. Currently, I'm zipping the classes with the output of model.decision_function(x), but this returns the distance from the hyperplane as opposed to a straightforward probability. These distance values vary from around -1 to around 1.

distances = dict(zip(clf.classes_, clf.decision_function(x)[0]))  

How can I convert these distances to a more concrete set of probabilities (a series of positive values that sum to 1)? I'm looking for something like clf.predict_proba() that is implemented for the SVC in sklearn.

Madison May

Further exploration lead to using the softmax function.

d = clf.decision_function(x)[0]
probs = np.exp(d) / np.sum(np.exp(d))

This guarantees a 0-1 bounded distribution that sums to 1.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Scikit-learn Ridge classifier: extracting class probabilities

From Dev

scikit-learn Ridge Regression UnboundLocalError

From Dev

Coefficient paths for Ridge Regression in scikit-learn

From Dev

Python Scikit-learn Perceptron Output Probabilities

From Dev

How to get most informative features for scikit-learn classifier for different class?

From Dev

Evaluating convergence of SGD classifier in scikit learn

From Dev

Evaluating convergence of SGD classifier in scikit learn

From Dev

How to set the learning rate in scikit-learn's ridge regression?

From Dev

Converting LinearSVC's decision function to probabilities (Scikit learn python )

From Dev

Scikit-Learn: How to retrieve prediction probabilities for a KFold CV?

From Dev

Confusing probabilities of the predict_proba of scikit-learn's svm

From Dev

Scikit-Learn: How to retrieve prediction probabilities for a KFold CV?

From Dev

scikit-learn - multinomial logistic regression with probabilities as a target variable

From Dev

What is the theorical foundation for scikit-learn dummy classifier?

From Dev

Converting JPG images for input to scikit learn SVM classifier

From Dev

How to get all alpha values of scikit-learn SVM classifier?

From Dev

scikit-learn get certainty of classification / score of the classifier for the chosen category

From Dev

Does scikit learn include a Naive Bayes classifier with continuous inputs?

From Dev

Post-process classifier output in scikit learn Pipeline

From Dev

combine two different classifier result in scikit-learn python

From Dev

Plot Confusion Matrix with scikit-learn without a Classifier

From Dev

How to upgrade the classifier to the latest version of scikit-learn

From Dev

Converting JPG images for input to scikit learn SVM classifier

From Dev

Ridge Regression: Scikit-learn vs. direct calculation does not match for alpha > 0

From Dev

Why does GridSearchCV on an SVC in scikit-learn produce different probabilities given identical inputs?

From Dev

Why does GridSearchCV on an SVC in scikit-learn produce different probabilities given identical inputs?

From Dev

Multi-Class Logistic Regression in SciKit Learn

From Dev

How to use a fixed validation set (not K-fold cross validation) in Scikit-learn for a decision tree classifier/random forest classifier?

From Java

How to build re-usable scikit-learn pipeline for Random Forest Classifier?

Related Related

  1. 1

    Scikit-learn Ridge classifier: extracting class probabilities

  2. 2

    scikit-learn Ridge Regression UnboundLocalError

  3. 3

    Coefficient paths for Ridge Regression in scikit-learn

  4. 4

    Python Scikit-learn Perceptron Output Probabilities

  5. 5

    How to get most informative features for scikit-learn classifier for different class?

  6. 6

    Evaluating convergence of SGD classifier in scikit learn

  7. 7

    Evaluating convergence of SGD classifier in scikit learn

  8. 8

    How to set the learning rate in scikit-learn's ridge regression?

  9. 9

    Converting LinearSVC's decision function to probabilities (Scikit learn python )

  10. 10

    Scikit-Learn: How to retrieve prediction probabilities for a KFold CV?

  11. 11

    Confusing probabilities of the predict_proba of scikit-learn's svm

  12. 12

    Scikit-Learn: How to retrieve prediction probabilities for a KFold CV?

  13. 13

    scikit-learn - multinomial logistic regression with probabilities as a target variable

  14. 14

    What is the theorical foundation for scikit-learn dummy classifier?

  15. 15

    Converting JPG images for input to scikit learn SVM classifier

  16. 16

    How to get all alpha values of scikit-learn SVM classifier?

  17. 17

    scikit-learn get certainty of classification / score of the classifier for the chosen category

  18. 18

    Does scikit learn include a Naive Bayes classifier with continuous inputs?

  19. 19

    Post-process classifier output in scikit learn Pipeline

  20. 20

    combine two different classifier result in scikit-learn python

  21. 21

    Plot Confusion Matrix with scikit-learn without a Classifier

  22. 22

    How to upgrade the classifier to the latest version of scikit-learn

  23. 23

    Converting JPG images for input to scikit learn SVM classifier

  24. 24

    Ridge Regression: Scikit-learn vs. direct calculation does not match for alpha > 0

  25. 25

    Why does GridSearchCV on an SVC in scikit-learn produce different probabilities given identical inputs?

  26. 26

    Why does GridSearchCV on an SVC in scikit-learn produce different probabilities given identical inputs?

  27. 27

    Multi-Class Logistic Regression in SciKit Learn

  28. 28

    How to use a fixed validation set (not K-fold cross validation) in Scikit-learn for a decision tree classifier/random forest classifier?

  29. 29

    How to build re-usable scikit-learn pipeline for Random Forest Classifier?

HotTag

Archive