Implement slope for Pseduo-Huber. (#7727)
* Add objective and metric. * Some refactoring for CPU/GPU dispatching using linalg module.
This commit is contained in:
@@ -105,38 +105,6 @@ struct LogisticRegression {
|
||||
static ObjInfo Info() { return {ObjInfo::kRegression, false}; }
|
||||
};
|
||||
|
||||
struct PseudoHuberError {
|
||||
XGBOOST_DEVICE static bst_float PredTransform(bst_float x) {
|
||||
return x;
|
||||
}
|
||||
XGBOOST_DEVICE static bool CheckLabel(bst_float) {
|
||||
return true;
|
||||
}
|
||||
XGBOOST_DEVICE static bst_float FirstOrderGradient(bst_float predt, bst_float label) {
|
||||
const float z = predt - label;
|
||||
const float scale_sqrt = std::sqrt(1 + std::pow(z, 2));
|
||||
return z/scale_sqrt;
|
||||
}
|
||||
XGBOOST_DEVICE static bst_float SecondOrderGradient(bst_float predt, bst_float label) {
|
||||
const float scale = 1 + std::pow(predt - label, 2);
|
||||
const float scale_sqrt = std::sqrt(scale);
|
||||
return 1/(scale*scale_sqrt);
|
||||
}
|
||||
static bst_float ProbToMargin(bst_float base_score) {
|
||||
return base_score;
|
||||
}
|
||||
static const char* LabelErrorMsg() {
|
||||
return "";
|
||||
}
|
||||
static const char* DefaultEvalMetric() {
|
||||
return "mphe";
|
||||
}
|
||||
static const char* Name() {
|
||||
return "reg:pseudohubererror";
|
||||
}
|
||||
static ObjInfo Info() { return {ObjInfo::kRegression, false}; }
|
||||
};
|
||||
|
||||
// logistic loss for binary classification task
|
||||
struct LogisticClassification : public LogisticRegression {
|
||||
static const char* DefaultEvalMetric() { return "logloss"; }
|
||||
|
||||
Reference in New Issue
Block a user