Skip to content

label_ranking_average_precision_score fails with sublists that are different sizes #8487

@josepablog

Description

@josepablog

The evaluation function label_ranking_average_precision_score fails when the sublists are of different sizes. Although I understand that this may be out of implementation convenience, I think this should be documented or at least a more adequate error should be raised.

import numpy as np
from sklearn.metrics import label_ranking_average_precision_score
y_true = np.array([[1, 0, 0], [0, 1]])  #sublists have 3 and 2  elements
y_score = np.array([[0.75, 0.5, 1], [1, 0.1]]) #sublists have 3 and  2 elements

 label_ranking_average_precision_score(y_true, y_score)       

This code fails with an exception:

ValueError: setting an array element with a sequence.

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