Skip to content
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

Added log loss classification metric #199

Merged
merged 8 commits into from
Oct 26, 2023
Merged

Conversation

svarqq
Copy link
Contributor

@svarqq svarqq commented Oct 24, 2023

I based the implementation on sklearn's, with these main differences:

  • Dropped labels as an optional argument, since it's mostly useful for string labels. Note as a result, the class index or class number of a value in y_true is always given by its ordered ranking over all y_true values (in the language of sklearn, the class index is always inferred). For example, if y_true = [4, 0, 9, 4, 9] the indices would be [1, 0, 2, 1, 2].
  • No clipping of y_prob values to interval (eps, 1-eps). That means log(0) can be evaluated to -Inf which would immediately cause a return of Inf for the function. I chose to keep this possibility because it immediately signals either that the client got inputs wrong, or that they should retrain their model/forecaster. Plus, I did try clipping to the eps interval using Nx.Constants.epsilon/2 for the underlying floats in the tensor, and still got Inf's returned.

@josevalim josevalim merged commit cf8bbe4 into elixir-nx:main Oct 26, 2023
2 checks passed
@josevalim
Copy link
Contributor

💚 💙 💜 💛 ❤️

@svarqq svarqq deleted the log-loss branch October 26, 2023 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants