-
-
Notifications
You must be signed in to change notification settings - Fork 46k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def hinge_loss(y_true: np.ndarray, pred: np.ndarray) -> float: | |
def hinge_loss(y_true: np.ndarray, y_pred: np.ndarray) -> float: |
Please rename for consistency
#10637 (comment) also applies here. |
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.. |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if np.array_equal(np.sort(np.unique(y_true)), np.array([-1, 1])) is False: | |
if np.any((y_true != 1) & (y_true != -1)): |
This should do the same thing (check if any entry is neither 1 or -1)
* Adds exponential moving average algorithm * code clean up * spell correction * Modifies I/O types of function * Replaces generator function * Resolved mypy type error * readibility of code and documentation * Update exponential_moving_average.py * Adds hinge loss function * suggested doc and refactoring changes * refactoring --------- Co-authored-by: Christian Clauss <cclauss@me.com>
Describe your change:
Checklist: