forked from microsoft/LightGBM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[R-package] fix issue where early stopping thinks higher MAPE is desi…
…rable (fixes microsoft#3099) (microsoft#3101) * [R-package] fix issue where early stopping thinks higher MAPE is desirable (fixes microsoft#3099) * fix linting * only use main metrics * fix tests
- Loading branch information
1 parent
54a0b7a
commit 2a06f0e
Showing
5 changed files
with
186 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# [description] List of metrics known to LightGBM. The most up to date list can be found | ||
# at https://lightgbm.readthedocs.io/en/latest/Parameters.html#metric-parameters | ||
# | ||
# [return] A named logical vector, where each key is a metric name and each value is a boolean. | ||
# TRUE if higher values of the metric are desirable, FALSE if lower values are desirable. | ||
# Note that only the 'main' metrics are stored here, not aliases, since only the 'main' metrics | ||
# are returned from the C++ side. For example, if you use `metric = "mse"` in your code, | ||
# the metric name `"l2"` will be returned. | ||
.METRICS_HIGHER_BETTER <- function() { | ||
return(c( | ||
"l1" = FALSE | ||
, "l2" = FALSE | ||
, "mape" = FALSE | ||
, "rmse" = FALSE | ||
, "quantile" = FALSE | ||
, "huber" = FALSE | ||
, "fair" = FALSE | ||
, "poisson" = FALSE | ||
, "gamma" = FALSE | ||
, "gamma_deviance" = FALSE | ||
, "tweedie" = FALSE | ||
, "ndcg" = TRUE | ||
, "map" = TRUE | ||
, "auc" = TRUE | ||
, "binary_logloss" = FALSE | ||
, "binary_error" = FALSE | ||
, "auc_mu" = TRUE | ||
, "multi_logloss" = FALSE | ||
, "multi_error" = FALSE | ||
, "cross_entropy" = FALSE | ||
, "cross_entropy_lambda" = FALSE | ||
, "kullback_leibler" = FALSE | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
context(".METRICS_HIGHER_BETTER()") | ||
|
||
test_that(".METRICS_HIGHER_BETTTER() should be well formed", { | ||
metrics <- .METRICS_HIGHER_BETTER() | ||
metric_names <- names(.METRICS_HIGHER_BETTER()) | ||
# should be a logical vector | ||
expect_true(is.logical(metrics)) | ||
# no metrics should be repeated | ||
expect_true(length(unique(metric_names)) == length(metrics)) | ||
# should not be any NAs | ||
expect_false(any(is.na(metrics))) | ||
}) |