| 1297 | } |
| 1298 | |
| 1299 | TVector<TString> GetModelUsedFeaturesNames(const TFullModel& model) { |
| 1300 | TVector<int> featuresIdxs; |
| 1301 | TVector<TString> featuresNames; |
| 1302 | const TModelTrees& forest = *model.ModelTrees; |
| 1303 | |
| 1304 | for (const TFloatFeature& feature : forest.GetFloatFeatures()) { |
| 1305 | featuresIdxs.push_back(feature.Position.FlatIndex); |
| 1306 | featuresNames.push_back( |
| 1307 | feature.FeatureId == "" ? ToString(feature.Position.FlatIndex) : feature.FeatureId |
| 1308 | ); |
| 1309 | } |
| 1310 | for (const TCatFeature& feature : forest.GetCatFeatures()) { |
| 1311 | featuresIdxs.push_back(feature.Position.FlatIndex); |
| 1312 | featuresNames.push_back( |
| 1313 | feature.FeatureId == "" ? ToString(feature.Position.FlatIndex) : feature.FeatureId |
| 1314 | ); |
| 1315 | } |
| 1316 | for (const TTextFeature& feature : forest.GetTextFeatures()) { |
| 1317 | featuresIdxs.push_back(feature.Position.FlatIndex); |
| 1318 | featuresNames.push_back( |
| 1319 | feature.FeatureId == "" ? ToString(feature.Position.FlatIndex) : feature.FeatureId |
| 1320 | ); |
| 1321 | } |
| 1322 | for (const TEmbeddingFeature& feature : forest.GetEmbeddingFeatures()) { |
| 1323 | featuresIdxs.push_back(feature.Position.FlatIndex); |
| 1324 | featuresNames.push_back( |
| 1325 | feature.FeatureId == "" ? ToString(feature.Position.FlatIndex) : feature.FeatureId |
| 1326 | ); |
| 1327 | } |
| 1328 | |
| 1329 | TVector<int> featuresOrder(featuresIdxs.size()); |
| 1330 | Iota(featuresOrder.begin(), featuresOrder.end(), 0); |
| 1331 | Sort(featuresOrder.begin(), featuresOrder.end(), |
| 1332 | [featuresIdxs](int index1, int index2) { |
| 1333 | return featuresIdxs[index1] < featuresIdxs[index2]; |
| 1334 | } |
| 1335 | ); |
| 1336 | |
| 1337 | TVector<TString> result(featuresNames.size()); |
| 1338 | for (int featureIdx = 0; featureIdx < featuresNames.ysize(); ++featureIdx) { |
| 1339 | result[featureIdx] = featuresNames[featuresOrder[featureIdx]]; |
| 1340 | } |
| 1341 | return result; |
| 1342 | } |
| 1343 | |
| 1344 | template <typename T> |
| 1345 | TVector<size_t> MakeIndicesVector(const TConstArrayRef<T>& features) { |
no test coverage detected