Skip to content

Getting error while calculating NDCG using sklearn #20119

Closed
@joshidp

Description

@joshidp

I'm trying to calculate the NDCG score for binary relevance:

from sklearn import metrics

# test 1
y_true = [[3]]
y_score = [[5]]
metrics.ndcg_score(y_true, y_score)

And getting error

ValueError: Only ('multilabel-indicator', 'continuous-multioutput', 'multiclass-multioutput') formats are supported. Got binary instead

Below code snippet is working which has more than 1 item. Please suggest why single item array is not working.

from sklearn import metrics

# test 1
y_true = [[6 ,5, 4, 3, 2, 1]]
y_score = [[120, -2, -6, -3,  2, 12]]
metrics.ndcg_score(y_true, y_score)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions