21
21
22
22
import warnings
23
23
from functools import partial
24
- from numbers import Real
24
+ from numbers import Real , Integral
25
25
26
26
import numpy as np
27
27
from scipy .sparse import csr_matrix , issparse
34
34
from ..utils .multiclass import type_of_target
35
35
from ..utils .extmath import stable_cumsum
36
36
from ..utils .sparsefuncs import count_nonzero
37
- from ..utils ._param_validation import validate_params , StrOptions
37
+ from ..utils ._param_validation import validate_params , StrOptions , Interval
38
38
from ..exceptions import UndefinedMetricWarning
39
39
from ..preprocessing import label_binarize
40
40
from ..utils ._encode import _encode , _unique
@@ -1445,6 +1445,16 @@ def _check_dcg_target_type(y_true):
1445
1445
)
1446
1446
1447
1447
1448
+ @validate_params (
1449
+ {
1450
+ "y_true" : ["array-like" ],
1451
+ "y_score" : ["array-like" ],
1452
+ "k" : [Interval (Integral , 1 , None , closed = "left" ), None ],
1453
+ "log_base" : [Interval (Real , 0.0 , None , closed = "neither" )],
1454
+ "sample_weight" : ["array-like" , None ],
1455
+ "ignore_ties" : ["boolean" ],
1456
+ }
1457
+ )
1448
1458
def dcg_score (
1449
1459
y_true , y_score , * , k = None , log_base = 2 , sample_weight = None , ignore_ties = False
1450
1460
):
@@ -1461,11 +1471,11 @@ def dcg_score(
1461
1471
1462
1472
Parameters
1463
1473
----------
1464
- y_true : ndarray of shape (n_samples, n_labels)
1474
+ y_true : array-like of shape (n_samples, n_labels)
1465
1475
True targets of multilabel classification, or true scores of entities
1466
1476
to be ranked.
1467
1477
1468
- y_score : ndarray of shape (n_samples, n_labels)
1478
+ y_score : array-like of shape (n_samples, n_labels)
1469
1479
Target scores, can either be probability estimates, confidence values,
1470
1480
or non-thresholded measure of decisions (as returned by
1471
1481
"decision_function" on some classifiers).
@@ -1478,7 +1488,7 @@ def dcg_score(
1478
1488
Base of the logarithm used for the discount. A low value means a
1479
1489
sharper discount (top results are more important).
1480
1490
1481
- sample_weight : ndarray of shape (n_samples,), default=None
1491
+ sample_weight : array-like of shape (n_samples,), default=None
1482
1492
Sample weights. If `None`, all samples are given the same weight.
1483
1493
1484
1494
ignore_ties : bool, default=False
0 commit comments