Merge pull request #860 from zhengruifeng/mae
Add "mean absolute error" to metrics
This commit is contained in:
commit
bb0d163d22
@ -80,6 +80,7 @@ Specify the learning task and the corresponding learning objective. The objectiv
|
|||||||
- User can add multiple evaluation metrics, for python user, remember to pass the metrics in as list of parameters pairs instead of map, so that latter 'eval_metric' won't override previous one
|
- User can add multiple evaluation metrics, for python user, remember to pass the metrics in as list of parameters pairs instead of map, so that latter 'eval_metric' won't override previous one
|
||||||
- The choices are listed below:
|
- The choices are listed below:
|
||||||
- "rmse": [root mean square error](http://en.wikipedia.org/wiki/Root_mean_square_error)
|
- "rmse": [root mean square error](http://en.wikipedia.org/wiki/Root_mean_square_error)
|
||||||
|
- "mae": [mean absolute error](https://en.wikipedia.org/wiki/Mean_absolute_error)
|
||||||
- "logloss": negative [log-likelihood](http://en.wikipedia.org/wiki/Log-likelihood)
|
- "logloss": negative [log-likelihood](http://en.wikipedia.org/wiki/Log-likelihood)
|
||||||
- "error": Binary classification error rate. It is calculated as #(wrong cases)/#(all cases). For the predictions, the evaluation will regard the instances with prediction value larger than 0.5 as positive instances, and the others as negative instances.
|
- "error": Binary classification error rate. It is calculated as #(wrong cases)/#(all cases). For the predictions, the evaluation will regard the instances with prediction value larger than 0.5 as positive instances, and the others as negative instances.
|
||||||
- "merror": Multiclass classification error rate. It is calculated as #(wrong cases)/#(all cases).
|
- "merror": Multiclass classification error rate. It is calculated as #(wrong cases)/#(all cases).
|
||||||
|
|||||||
@ -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> {
|
struct EvalLogLoss : public EvalEWiseBase<EvalLogLoss> {
|
||||||
const char *Name() const override {
|
const char *Name() const override {
|
||||||
return "logloss";
|
return "logloss";
|
||||||
@ -114,6 +123,10 @@ XGBOOST_REGISTER_METRIC(RMSE, "rmse")
|
|||||||
.describe("Rooted mean square error.")
|
.describe("Rooted mean square error.")
|
||||||
.set_body([](const char* param) { return new EvalRMSE(); });
|
.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")
|
XGBOOST_REGISTER_METRIC(LogLoss, "logloss")
|
||||||
.describe("Negative loglikelihood for logistic regression.")
|
.describe("Negative loglikelihood for logistic regression.")
|
||||||
.set_body([](const char* param) { return new EvalLogLoss(); });
|
.set_body([](const char* param) { return new EvalLogLoss(); });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user