MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / CheckLabel

Method CheckLabel

src/metric/dcg_calculator.cpp:154–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void DCGCalculator::CheckLabel(const label_t* label, data_size_t num_data) {
155 for (data_size_t i = 0; i < num_data; ++i) {
156 label_t delta = std::fabs(label[i] - static_cast<int>(label[i]));
157 if (delta > kEpsilon) {
158 Log::Fatal("label should be int type (met %f) for ranking task,\n"
159 "for the gain of label, please set the label_gain parameter", label[i]);
160 }
161
162 if (label[i] < 0) {
163 Log::Fatal("Label should be non-negative (met %f) for ranking task", label[i]);
164 }
165
166 if (static_cast<size_t>(label[i]) >= label_gain_.size()) {
167 Log::Fatal("Label %zu is not less than the number of label mappings (%zu)", static_cast<size_t>(label[i]), label_gain_.size());
168 }
169 }
170}
171
172} // namespace LightGBM

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected