create mae

This commit is contained in:
Zheng RuiFeng
2016-02-24 11:15:31 +08:00
parent d063eaccb1
commit 2c7c27e297
2 changed files with 14 additions and 0 deletions

View File

@@ -72,6 +72,15 @@ struct EvalRMSE : public EvalEWiseBase<EvalRMSE> {
}
};
struct EvalMAE : public EvalEWiseBase<EvalMAE> {
const char *Name() const override {
return "mae";
}
inline static float EvalRow(float label, float pred) {
return std::abs(label - pred);
}
};
struct EvalLogLoss : public EvalEWiseBase<EvalLogLoss> {
const char *Name() const override {
return "logloss";
@@ -114,6 +123,10 @@ XGBOOST_REGISTER_METRIC(RMSE, "rmse")
.describe("Rooted mean square error.")
.set_body([](const char* param) { return new EvalRMSE(); });
XGBOOST_REGISTER_METRIC(MAE, "mae")
.describe("Mean absolute error.")
.set_body([](const char* param) { return new EvalMAE(); });
XGBOOST_REGISTER_METRIC(LogLoss, "logloss")
.describe("Negative loglikelihood for logistic regression.")
.set_body([](const char* param) { return new EvalLogLoss(); });