4#ifndef XGBOOST_OBJECTIVE_REGRESSION_LOSS_H_
5#define XGBOOST_OBJECTIVE_REGRESSION_LOSS_H_
11#include "../common/math.h"
14#include "xgboost/task.h"
28 static const char* LabelErrorMsg() {
return ""; }
29 static const char* DefaultEvalMetric() {
return "rmse"; }
31 static const char* Name() {
return "reg:squarederror"; }
32 static ObjInfo Info() {
return {ObjInfo::kRegression,
true,
false}; }
39 predt = fmaxf(predt, -1 + 1e-6);
40 return (std::log1p(predt) - std::log1p(label)) / (predt + 1);
43 predt = fmaxf(predt, -1 + 1e-6);
44 float res = (-std::log1p(predt) + std::log1p(label) + 1) / std::pow(predt + 1, 2);
45 res = fmaxf(res, 1e-6f);
49 static const char* LabelErrorMsg() {
50 return "label must be greater than -1 for rmsle so that log(label + 1) can be valid.";
52 static const char* DefaultEvalMetric() {
return "rmsle"; }
54 static const char* Name() {
return "reg:squaredlogerror"; }
56 static ObjInfo Info() {
return ObjInfo::kRegression; }
67 const float eps = 1e-16f;
68 return fmaxf(predt * (1.0f - predt), eps);
71 CHECK(base_score > 0.0f && base_score < 1.0f)
72 <<
"base_score must be in (0,1) for logistic loss, got: " << base_score;
73 return -logf(1.0f / base_score - 1.0f);
75 static const char* LabelErrorMsg() {
return "label must be in [0,1] for logistic regression"; }
76 static const char* DefaultEvalMetric() {
return "rmse"; }
78 static const char* Name() {
return "reg:logistic"; }
80 static ObjInfo Info() {
return ObjInfo::kRegression; }
85 static const char* DefaultEvalMetric() {
return "logloss"; }
86 static const char* Name() {
return "binary:logistic"; }
87 static ObjInfo Info() {
return ObjInfo::kBinary; }
98 const float eps = 1e-16f;
100 return fmaxf(predt * (1.0f - predt), eps);
103 static const char* DefaultEvalMetric() {
return "logloss"; }
105 static const char* Name() {
return "binary:logitraw"; }
107 static ObjInfo Info() {
return ObjInfo::kRegression; }
#define XGBOOST_DEVICE
Tag function as usable by device.
Definition base.h:64
Copyright 2015-2023 by XGBoost Contributors.
defines console logging options for xgboost. Use to enforce unified print behavior.
XGBOOST_DEVICE float Sigmoid(float x)
calculate the sigmoid of the input.
Definition math.h:28
namespace of xgboost
Definition base.h:90
float bst_float
float type, used for storing statistics
Definition base.h:97
header to handle OpenMP compatibility issues
A struct returned by objective, which determines task at hand. The struct is not used by any algorith...
Definition task.h:24
Definition regression_loss.h:20
Definition regression_loss.h:84
Definition regression_loss.h:91
Definition regression_loss.h:60
Definition regression_loss.h:35