| 22 | } |
| 23 | |
| 24 | void NCatboostOptions::TOverfittingDetectorOptions::Load(const NJson::TJsonValue& options) { |
| 25 | if (!options.Has("type")) { |
| 26 | if (options.Has("stop_pvalue")) { |
| 27 | OverfittingDetectorType.Set(EOverfittingDetectorType::IncToDec); |
| 28 | } else if (options.Has("wait_iterations")) { |
| 29 | OverfittingDetectorType.Set(EOverfittingDetectorType::Iter); |
| 30 | } else { |
| 31 | OverfittingDetectorType.Set(EOverfittingDetectorType::None); |
| 32 | } |
| 33 | } |
| 34 | CheckedLoad(options, &AutoStopPValue, &OverfittingDetectorType, &IterationsWait); |
| 35 | CB_ENSURE( |
| 36 | (OverfittingDetectorType.Get() != EOverfittingDetectorType::Iter) |
| 37 | || !options.Has("stop_pvalue") |
| 38 | || (options["stop_pvalue"].GetDouble() == 0.0), // this check is needed because the default value is serialized |
| 39 | "Auto-stop PValue is not a valid parameter for Iter overfitting detector." |
| 40 | ); |
| 41 | Validate(); |
| 42 | } |
| 43 | |
| 44 | void NCatboostOptions::TOverfittingDetectorOptions::Save(NJson::TJsonValue* options) const { |
| 45 | SaveFields(options, AutoStopPValue, OverfittingDetectorType, IterationsWait); |