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

Method Save

catboost/libs/data/target.cpp:978–1026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

976}
977
978void TProcessedTargetData::Save(IBinSaver* binSaver) const {
979 TSerializationTargetDataCache cache;
980
981 /* For serialization we have get serialized target data with ids first before cache is filled
982 * For deserialization we get cache filled first and then create target data from it
983 * so we need to change the order of these parts while saving
984 */
985 TBuffer serializedTargetDataWithIds;
986
987 {
988 TBufferOutput out(serializedTargetDataWithIds);
989 TYaStreamOutput out2(out);
990 IBinSaver targetDataWithIdsBinSaver(out2, false);
991
992 SaveMulti(&targetDataWithIdsBinSaver, TargetsClassCount);
993 SaveWithCache(Weights, &targetDataWithIdsBinSaver, &cache.Weights);
994
995 {
996 SaveMulti(&targetDataWithIdsBinSaver, SafeIntegerCast<ui32>(Targets.size()));
997 for (const auto& [name, dataPart] : Targets) {
998 const ui32 dimensionCount = dataPart.size();
999 SaveMulti(&targetDataWithIdsBinSaver, name, dimensionCount);
1000 for (const auto& oneTarget : dataPart) {
1001 AddToCacheAndSaveId(oneTarget, &targetDataWithIdsBinSaver, &cache.Targets);
1002 }
1003 }
1004 }
1005
1006 {
1007 SaveMulti(&targetDataWithIdsBinSaver, SafeIntegerCast<ui32>(Baselines.size()));
1008 for (const auto& [name, dataPart] : Baselines) {
1009 const ui32 dimensionCount = dataPart.size();
1010 SaveMulti(&targetDataWithIdsBinSaver, name, dimensionCount);
1011 for (const auto& oneBaseline : dataPart) {
1012 AddToCacheAndSaveId(oneBaseline, &targetDataWithIdsBinSaver, &cache.Baselines);
1013 }
1014 }
1015 }
1016
1017 SaveWithCache(GroupInfos, &targetDataWithIdsBinSaver, &cache.GroupInfos);
1018 }
1019
1020 SaveMulti(binSaver, cache);
1021
1022 SaveArrayData(
1023 TConstArrayRef<ui8>((ui8*)serializedTargetDataWithIds.Data(), serializedTargetDataWithIds.Size()),
1024 binSaver
1025 );
1026}
1027
1028
1029TTargetDataProvider::TTargetDataProvider(

Callers 2

SaveDataNonSharedPartMethod · 0.45
DoSerializeDeserializeFunction · 0.45

Calls 7

SaveMultiFunction · 0.85
SaveWithCacheFunction · 0.85
AddToCacheAndSaveIdFunction · 0.85
SaveArrayDataFunction · 0.85
sizeMethod · 0.45
DataMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected