[MRG] Implements Multiclass hinge loss

Implements multiclass hinge loss. Fixes #3451 
$ git grep '\\$' | grep '\.py: *if '
doc/sphinxext/gen_rst.py:        if not os.path.exists(first_image_file) or
\
doc/sphinxext/numpy_ext/numpydoc.py:    if app.config.numpydoc_edit_link
and hasattr(obj, '__name__') and \
sklearn/hmm.py:        if hasattr(self, 'n_symbols') and \
sklearn/linear_model/base.py:    if hasattr(precompute, '__array__') \
sklearn/mixture/gmm.py:                if i > 0 and abs(log_likelihood[-1]
- log_likelihood[-2]) < \

On 21 September 2014 22:42, Saurabh Jha <notifications@github.com> wrote:

>  In sklearn/metrics/classification.py:
>
> > -    lbin = LabelBinarizer(neg_label=-1)
> > -    y_true = lbin.fit_transform(y_true)[:, 0]
> > -
> > -    if len(lbin.classes_) > 2 or (pred_decision.ndim == 2
> > -                                  and pred_decision.shape[1] != 1):
> > -        raise ValueError("Multi-class hinge loss not supported")
> > -    pred_decision = np.ravel(pred_decision)
> > -
> > -    try:
> > -        margin = y_true * pred_decision
> > -    except TypeError:
> > -        raise TypeError("pred_decision should be an array of floats.")
> > +
> > +    y_lab = np.unique(y_true)
> > +    if len(y_lab) > 2:
> > +        if labels is None and len(
>
> Your first solution is nice. I thought '\' is not used anywhere else in
> scikit-learn. I am committing code that uses the first one. Thanks!
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/scikit-learn/scikit-learn/pull/3607/files#r17825014>.
>