| 52 | } |
| 53 | |
| 54 | PredictionEarlyStopInstance CreateBinary(const PredictionEarlyStopConfig& config) { |
| 55 | // margin_threshold will be captured by value |
| 56 | const double margin_threshold = config.margin_threshold; |
| 57 | |
| 58 | return PredictionEarlyStopInstance{ |
| 59 | [margin_threshold](const double* pred, int sz) { |
| 60 | if (sz != 1) { |
| 61 | Log::Fatal("Binary early stopping needs predictions to be of length one"); |
| 62 | } |
| 63 | const auto margin = 2.0 * fabs(pred[0]); |
| 64 | |
| 65 | if (margin > margin_threshold) { |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | return false; |
| 70 | }, |
| 71 | config.round_period |
| 72 | }; |
| 73 | } |
| 74 | |
| 75 | PredictionEarlyStopInstance CreatePredictionEarlyStopInstance(const std::string& type, |
| 76 | const PredictionEarlyStopConfig& config) { |
no outgoing calls
no test coverage detected