| 774 | class TCPUModelTrainer : public IModelTrainer { |
| 775 | |
| 776 | void TrainModel( |
| 777 | const TTrainModelInternalOptions& internalOptions, |
| 778 | const NCatboostOptions::TCatBoostOptions& catboostOptions, |
| 779 | const NCatboostOptions::TOutputFilesOptions& outputOptions, |
| 780 | const TMaybe<TCustomObjectiveDescriptor>& objectiveDescriptor, |
| 781 | const TMaybe<TCustomMetricDescriptor>& evalMetricDescriptor, |
| 782 | TTrainingDataProviders trainingData, |
| 783 | TMaybe<TPrecomputedOnlineCtrData> precomputedSingleOnlineCtrDataForSingleFold, |
| 784 | const TLabelConverter& labelConverter, |
| 785 | ITrainingCallbacks* trainingCallbacks, |
| 786 | ICustomCallbacks* customCallbacks, |
| 787 | TMaybe<TFullModel*> initModel, |
| 788 | THolder<TLearnProgress> initLearnProgress, |
| 789 | TDataProviders initModelApplyCompatiblePools, |
| 790 | NPar::ILocalExecutor* localExecutor, |
| 791 | const TMaybe<TRestorableFastRng64*> rand, |
| 792 | TFullModel* dstModel, |
| 793 | const TVector<TEvalResult*>& evalResultPtrs, |
| 794 | TMetricsAndTimeLeftHistory* metricsAndTimeHistory, |
| 795 | THolder<TLearnProgress>* dstLearnProgress |
| 796 | ) const override { |
| 797 | |
| 798 | if (!internalOptions.CalcMetricsOnly) { |
| 799 | if (dstModel != nullptr) { |
| 800 | CB_ENSURE( |
| 801 | !outputOptions.ResultModelPath.IsSet(), |
| 802 | "Both dstModel != nullptr and ResultModelPath is set" |
| 803 | ); |
| 804 | } else { |
| 805 | CB_ENSURE( |
| 806 | !outputOptions.ResultModelPath.Get().empty(), |
| 807 | "Both dstModel == nullptr and ResultModelPath is empty" |
| 808 | ); |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | trainingData.Learn->ObjectsData->CheckCPUTrainCompatibility(); |
| 813 | for (auto& test : trainingData.Test) { |
| 814 | test->ObjectsData->CheckCPUTrainCompatibility(); |
| 815 | } |
| 816 | |
| 817 | const TString trainingOptionsFileName = outputOptions.CreateTrainingOptionsFullPath(); |
| 818 | if (!trainingOptionsFileName.empty()) { |
| 819 | TOFStream trainingOptionsFile(trainingOptionsFileName); |
| 820 | trainingOptionsFile.Write(NJson::PrettifyJson(ToString(catboostOptions))); |
| 821 | } |
| 822 | |
| 823 | // need to save it because initLearnProgress is moved to TLearnContext |
| 824 | TMaybe<ui32> initLearnProgressLearnAndTestQuantizedFeaturesCheckSum; |
| 825 | if (initLearnProgress) { |
| 826 | initLearnProgressLearnAndTestQuantizedFeaturesCheckSum = initLearnProgress->LearnAndTestQuantizedFeaturesCheckSum; |
| 827 | } |
| 828 | |
| 829 | if (catboostOptions.BoostingOptions->BoostFromAverage.Get()) { |
| 830 | CB_ENSURE(!initModel, "You can't use boost_from_average with initial model now."); |
| 831 | CB_ENSURE(!trainingData.Learn->TargetData->GetBaseline(), "You can't use boost_from_average with baseline now."); |
| 832 | for (ui32 testIdx = 0; testIdx < trainingData.Test.size(); ++testIdx) { |
| 833 | CB_ENSURE(!trainingData.Test[testIdx]->TargetData->GetBaseline(), "You can't use boost_from_average with baseline now."); |
no test coverage detected