| 321 | |
| 322 | |
| 323 | TVector<TString> GetFeatureNames( |
| 324 | const TDataColumnsMetaInfo& columnsDescription, |
| 325 | const TMaybe<TVector<TString>>& headerColumns, |
| 326 | const TPathWithScheme& featureNamesPath |
| 327 | ) { |
| 328 | // featureNamesFromColumns can be empty |
| 329 | const TVector<TString> featureNamesFromColumns = columnsDescription.GenerateFeatureIds(headerColumns); |
| 330 | const size_t featureCount |
| 331 | = featureNamesFromColumns.empty() ? |
| 332 | GetFeatureCount(columnsDescription.Columns) |
| 333 | : featureNamesFromColumns.size(); |
| 334 | |
| 335 | TVector<TString> externalFeatureNames = LoadFeatureNames(featureNamesPath); |
| 336 | |
| 337 | if (externalFeatureNames.empty()) { |
| 338 | return featureNamesFromColumns; |
| 339 | } else { |
| 340 | CB_ENSURE( |
| 341 | externalFeatureNames.size() <= featureCount, |
| 342 | "feature names file contains index (" << (externalFeatureNames.size() - 1) |
| 343 | << ") that is not less than the number of features in the dataset (" << featureCount << ')' |
| 344 | ); |
| 345 | externalFeatureNames.resize(featureCount); |
| 346 | if (!featureNamesFromColumns.empty()) { |
| 347 | for (auto featureIdx : xrange(featureCount)) { |
| 348 | CB_ENSURE( |
| 349 | featureNamesFromColumns[featureIdx].empty() |
| 350 | || (featureNamesFromColumns[featureIdx] == externalFeatureNames[featureIdx]), |
| 351 | "Feature #" << featureIdx << ": name from columns specification (\"" |
| 352 | << featureNamesFromColumns[featureIdx] |
| 353 | << "\") is not equal to name from feature names file (\"" |
| 354 | << externalFeatureNames[featureIdx] << "\")"); |
| 355 | } |
| 356 | } |
| 357 | return externalFeatureNames; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | bool IsMissingValue(const TStringBuf& s) { |
| 362 | switch (s.length()) { |
no test coverage detected