Skip to content
This repository was archived by the owner on Jun 18, 2022. It is now read-only.

Commit e33c4a5

Browse files
Don't save single value catFeaturePerfectHash to ensure that constant categ features are ignored when loading. MLTOOLS-5191.
ref:413195f165fdea146eb6e9b06876441493c1de6d
1 parent 18074b4 commit e33c4a5

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

catboost/private/libs/quantized_pool/serialization.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -1022,22 +1022,24 @@ namespace NCB {
10221022
const auto catFeatureIdx =
10231023
featuresLayout->GetInternalFeatureIdx<EFeatureType::Categorical>(externalFeatureIdx);
10241024

1025-
const auto& srcCatFeaturePerfectHash =
1026-
quantizedFeaturesInfo->GetCategoricalFeaturesPerfectHash(catFeatureIdx);
1027-
1028-
TMap<ui32, TValueWithCount> dstCatFeaturePerfectHash = srcCatFeaturePerfectHash.Map;
1029-
if (srcCatFeaturePerfectHash.DefaultMap.Defined()) {
1030-
dstCatFeaturePerfectHash.emplace(
1031-
srcCatFeaturePerfectHash.DefaultMap->SrcValue,
1032-
srcCatFeaturePerfectHash.DefaultMap->DstValueWithCount
1033-
);
1034-
}
1025+
TMap<ui32, TValueWithCount> dstCatFeaturePerfectHash;
10351026

10361027
TMaybeData<const IQuantizedCatValuesHolder*> feature =
10371028
quantizedObjectsData->GetCatFeature(*catFeatureIdx);
10381029

10391030
THolder<TSrcColumnBase> maybeFeatureColumn;
10401031
if (feature) {
1032+
const auto& srcCatFeaturePerfectHash =
1033+
quantizedFeaturesInfo->GetCategoricalFeaturesPerfectHash(catFeatureIdx);
1034+
1035+
dstCatFeaturePerfectHash = srcCatFeaturePerfectHash.Map;
1036+
if (srcCatFeaturePerfectHash.DefaultMap.Defined()) {
1037+
dstCatFeaturePerfectHash.emplace(
1038+
srcCatFeaturePerfectHash.DefaultMap->SrcValue,
1039+
srcCatFeaturePerfectHash.DefaultMap->DstValueWithCount
1040+
);
1041+
}
1042+
10411043
if (dstCatFeaturePerfectHash.size() > ((size_t)Max<ui16>() + 1)) {
10421044
maybeFeatureColumn = GenerateSrcColumn<ui32>(**feature);
10431045
} else if (dstCatFeaturePerfectHash.size() > ((size_t)Max<ui8>() + 1)) {

0 commit comments

Comments
 (0)