forked from dmlc/xgboost
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backport] Fix default metric configuration. (dmlc#9575)
- Loading branch information
1 parent
096047c
commit f5486fb
Showing
6 changed files
with
105 additions
and
25 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
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,31 @@ | ||
/** | ||
* Copyright (c) 2023, XGBoost contributors | ||
*/ | ||
#include "objective_helpers.h" | ||
|
||
#include "../../src/common/linalg_op.h" // for begin, end | ||
#include "helpers.h" // for RandomDataGenerator | ||
|
||
namespace xgboost { | ||
std::shared_ptr<DMatrix> MakeFmatForObjTest(std::string const& obj) { | ||
auto constexpr kRows = 10, kCols = 10; | ||
auto p_fmat = RandomDataGenerator{kRows, kCols, 0}.GenerateDMatrix(true); | ||
auto& h_upper = p_fmat->Info().labels_upper_bound_.HostVector(); | ||
auto& h_lower = p_fmat->Info().labels_lower_bound_.HostVector(); | ||
h_lower.resize(kRows); | ||
h_upper.resize(kRows); | ||
for (size_t i = 0; i < kRows; ++i) { | ||
h_lower[i] = 1; | ||
h_upper[i] = 10; | ||
} | ||
if (obj.find("rank:") != std::string::npos) { | ||
auto h_label = p_fmat->Info().labels.HostView(); | ||
std::size_t k = 0; | ||
for (auto& v : h_label) { | ||
v = k % 2 == 0; | ||
++k; | ||
} | ||
} | ||
return p_fmat; | ||
}; | ||
} // namespace xgboost |
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