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

Method Transform

catboost/dotnet/CatBoostNet/CatBoostModel.cs:55–202  ·  view source on GitHub ↗

(IDataView input)

Source from the content-addressed store, hash-verified

53
54 /// <inheritdoc />
55 public IDataView Transform(IDataView input)
56 {
57 HashSet<string> numTypes = new HashSet<string>
58 {
59 "Boolean", "Single", "Int32"
60 };
61
62 int nFloat = 0, nCat = 0;
63 Collection<int> catFeatureIxs = new Collection<int>();
64
65 using (var cursor = input.GetRowCursor(input.Schema))
66 {
67 cursor.MoveNext();
68 int ix = -1;
69 int ptr = 0;
70 foreach (var col in cursor.Schema)
71 {
72 ix++;
73 if (col.Name == TargetFeature)
74 {
75 continue;
76 }
77
78 string typeId = col.Type.ToString();
79 if (numTypes.Contains(typeId))
80 {
81 nFloat++;
82 }
83 else if (typeId == "String")
84 {
85 catFeatureIxs.Add(ptr);
86 nCat++;
87 }
88 else
89 {
90 throw new NotSupportedException($"Data type {typeId} is not supported.");
91 }
92 ptr++;
93 }
94 }
95
96 List<float[]> floatFeatures = new List<float[]>();
97 List<string[]> catFeatures = new List<string[]>();
98
99 using (var cursor = input.GetRowCursor(input.Schema))
100 {
101 int rowIx = 0;
102 while (cursor.MoveNext())
103 {
104 int ix = -1;
105 int ptr = 0;
106 int realPtr = 0;
107 int catPtr = 0;
108
109 float[] floats = new float[nFloat];
110 string[] cats = new string[nCat];
111
112 foreach (var col in cursor.Schema)

Callers 4

PredictMethod · 0.45
RunIrisTestMethod · 0.45
RunBostonTestMethod · 0.45
RunMushroomMethod · 0.45

Calls 7

EvaluateBatchMethod · 0.80
ToStringMethod · 0.45
ContainsMethod · 0.45
AddMethod · 0.45
AssertMethod · 0.45
RangeMethod · 0.45
GetLengthMethod · 0.45

Tested by 3

RunIrisTestMethod · 0.36
RunBostonTestMethod · 0.36
RunMushroomMethod · 0.36