| 1101 | } |
| 1102 | |
| 1103 | static void CountDisjointFolds( |
| 1104 | TDataProviderPtr data, |
| 1105 | const NCatboostOptions::TFeatureEvalOptions& featureEvalOptions, |
| 1106 | ui32* absoluteFoldSize, |
| 1107 | ui32* disjointFoldCount |
| 1108 | ) { |
| 1109 | const auto isObjectwise = IsObjectwiseEval(featureEvalOptions); |
| 1110 | const auto& objectsGrouping = *data->ObjectsGrouping; |
| 1111 | |
| 1112 | ui32 samplingUnitsCount = 0; |
| 1113 | if (!data->MetaInfo.HasTimestamp) { |
| 1114 | samplingUnitsCount = GetSamplingUnitCount(objectsGrouping, isObjectwise); |
| 1115 | } else { |
| 1116 | const auto timestamps = *data->ObjectsData->GetTimestamp(); |
| 1117 | CB_ENSURE( |
| 1118 | data->ObjectsData->GetGroupIds(), |
| 1119 | "Timestamps require group ids"); |
| 1120 | const auto timesplitQuantileTimestamp = FindQuantileTimestamp( |
| 1121 | *data->ObjectsData->GetGroupIds(), |
| 1122 | timestamps, |
| 1123 | featureEvalOptions.TimeSplitQuantile); |
| 1124 | |
| 1125 | samplingUnitsCount = 0; |
| 1126 | for (ui32 groupIdx : xrange(objectsGrouping.GetGroupCount())) { |
| 1127 | const auto group = objectsGrouping.GetGroup(groupIdx); |
| 1128 | const auto groupTimestamp = timestamps[group.Begin]; |
| 1129 | if (groupTimestamp <= timesplitQuantileTimestamp) { |
| 1130 | if (isObjectwise) { |
| 1131 | samplingUnitsCount += group.GetSize(); |
| 1132 | } else { |
| 1133 | ++samplingUnitsCount; |
| 1134 | } |
| 1135 | } |
| 1136 | } |
| 1137 | } |
| 1138 | CB_ENSURE( |
| 1139 | featureEvalOptions.FoldSize.Get() > 0 || featureEvalOptions.RelativeFoldSize.Get() > 0, |
| 1140 | "Please specify positive fold size or positive relative fold size"); |
| 1141 | if (featureEvalOptions.FoldSize.Get() > 0) { |
| 1142 | *absoluteFoldSize = featureEvalOptions.FoldSize.Get(); |
| 1143 | } else { |
| 1144 | *absoluteFoldSize = featureEvalOptions.RelativeFoldSize.Get() * samplingUnitsCount; |
| 1145 | CB_ENSURE( |
| 1146 | *absoluteFoldSize > 0, |
| 1147 | "Relative fold size must be greater than " << 1.0f / samplingUnitsCount << " so that size of each fold is non-zero"; |
| 1148 | ); |
| 1149 | } |
| 1150 | *disjointFoldCount = samplingUnitsCount / *absoluteFoldSize; |
| 1151 | if (*disjointFoldCount < 2) { |
| 1152 | CATBOOST_WARNING_LOG << "Fold size (" << *absoluteFoldSize << " units) excceds 50% of dataset size (" << samplingUnitsCount << " units). " |
| 1153 | << "Fold size is decreased to 50% of dataset size." << Endl; |
| 1154 | *disjointFoldCount = 2; |
| 1155 | *absoluteFoldSize = samplingUnitsCount / 2; |
| 1156 | } |
| 1157 | } |
| 1158 | |
| 1159 | TFeatureEvaluationSummary EvaluateFeatures( |
| 1160 | const NJson::TJsonValue& plainJsonParams, |
no test coverage detected