Skip to content

Commit

Permalink
Change DefaultEvalMetric of classification from error to logloss
Browse files Browse the repository at this point in the history
  • Loading branch information
lorentzenchr committed Sep 29, 2020
1 parent 444131a commit e40a9eb
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/parameter.rst
Expand Up @@ -376,7 +376,7 @@ Specify the learning task and the corresponding learning objective. The objectiv

* ``eval_metric`` [default according to objective]

- Evaluation metrics for validation data, a default metric will be assigned according to objective (rmse for regression, and error for classification, mean average precision for ranking)
- Evaluation metrics for validation data, a default metric will be assigned according to objective (rmse for regression, and logloss for classification, mean average precision for ranking)
- User can add multiple evaluation metrics. Python users: 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:

Expand Down
Expand Up @@ -154,10 +154,10 @@ class XGBoostClassifier (
require(isDefined(objective), "Users must set \'objective\' via xgboostParams.")
if ($(objective).startsWith("multi")) {
// multi
"merror"
"mlogloss"
} else {
// binary
"error"
"logloss"
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/updater_oneapi/regression_loss_oneapi.h
Expand Up @@ -103,7 +103,7 @@ struct LogisticRegressionOneAPI {

// logistic loss for binary classification task
struct LogisticClassificationOneAPI : public LogisticRegressionOneAPI {
static const char* DefaultEvalMetric() { return "error"; }
static const char* DefaultEvalMetric() { return "logloss"; }
static const char* Name() { return "binary:logistic_oneapi"; }
};

Expand Down
2 changes: 1 addition & 1 deletion src/objective/multiclass_obj.cu
Expand Up @@ -125,7 +125,7 @@ class SoftmaxMultiClassObj : public ObjFunction {
this->Transform(io_preds, true);
}
const char* DefaultEvalMetric() const override {
return "merror";
return "mlogloss";
}

inline void Transform(HostDeviceVector<bst_float> *io_preds, bool prob) {
Expand Down
2 changes: 1 addition & 1 deletion src/objective/regression_loss.h
Expand Up @@ -131,7 +131,7 @@ struct PseudoHuberError {

// logistic loss for binary classification task
struct LogisticClassification : public LogisticRegression {
static const char* DefaultEvalMetric() { return "error"; }
static const char* DefaultEvalMetric() { return "logloss"; }
static const char* Name() { return "binary:logistic"; }
};

Expand Down
2 changes: 1 addition & 1 deletion tests/cpp/plugin/test_example_objective.cc
Expand Up @@ -8,7 +8,7 @@ namespace xgboost {
TEST(Plugin, ExampleObjective) {
xgboost::GenericParameter tparam = CreateEmptyGenericParam(GPUIDX);
auto * obj = xgboost::ObjFunction::Create("mylogistic", &tparam);
ASSERT_EQ(obj->DefaultEvalMetric(), std::string{"error"});
ASSERT_EQ(obj->DefaultEvalMetric(), std::string{"logloss"});
delete obj;
}

Expand Down

0 comments on commit e40a9eb

Please sign in to comment.