Skip to content

Should sklearn include the Equal Error Rate metric? #15247

Open

Description

@vnherdeiro

Hi there,

I have recently looked into using sklearn for biometric security models. In this field one of the most common metrics is equal error rate (EER). Surprisingly it's not out of the box in sklearn despite the long list of scores and metrics shipped with https://scikit-learn.org/stable/modules/classes.html

I have coded a piece of code to compute the EER in different contexts, such as optimizing hyperparameters and model space to minimize it. Is it worth cleaning it and including it in a pull request?

Activity

  1. vnherdeiro commented on Oct 15, 2019

    @vnherdeiro
    ContributorAuthor

    Yeah I saw these examples, and refactored them to this code:

    from sklearn.metrics import make_scorer, roc_curve
    from scipy.optimize import brentq
    from scipy.interpolate import interp1d
    
    def calculate_eer(y_true, y_score):
        '''
        Returns the equal error rate for a binary classifier output.
        '''
        fpr, tpr, thresholds = roc_curve(y_true, y_score, pos_label=1)
        eer = brentq(lambda x : 1. - x - interp1d(fpr, tpr)(x), 0., 1.)
        return eer

    From which you can use a sklearn scorer with:

    make_scorer(calculate_eer, greater_is_better=False, needs_proba=True)

    For instance used in grid search optimization:

    GridSearchCV( LogisticRegression(), param_grid=param_grid, cv=n_folds, scoring=make_scorer(calculate_eer, greater_is_better=False, needs_proba=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions