MCPcopy Create free account
hub / github.com/catboost/catboost / EvaluateFeatures

Function EvaluateFeatures

catboost/libs/train_lib/eval_feature.cpp:1159–1245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1157}
1158
1159TFeatureEvaluationSummary EvaluateFeatures(
1160 const NJson::TJsonValue& plainJsonParams,
1161 const NCatboostOptions::TFeatureEvalOptions& featureEvalOptions,
1162 const TMaybe<TCustomObjectiveDescriptor>& objectiveDescriptor,
1163 const TMaybe<TCustomMetricDescriptor>& evalMetricDescriptor,
1164 const TCvDataPartitionParams& cvParams,
1165 TDataProviderPtr data
1166) {
1167 const auto taskType = NCatboostOptions::GetTaskType(plainJsonParams);
1168 if (taskType == ETaskType::GPU) {
1169 CB_ENSURE(
1170 TTrainerFactory::Has(ETaskType::GPU),
1171 "Can't load GPU learning library. "
1172 "Module was not compiled or driver is incompatible with package. "
1173 "Please install latest NVDIA driver and check again");
1174 }
1175 NCatboostOptions::TCatBoostOptions catBoostOptions(taskType);
1176 NCatboostOptions::TOutputFilesOptions outputFileOptions;
1177 LoadOptions(plainJsonParams, data.Get()->MetaInfo, &catBoostOptions, &outputFileOptions);
1178 const auto& absoluteSnapshotPath = MakeAbsolutePath(outputFileOptions.GetSnapshotFilename());
1179 outputFileOptions.SetSnapshotFilename(absoluteSnapshotPath);
1180
1181 const ui32 foldCount = cvParams.Initialized() ? cvParams.FoldCount : featureEvalOptions.FoldCount.Get();
1182 CB_ENSURE(foldCount > 0, "Fold count must be positive integer");
1183 const ui32 offset = featureEvalOptions.Offset;
1184
1185 ui32 absoluteFoldSize;
1186 ui32 disjointFoldCount;
1187 CountDisjointFolds(data, featureEvalOptions, &absoluteFoldSize, &disjointFoldCount);
1188
1189 if (disjointFoldCount < offset + foldCount) {
1190 const auto samplingUnitsCount = GetSamplingUnitCount(*data->ObjectsGrouping, IsObjectwiseEval(featureEvalOptions));
1191 CB_ENSURE(
1192 cvParams.Shuffle,
1193 "Dataset contains too few objects or groups to evaluate features without shuffling. "
1194 "Please decrease fold size to at most " << samplingUnitsCount / (offset + foldCount) << ", or "
1195 "enable dataset shuffling in cross-validation "
1196 "(specify cv_no_suffle=False in Python or remove --cv-no-shuffle from command line).");
1197 }
1198
1199 const auto foldRangeRandomSeeds = GenRandUI64Vector(CeilDiv(offset + foldCount, disjointFoldCount), catBoostOptions.RandomSeed);
1200 auto foldRangeRandomSeed = catBoostOptions;
1201
1202 TFeatureEvaluationSummary summary;
1203
1204 const auto callbacks = MakeHolder<TFeatureEvaluationCallbacks>(
1205 catBoostOptions.BoostingOptions->IterationCount,
1206 featureEvalOptions,
1207 &summary);
1208
1209 if (outputFileOptions.SaveSnapshot() && NFs::Exists(absoluteSnapshotPath)) {
1210 callbacks->LoadSnapshot(taskType, absoluteSnapshotPath);
1211 }
1212
1213 const ui32 trainingCount = GetTrainingCount(featureEvalOptions);
1214 CATBOOST_NOTICE_LOG << "Feature evaluation requires training " << trainingCount << " model(s); "
1215 "if training takes more than 10 minutes to complete, progress is printed every 10 minutes" << Endl;
1216

Callers 1

mode_eval_featureFunction · 0.85

Calls 15

HasFunction · 0.85
MakeAbsolutePathFunction · 0.85
CountDisjointFoldsFunction · 0.85
GetSamplingUnitCountFunction · 0.85
IsObjectwiseEvalFunction · 0.85
GenRandUI64VectorFunction · 0.85
CeilDivFunction · 0.85
GetTrainingCountFunction · 0.85
EvaluateFeaturesImplFunction · 0.85
SetSnapshotFilenameMethod · 0.80
SaveSnapshotMethod · 0.80

Tested by

no test coverage detected