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

Class LightSplitInfo

src/treelearner/split_info.hpp:195–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193};
194
195struct LightSplitInfo {
196 public:
197 /*! \brief Feature index */
198 int feature = -1;
199 /*! \brief Split gain */
200 double gain = kMinScore;
201 /*! \brief Left number of data after split */
202 data_size_t left_count = 0;
203 /*! \brief Right number of data after split */
204 data_size_t right_count = 0;
205
206 inline void Reset() {
207 // initialize with -1 and -inf gain
208 feature = -1;
209 gain = kMinScore;
210 }
211
212 void CopyFrom(const SplitInfo& other) {
213 feature = other.feature;
214 gain = other.gain;
215 left_count = other.left_count;
216 right_count = other.right_count;
217 }
218
219 void CopyFrom(const char* buffer) {
220 std::memcpy(&feature, buffer, sizeof(feature));
221 buffer += sizeof(feature);
222 std::memcpy(&left_count, buffer, sizeof(left_count));
223 buffer += sizeof(left_count);
224 std::memcpy(&right_count, buffer, sizeof(right_count));
225 buffer += sizeof(right_count);
226 std::memcpy(&gain, buffer, sizeof(gain));
227 buffer += sizeof(gain);
228 }
229
230 inline bool operator > (const LightSplitInfo& si) const {
231 double local_gain = this->gain;
232 double other_gain = si.gain;
233 // replace nan with -inf
234 if (local_gain == NAN) {
235 local_gain = kMinScore;
236 }
237 // replace nan with -inf
238 if (other_gain == NAN) {
239 other_gain = kMinScore;
240 }
241 int local_feature = this->feature;
242 int other_feature = si.feature;
243 // replace -1 with max int
244 if (local_feature == -1) {
245 local_feature = INT32_MAX;
246 }
247 // replace -1 with max int
248 if (other_feature == -1) {
249 other_feature = INT32_MAX;
250 }
251 if (local_gain != other_gain) {
252 return local_gain > other_gain;

Callers 2

GlobalVotingMethod · 0.70
FindBestSplitsMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected