-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
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;
}
Metadata
Metadata
Assignees
Labels
No labels