FEA Add d2_log_loss_score#28351
Conversation
|
@lorentzenchr Could you kindly have a look to see if this formulation looks okay? If this looks correct then we can add the general case which handles more than one class and also all the corresponding things required like the addition of documentation, more tests etc. step by step. |
lorentzenchr
left a comment
There was a problem hiding this comment.
This goes in the right direction.
|
@lorentzenchr Would it make sense to include this in 1.5? |
jeremiedbb
left a comment
There was a problem hiding this comment.
Looks good, just a few minor comments.
sklearn/metrics/_classification.py
Outdated
| if sample_weight is not None: | ||
| weights = np.asarray(sample_weight) | ||
| else: | ||
| weights = np.ones(shape=len(y_true), dtype=np.int64) |
There was a problem hiding this comment.
| if sample_weight is not None: | |
| weights = np.asarray(sample_weight) | |
| else: | |
| weights = np.ones(shape=len(y_true), dtype=np.int64) | |
| weights = _check_sample_weight(sample_weight, y_true) |
| The :func:`d2_log_loss_score` function implements the special case | ||
| of D² with the log loss, see :ref:`log_loss`, i.e.: | ||
|
|
||
| .. math:: | ||
|
|
||
| \text{dev}(y, \hat{y}) = \text{log_loss}(y, \hat{y}). | ||
|
|
||
| Here are some usage examples of the :func:`d2_log_loss_score` function:: |
There was a problem hiding this comment.
Please mention that the y_null for the log loss is the per-class frequency, here or in the introdction paragraph above where the y_null for other losses are described.
sklearn/metrics/_classification.py
Outdated
| y_true : array-like or label indicator matrix | ||
| The actuals labels for the n_samples samples. | ||
|
|
||
| y_pred : array-like of float, shape = (n_samples, n_classes) or (n_samples,) |
There was a problem hiding this comment.
| y_pred : array-like of float, shape = (n_samples, n_classes) or (n_samples,) | |
| y_pred : array-like of shape (n_samples, n_classes) or (n_samples,) |
| |details-end| | ||
|
|
||
| |details-start| | ||
| **D² log loss score** |
There was a problem hiding this comment.
This is under „regression metrics“ but it’s a classification metric. Wen can fix that in another PR as it involves a larger change of the user guide.
There was a problem hiding this comment.
Haha you spot it as well. I assumed I would just merge it discretly and open an issue right after 😄
Reference Issues/PRs
Fixes: #20943
What does this implement/fix? Explain your changes.
Any other comments?