scikit-learn/scikit-learn — pull request #886 by amueller (2012-06-03 22:23:47+00:00)
Title: MRG: enh in OvR, use constant predictor if one class always present or never.

Closes #559.

This solution seemed easier than working with the matrix produced by LabelBinarizer.
Another possibility would be to modify LabelBinarizer to take care of the issue.

Both issues have their caveats:
this solution:
If someone iterates over the estimators and expects them to be of a certain type, they will run into trouble
(for example if they expect them all to have a coef to find some feature importance).

LabelBinarizer solution:
The number of estimators is unexpected and the mapping between classes and estimators is somewhere hidden in the LabelBinarizer, where the user will probably not suspect it.

Oh and the *trivial* solution by modifying ``fit_ovr`` and ``predict_ovr`` has the same drawbacks as doing it in label binarizer, only it is more ugly.