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

Method TCommonModelBuilderHelper

catboost/libs/model/model_build_helper.cpp:11–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <util/generic/ylimits.h>
10
11TCommonModelBuilderHelper::TCommonModelBuilderHelper(
12 const TVector<TFloatFeature>& allFloatFeatures,
13 const TVector<TCatFeature>& allCategoricalFeatures,
14 const TVector<TTextFeature>& allTextFeatures,
15 const TVector<TEmbeddingFeature>& allEmbeddingFeatures,
16 int approxDimension
17)
18 : ApproxDimension(approxDimension)
19 , FloatFeatures(allFloatFeatures)
20 , CatFeatures(allCategoricalFeatures)
21 , TextFeatures(allTextFeatures)
22 , EmbeddingFeatures(allEmbeddingFeatures)
23{
24 if (!FloatFeatures.empty()) {
25 CB_ENSURE(IsSorted(FloatFeatures.begin(), FloatFeatures.end(),
26 [](const TFloatFeature& f1, const TFloatFeature& f2) {
27 return f1.Position.FlatIndex < f2.Position.FlatIndex;
28 }),
29 "Float features should be sorted"
30 );
31 FloatFeaturesInternalIndexesMap.resize((size_t)FloatFeatures.back().Position.Index + 1, Max<size_t>());
32 for (auto i : xrange(FloatFeatures.size())) {
33 FloatFeaturesInternalIndexesMap.at((size_t)FloatFeatures[i].Position.Index) = i;
34 }
35 }
36 if (!CatFeatures.empty()) {
37 CB_ENSURE(IsSorted(CatFeatures.begin(), CatFeatures.end(),
38 [](const TCatFeature& f1, const TCatFeature& f2) {
39 return f1.Position.FlatIndex < f2.Position.FlatIndex;
40 }),
41 "Cat features should be sorted"
42 );
43 CatFeaturesInternalIndexesMap.resize((size_t)CatFeatures.back().Position.Index + 1, Max<size_t>());
44 for (auto i : xrange(CatFeatures.size())) {
45 CatFeaturesInternalIndexesMap.at((size_t)CatFeatures[i].Position.Index) = i;
46 }
47 }
48 if (!TextFeatures.empty()) {
49 CB_ENSURE(
50 IsSorted(
51 TextFeatures.begin(),
52 TextFeatures.end(),
53 [](const TTextFeature& f1, const TTextFeature& f2) {
54 return f1.Position.FlatIndex < f2.Position.FlatIndex;
55 }
56 ),
57 "Text features should be sorted"
58 );
59 TextFeaturesInternalIndexesMap.resize((size_t)TextFeatures.back().Position.Index + 1, Max<size_t>());
60 for (auto i : xrange(TextFeatures.size())) {
61 TextFeaturesInternalIndexesMap.at((size_t)TextFeatures[i].Position.Index) = i;
62 }
63 }
64 if (!EmbeddingFeatures.empty()) {
65 CB_ENSURE(
66 IsSorted(
67 EmbeddingFeatures.begin(),
68 EmbeddingFeatures.end(),

Callers

nothing calls this directly

Calls 9

IsSortedFunction · 0.85
xrangeFunction · 0.85
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45
backMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected