scikit-learn/scikit-learn — Issue #389: implement predict_scores proposal
Author: mblondel
Created: 2011-10-09 14:32:26+00:00
State: open

`predict_scores` is a method to unify predict methods which output a score such as `decision_function`, `predict_proba`, etc. It should return a `[n_samples, n_classes]` array containing scores (the bigger, the more likely to choose the corresponding class).

The method signature should be `predict_scores(self, X, score="margin|proba|log_proba|...")` or maybe `predict_scores(self, X, score_func="margin|proba|log_proba|...")`.

TODO list (please comment):

* Add a `PredictorMixin` which implements `predict_scores` (just calling the underlying `decision_function`, `predict_proba`, etc if present and raising a `NotImplementedError` if not)

* Add `PredictorMixin` to objects which have a `decision_function` or a `predict_proba` method

* Currently, `decision_function` returns an array of shape `[n_samples, 1]` in the binary case. Break API to return `[n_samples, 2]` or handle `decision_function` separately in `PredictorMixin.predict_scores`.

* Override `predict_scores` in `KMeans` and other clustering modules to return the opposite of the distances to the clusters.

* Implement `predict_log_proba` as the log of `predict_proba` in `PredictorMixin` (?)

* Change `multiclass` module to internally use `predict_scores` (currently it looks for `decision_function` and `predict_proba`)

* Add `predict_scores` to the multiclass estimators. `OneVsOneClassifier` and `OutputCodeClassifier` will need to override `predict_scores`