| 181 | } |
| 182 | |
| 183 | void ClassificationStats::AddExample( |
| 184 | const std::unique_ptr<TensorDataSet>& input_data, const InputTarget* target, |
| 185 | int example) { |
| 186 | const int64 int_label = target->GetTargetAsClassIndex(example, 0); |
| 187 | const float weight = target->GetTargetWeight(example); |
| 188 | |
| 189 | for (int i = 0; i < num_splits(); ++i) { |
| 190 | auto& eval = evaluators_[i]; |
| 191 | if (eval->Decide(input_data, example) == LEFT_INDEX) { |
| 192 | if (left_gini_ != nullptr) { |
| 193 | left_gini_->update(i, left_count(i, int_label), weight); |
| 194 | } |
| 195 | ClassificationAddLeftExample(i, int_label, weight); |
| 196 | } else { |
| 197 | if (right_gini_ != nullptr) { |
| 198 | right_gini_->update(i, right_count(i, int_label), weight); |
| 199 | } |
| 200 | ClassificationAddRightExample(i, int_label, weight); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | ClassificationAddTotalExample(int_label, weight); |
| 205 | |
| 206 | weight_sum_ += weight; |
| 207 | |
| 208 | CheckFinishEarly(); |
| 209 | CheckPrune(); |
| 210 | } |
| 211 | |
| 212 | void ClassificationStats::CheckPrune() { |
| 213 | if (params_.pruning_type().type() == SPLIT_PRUNE_NONE || IsFinished() || |