| 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; |
no test coverage detected