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

poisson log loss #20

Open
spedygiorgio opened this issue Apr 27, 2017 · 2 comments
Open

poisson log loss #20

spedygiorgio opened this issue Apr 27, 2017 · 2 comments

Comments

@spedygiorgio
Copy link

The following function could be a nice add for the package, since it implements the Poisson Log Loss in Rcpp (also thanks to SO ) and originally written in R in the MLmetrics package:

#include <Rcpp.h>
#include <math.h>
using namespace Rcpp;

// [[Rcpp::export]]
double poissonLogLoss(NumericVector predicted, NumericVector actual) {
  NumericVector temp, y_pred_new;
  double out; 
  const double eps=1e-15;

  y_pred_new=pmax(predicted,eps);
  temp = log(gamma(actual + 1)) + y_pred_new - log(y_pred_new)*actual;
  out=mean(temp); // using sugar implementation
  return out;
}
@JackStat
Copy link
Owner

@spedygiorgio Can you open a pull req for this. It would be a great addition. You can also get credit for the work. Let me know
Tyler

@spedygiorgio
Copy link
Author

@JackStat I hope to pull it tomorrow

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

No branches or pull requests

2 participants