Uh oh!
There was an error while loading. Please reload this page.
Adds hinge loss function algorithm - #10628
Conversation
| import numpy as np | ||
| def hinge_loss(y_true: np.ndarray, pred: np.ndarray) -> float: |
There was a problem hiding this comment.
| defhinge_loss(y_true: np.ndarray, pred: np.ndarray) ->float: | |
| defhinge_loss(y_true: np.ndarray, y_pred: np.ndarray) ->float: |
Please rename for consistency
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
cclauss
commented
Oct 17, 2023
#10637 (comment) also applies here. |
PoojanSmart
commented
Oct 17, 2023
I can combine all loss function into single file, then you can review. We will do further modularization if required based on loss function category. Let me know your thoughts.. |
cclauss
commented
Oct 17, 2023
I will allow @tianyizheng02 to review this PR because he has already had several good suggestions. On this repo, if you |
| # Raise value error when y_true (encoded labels) have any other values | ||
| # than -1 and 1 | ||
| if np.array_equal(np.sort(np.unique(y_true)), np.array([-1, 1])) is False: |
There was a problem hiding this comment.
| ifnp.array_equal(np.sort(np.unique(y_true)), np.array([-1, 1])) isFalse: | |
| ifnp.any((y_true!=1) & (y_true!=-1)): |
This should do the same thing (check if any entry is neither 1 or -1)
Describe your change:
Checklist: