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

Function GetClassLabelsImpl

catboost/libs/model/model_export/onnx_helpers.cpp:119–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117 */
118template <class TLabelContainer>
119static void GetClassLabelsImpl(
120 const TLabelContainer& classLabels,
121 TVector<i64>* classLabelsInt64,
122 TVector<TString>* classLabelsString) {
123
124 CB_ENSURE(!classLabels.empty(), "Class labels are missing");
125
126 classLabelsInt64->clear();
127 classLabelsString->clear();
128
129 switch (classLabels.begin()->GetType()) {
130 case NJson::JSON_INTEGER:
131 classLabelsInt64->reserve(classLabels.size());
132 for (const NJson::TJsonValue& classLabel : classLabels) {
133 classLabelsInt64->push_back(classLabel.GetInteger());
134 }
135 break;
136 case NJson::JSON_DOUBLE:
137 CB_ENSURE(false, "ONNX format does not support floating-point labels");
138 case NJson::JSON_STRING:
139 classLabelsString->reserve(classLabels.size());
140 for (const NJson::TJsonValue& classLabel : classLabels) {
141 classLabelsString->push_back(NCB::ClassLabelToString(classLabel));
142 }
143 break;
144 default:
145 CB_ENSURE(false, "Unexpected label type");
146 }
147}
148
149// only one of classLabelsInt64 or classLabelsString returned nonempty
150static void GetClassLabels(

Callers 1

GetClassLabelsFunction · 0.85

Calls 9

ClassLabelToStringFunction · 0.85
emptyMethod · 0.45
clearMethod · 0.45
GetTypeMethod · 0.45
beginMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
GetIntegerMethod · 0.45

Tested by

no test coverage detected