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

Method ComputeNanMode

catboost/libs/data/quantized_features_info.cpp:202–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200 }
201
202 ENanMode TQuantizedFeaturesInfo::ComputeNanMode(const TFloatValuesHolder& feature) const {
203 auto& floatFeaturesBinarization = GetFloatFeatureBinarization(feature.GetId());
204 if (floatFeaturesBinarization.NanMode == ENanMode::Forbidden) {
205 return ENanMode::Forbidden;
206 }
207
208 bool hasNans;
209
210 if (const auto* denseData = dynamic_cast<const TFloatArrayValuesHolder*>(&feature)) {
211 hasNans
212 = denseData->GetData()->Find([] (size_t /*idx*/, float value) { return std::isnan(value); });
213 } else if (const auto* sparseData = dynamic_cast<const TFloatSparseValuesHolder*>(&feature)) {
214 const TConstPolymorphicValuesSparseArray<float, ui32>& sparseArray = sparseData->GetData();
215 if (std::isnan(sparseArray.GetDefaultValue())) {
216 hasNans = true;
217 } else {
218 hasNans = false;
219 auto blockIterator = sparseArray.GetNonDefaultValues().GetImpl().GetBlockIterator();
220 while (auto block = blockIterator->Next()) {
221 for (auto element : block) {
222 if (std::isnan(element)) {
223 hasNans = true;
224 break;
225 }
226 }
227 if (hasNans) {
228 break;
229 }
230 }
231 }
232 } else {
233 CB_ENSURE_INTERNAL(false, "TQuantizedFeaturesInfo::ComputeNanMode: unsupported column type");
234 }
235
236 if (hasNans) {
237 return floatFeaturesBinarization.NanMode;
238 }
239 return ENanMode::Forbidden;
240 }
241
242 ENanMode TQuantizedFeaturesInfo::GetOrComputeNanMode(const TFloatValuesHolder& feature) {
243 const auto floatFeatureIdx = GetPerTypeFeatureIdx<EFeatureType::Float>(feature);

Callers

nothing calls this directly

Calls 8

isnanFunction · 0.50
GetIdMethod · 0.45
FindMethod · 0.45
GetDataMethod · 0.45
GetDefaultValueMethod · 0.45
GetBlockIteratorMethod · 0.45
GetImplMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected