Skip to content

BUG: _SearchLight when 'scoring=roc_auc' & y not in (0, 1) #3697

@kingjr

Description

@kingjr

@kaichogami we missed a necessary feature when adding the scoring parameter to the SearchLight in the last PR: currently, we encounter an error if scoring='roc_auc' but y is not (0, 1):

import numpy as np
from mne.decoding.search_light import _SearchLight
from sklearn.linear_model import LogisticRegression

sl = _SearchLight(LogisticRegression(), scoring='roc_auc')
X = np.random.rand(100, 20, 2)
y = np.random.randint(0, 2, 100)
sl.fit(X, y)
sl.score(X, y)  # works

y = np.random.randint(2, 4, 100)
sl.fit(X, y)
sl.score(X, y)  # crashes

I suggest to add a sklearn.preprocessing.LabelEncoder() at fitting and use it before scoring. @agramfort do you think it's the right approach?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions