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

Function LoadFeatureNames

catboost/libs/data/loader.cpp:265–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263 }
264
265 TVector<TString> LoadFeatureNames(const TPathWithScheme& featureNamesPath) {
266 TVector<TString> featureNames;
267
268 if (featureNamesPath.Inited()) {
269 auto reader = GetLineDataReader(featureNamesPath);
270 TString line;
271 for (size_t lineNumber = 0; reader->ReadLine(&line); ++lineNumber) {
272 TVector<TString> tokens = StringSplitter(line).Split('\t');
273 if (tokens.empty()) {
274 continue;
275 }
276 try {
277 CB_ENSURE(tokens.size() == 2, "expect two items, got " << tokens.size());
278
279 size_t featureIdx;
280 CB_ENSURE(
281 TryFromString(tokens[0], featureIdx),
282 "Wrong format: first field is not unsigned integer");
283
284 CB_ENSURE(
285 !tokens[1].empty(),
286 "feature name is empty");
287
288 if (featureIdx >= featureNames.size()) {
289 featureNames.resize(featureIdx + 1);
290 } else {
291 CB_ENSURE(
292 featureNames[featureIdx].empty(),
293 "feature index " << featureIdx << " specified multiple times");
294 }
295
296 featureNames[featureIdx] = tokens[1];
297
298 } catch (std::exception& e) {
299 throw TCatBoostException() << "Feature names data from " << featureNamesPath
300 << ", line number " << lineNumber << ": " << e.what();
301 }
302 }
303 }
304
305 return featureNames;
306 }
307
308 static size_t GetFeatureCount(TConstArrayRef<TColumn> columns) {
309 size_t featureCount = 0;

Callers 3

GetFeatureNamesFunction · 0.85
GetFeatureNamesFunction · 0.85

Calls 11

GetLineDataReaderFunction · 0.85
StringSplitterFunction · 0.85
TryFromStringFunction · 0.85
TCatBoostExceptionClass · 0.85
InitedMethod · 0.45
ReadLineMethod · 0.45
SplitMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected