3 instantiations of ValueToKeyMappingEstimator
Microsoft.ML.Data (3)
Transforms\ConversionsExtensionsCatalog.cs (3)
254
=> new
ValueToKeyMappingEstimator
(CatalogUtils.GetEnvironment(catalog),
292
return new
ValueToKeyMappingEstimator
(env, columnOptions, keyData);
309
=> new
ValueToKeyMappingEstimator
(CatalogUtils.GetEnvironment(catalog), columns, keyData);
156 references to ValueToKeyMappingEstimator
Microsoft.ML.Core.Tests (1)
UnitTests\TestEntryPoints.cs (1)
1557
data = new ValueToKeyMappingEstimator(Env, "Label", "Label", keyOrdinality:
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue).Fit(data).Transform(data);
Microsoft.ML.Data (48)
Transforms\ConversionsExtensionsCatalog.cs (23)
126
/// <see cref="MapValueToKey(TransformsCatalog.ConversionTransforms, InputOutputColumnPair[], int,
ValueToKeyMappingEstimator
.KeyOrdinality, bool, IDataView)"/></remarks>
147
/// <see cref="MapValueToKey(TransformsCatalog.ConversionTransforms, InputOutputColumnPair[], int,
ValueToKeyMappingEstimator
.KeyOrdinality, bool, IDataView)"/></remarks>
223
/// Create a <see cref="
ValueToKeyMappingEstimator
"/>, which converts categorical values into numerical keys.
232
/// If set to <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByOccurrence"/>, keys are assigned in the order encountered.
233
/// If set to <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue"/>, values are sorted, and keys are assigned based on the sort order.</param>
247
public static
ValueToKeyMappingEstimator
MapValueToKey(this TransformsCatalog.ConversionTransforms catalog,
250
int maximumNumberOfKeys =
ValueToKeyMappingEstimator
.Defaults.MaximumNumberOfKeys,
251
ValueToKeyMappingEstimator
.KeyOrdinality keyOrdinality =
ValueToKeyMappingEstimator
.Defaults.Ordinality,
252
bool addKeyValueAnnotationsAsText =
ValueToKeyMappingEstimator
.Defaults.AddKeyValueAnnotationsAsText,
255
new[] { new
ValueToKeyMappingEstimator
.ColumnOptions(outputColumnName, inputColumnName, maximumNumberOfKeys, keyOrdinality, addKeyValueAnnotationsAsText) }, keyData);
258
/// Create a <see cref="
ValueToKeyMappingEstimator
"/>, which converts categorical values into keys.
267
/// If set to <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByOccurrence"/>, keys are assigned in the order encountered.
268
/// If set to <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue"/>, values are sorted, and keys are assigned based on the sort order.</param>
282
public static
ValueToKeyMappingEstimator
MapValueToKey(this TransformsCatalog.ConversionTransforms catalog,
284
int maximumNumberOfKeys =
ValueToKeyMappingEstimator
.Defaults.MaximumNumberOfKeys,
285
ValueToKeyMappingEstimator
.KeyOrdinality keyOrdinality =
ValueToKeyMappingEstimator
.Defaults.Ordinality,
286
bool addKeyValueAnnotationsAsText =
ValueToKeyMappingEstimator
.Defaults.AddKeyValueAnnotationsAsText,
291
var columnOptions = columns.Select(x => new
ValueToKeyMappingEstimator
.ColumnOptions(x.OutputColumnName, x.InputColumnName, maximumNumberOfKeys, keyOrdinality, addKeyValueAnnotationsAsText)).ToArray();
296
/// Create a <see cref="
ValueToKeyMappingEstimator
"/>, which converts value types into keys, optionally loading the keys to use from <paramref name="keyData"/>.
307
internal static
ValueToKeyMappingEstimator
MapValueToKey(this TransformsCatalog.ConversionTransforms catalog,
308
ValueToKeyMappingEstimator
.ColumnOptions[] columns, IDataView keyData = null)
Transforms\ValueToKeyMappingEstimator.cs (8)
45
/// <seealso cref="ConversionsExtensionsCatalog.MapValueToKey(TransformsCatalog.ConversionTransforms, InputOutputColumnPair[], int,
ValueToKeyMappingEstimator
.KeyOrdinality, bool, IDataView)"/>
46
/// <seealso cref="ConversionsExtensionsCatalog.MapValueToKey(TransformsCatalog.ConversionTransforms, string, string, int,
ValueToKeyMappingEstimator
.KeyOrdinality, bool, IDataView)"/>
119
/// If set to <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByOccurrence"/>, keys are assigned in the order encountered.
120
/// If set to <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue"/>, values are sorted, and keys are assigned based on the sort order.</param>
138
/// Initializes a new instance of <see cref="
ValueToKeyMappingEstimator
"/>.
145
/// If set to <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByOccurrence"/>, keys are assigned in the order encountered.
146
/// If set to <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue"/>, values are sorted, and keys are assigned based on the sort order.</param>
155
_host = env.Register(nameof(
ValueToKeyMappingEstimator
));
Transforms\ValueToKeyMappingTransformer.cs (13)
38
/// <see cref="ITransformer"/> resulting from fitting a <see cref="
ValueToKeyMappingEstimator
"/>.
56
public
ValueToKeyMappingEstimator
.KeyOrdinality? Sort;
100
public int MaxNumTerms =
ValueToKeyMappingEstimator
.Defaults.MaximumNumberOfKeys;
125
public
ValueToKeyMappingEstimator
.KeyOrdinality Sort =
ValueToKeyMappingEstimator
.Defaults.Ordinality;
212
private static (string outputColumnName, string inputColumnName)[] GetColumnPairs(
ValueToKeyMappingEstimator
.ColumnOptionsBase[] columns)
246
params
ValueToKeyMappingEstimator
.ColumnOptions[] columns) :
251
ValueToKeyMappingEstimator
.ColumnOptionsBase[] columns, IDataView keyData, bool autoConvert)
274
var cols = new
ValueToKeyMappingEstimator
.ColumnOptions[options.Columns.Length];
283
if (!Enum.IsDefined(typeof(
ValueToKeyMappingEstimator
.KeyOrdinality), options.Sort))
290
if (!Enum.IsDefined(typeof(
ValueToKeyMappingEstimator
.KeyOrdinality), sortOrder))
293
cols[i] = new
ValueToKeyMappingEstimator
.ColumnOptions(
515
IDataView keyData,
ValueToKeyMappingEstimator
.ColumnOptionsBase[] columns, IDataView trainingData, bool autoConvert)
Transforms\ValueToKeyMappingTransformerImpl.cs (4)
42
public static Builder Create(DataViewType type,
ValueToKeyMappingEstimator
.KeyOrdinality sortOrder)
50
Contracts.Assert(sortOrder ==
ValueToKeyMappingEstimator
.KeyOrdinality.ByOccurrence || sortOrder ==
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue);
51
bool sorted = sortOrder ==
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue;
Microsoft.ML.EntryPoints (1)
FeatureCombiner.cs (1)
255
Sort =
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue
Microsoft.ML.Samples (10)
Dynamic\DataOperations\FilterRowsByKeyColumnFraction.cs (1)
36
var
pipeline = mlContext.Transforms.Conversion.MapValueToKey("Age");
Dynamic\Trainers\MulticlassClassification\ImageClassification\ImageClassificationDefault.cs (1)
51
.
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue)
Dynamic\Trainers\MulticlassClassification\ImageClassification\LearningRateSchedulingCifarResnetTransferLearning.cs (2)
55
.
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue)
71
.
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue)
Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningEarlyStopping.cs (1)
50
.
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue)
Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningTrainTestSplit.cs (1)
50
.
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue)
Dynamic\Transforms\Conversion\KeyToValueToKey.cs (1)
45
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue));
Dynamic\Transforms\Conversion\MapValueToKeyMultiColumn.cs (3)
30
var
pipeline = mlContext.Transforms.Conversion.MapValueToKey(new[] {
34
keyOrdinality: Microsoft.ML.Transforms.
ValueToKeyMappingEstimator
81
var
pipelineWithLookupMap = mlContext.Transforms.Conversion
Microsoft.ML.Samples.GPU (5)
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\ImageClassificationDefault.cs (1)
51
.
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue)
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\LearningRateSchedulingCifarResnetTransferLearning.cs (2)
55
.
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue)
71
.
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue)
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningEarlyStopping.cs (1)
50
.
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue)
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningTrainTestSplit.cs (1)
50
.
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue)
Microsoft.ML.Tests (63)
OnnxConversionTest.cs (3)
1185
[CombinatorialValues(1, 2)] int maximumNumberOfKeys,
ValueToKeyMappingEstimator
.KeyOrdinality keyOrdinality,
1208
var
pipeline = mlContext.Transforms.Conversion.MapValueToKey("Key", "Value",
1776
var
pipeline1 = mlContext.Transforms.Conversion.MapValueToKey("Label");
TermEstimatorTests.cs (18)
71
var
pipe = new ValueToKeyMappingEstimator(ML, new[]{
72
new
ValueToKeyMappingEstimator
.ColumnOptions("TermFloat1", "float1"),
73
new
ValueToKeyMappingEstimator
.ColumnOptions("TermFloat4", "float4"),
74
new
ValueToKeyMappingEstimator
.ColumnOptions("TermDouble1", "double1"),
75
new
ValueToKeyMappingEstimator
.ColumnOptions("TermDouble4", "double4"),
76
new
ValueToKeyMappingEstimator
.ColumnOptions("TermInt1", "int1"),
77
new
ValueToKeyMappingEstimator
.ColumnOptions("TermText1", "text1"),
78
new
ValueToKeyMappingEstimator
.ColumnOptions("TermText2", "text2")
102
var
pipe = new ValueToKeyMappingEstimator(Env, new[]{
103
new
ValueToKeyMappingEstimator
.ColumnOptions("TermA", "A"),
104
new
ValueToKeyMappingEstimator
.ColumnOptions("TermB", "B"),
105
new
ValueToKeyMappingEstimator
.ColumnOptions("TermC", "C")
117
var
est = new ValueToKeyMappingEstimator(Env, new[]{
118
new
ValueToKeyMappingEstimator
.ColumnOptions("TermA", "A"),
119
new
ValueToKeyMappingEstimator
.ColumnOptions("TermB", "B"),
120
new
ValueToKeyMappingEstimator
.ColumnOptions("TermC", "C")
139
var
termEst = new ValueToKeyMappingEstimator(Env, new[] {
140
new
ValueToKeyMappingEstimator
.ColumnOptions("T", "Term") });
TrainerEstimators\TrainerEstimators.cs (4)
240
var
pipeline = new ValueToKeyMappingEstimator(Env, new[]{
241
new
ValueToKeyMappingEstimator
.ColumnOptions("Group", "Workclass"),
242
new
ValueToKeyMappingEstimator
.ColumnOptions("Label0", "Label") });
288
var
pipeline = new ValueToKeyMappingEstimator(Env, "Label");
Transformers\ConvertTests.cs (2)
291
var ci = new
ValueToKeyMappingEstimator
.ColumnOptions("CatA", "A");
292
var
pipe = mlContext.Transforms.Conversion.MapValueToKey(new[] { ci }, sideData);
Transformers\KeyToBinaryVectorEstimatorTest.cs (14)
49
new
ValueToKeyMappingEstimator
.ColumnOptions("TermA", "A"),
50
new
ValueToKeyMappingEstimator
.ColumnOptions("TermB", "B"),
51
new
ValueToKeyMappingEstimator
.ColumnOptions("TermC", "C", addKeyValueAnnotationsAsText:true)
69
new
ValueToKeyMappingEstimator
.ColumnOptions("A", "ScalarString"),
70
new
ValueToKeyMappingEstimator
.ColumnOptions("B", "VectorString") })
92
var
termEst = new ValueToKeyMappingEstimator(Env, new[] {
93
new
ValueToKeyMappingEstimator
.ColumnOptions("TA", "A", addKeyValueAnnotationsAsText: true),
94
new
ValueToKeyMappingEstimator
.ColumnOptions("TB", "B", addKeyValueAnnotationsAsText: true),
95
new
ValueToKeyMappingEstimator
.ColumnOptions("TC", "C"),
96
new
ValueToKeyMappingEstimator
.ColumnOptions("TD", "D") });
148
var
est = new ValueToKeyMappingEstimator(Env, new[]{
149
new
ValueToKeyMappingEstimator
.ColumnOptions("TermA", "A"),
150
new
ValueToKeyMappingEstimator
.ColumnOptions("TermB", "B", addKeyValueAnnotationsAsText:true),
151
new
ValueToKeyMappingEstimator
.ColumnOptions("TermC", "C")
Transformers\KeyToValueTests.cs (4)
40
new
ValueToKeyMappingEstimator
.ColumnOptions("A", "ScalarString"),
41
new
ValueToKeyMappingEstimator
.ColumnOptions("B", "VectorString") }).Fit(data).Transform(data);
74
new
ValueToKeyMappingEstimator
.ColumnOptions("A", "ScalarString"),
75
new
ValueToKeyMappingEstimator
.ColumnOptions("B", "VectorString") })
Transformers\KeyToVectorEstimatorTests.cs (18)
56
new
ValueToKeyMappingEstimator
.ColumnOptions("TermA", "A"),
57
new
ValueToKeyMappingEstimator
.ColumnOptions("TermB", "B"),
58
new
ValueToKeyMappingEstimator
.ColumnOptions("TermC", "C", addKeyValueAnnotationsAsText:true)
79
new
ValueToKeyMappingEstimator
.ColumnOptions("A", "ScalarString"),
80
new
ValueToKeyMappingEstimator
.ColumnOptions("B", "VectorString") })
102
var
termEst = new ValueToKeyMappingEstimator(Env, new[] {
103
new
ValueToKeyMappingEstimator
.ColumnOptions("TA", "A", addKeyValueAnnotationsAsText: true),
104
new
ValueToKeyMappingEstimator
.ColumnOptions("TB", "B"),
105
new
ValueToKeyMappingEstimator
.ColumnOptions("TC", "C", addKeyValueAnnotationsAsText: true),
106
new
ValueToKeyMappingEstimator
.ColumnOptions("TD", "D", addKeyValueAnnotationsAsText: true),
107
new
ValueToKeyMappingEstimator
.ColumnOptions("TE", "E"),
108
new
ValueToKeyMappingEstimator
.ColumnOptions("TF", "F"),
109
new
ValueToKeyMappingEstimator
.ColumnOptions("TG", "G"),
110
new
ValueToKeyMappingEstimator
.ColumnOptions("TH", "H", addKeyValueAnnotationsAsText: true) });
207
var
est = new ValueToKeyMappingEstimator(Env, new[]{
208
new
ValueToKeyMappingEstimator
.ColumnOptions("TermA", "A"),
209
new
ValueToKeyMappingEstimator
.ColumnOptions("TermB", "B"),
210
new
ValueToKeyMappingEstimator
.ColumnOptions("TermC", "C")
Microsoft.ML.TorchSharp.Tests (1)
TextClassificationTests.cs (1)
316
var
dataPrep = ML.Transforms.Conversion.MapValueToKey("Label");
Microsoft.ML.Transforms (27)
CategoricalCatalog.cs (10)
32
/// <param name="keyOrdinality">How items should be ordered when vectorized. If <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByOccurrence"/>
33
/// choosen they will be in the order encountered. If <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue"/>,
47
int maximumNumberOfKeys =
ValueToKeyMappingEstimator
.Defaults.MaximumNumberOfKeys,
48
ValueToKeyMappingEstimator
.KeyOrdinality keyOrdinality =
ValueToKeyMappingEstimator
.Defaults.Ordinality,
66
/// <param name="keyOrdinality">How items should be ordered when vectorized. If <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByOccurrence"/>
67
/// choosen they will be in the order encountered. If <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue"/>,
80
int maximumNumberOfKeys =
ValueToKeyMappingEstimator
.Defaults.MaximumNumberOfKeys,
81
ValueToKeyMappingEstimator
.KeyOrdinality keyOrdinality =
ValueToKeyMappingEstimator
.Defaults.Ordinality,
OneHotEncoding.cs (11)
127
internal OneHotEncodingTransformer(
ValueToKeyMappingEstimator
term, IEstimator<ITransformer> toVector, IDataView input)
194
/// <seealso cref="CategoricalCatalog.OneHotEncoding(TransformsCatalog.CategoricalTransforms, InputOutputColumnPair[], OneHotEncodingEstimator.OutputKind, int,
ValueToKeyMappingEstimator
.KeyOrdinality, IDataView)"/>
195
/// <seealso cref="CategoricalCatalog.OneHotEncoding(TransformsCatalog.CategoricalTransforms, string, string, OneHotEncodingEstimator.OutputKind, int,
ValueToKeyMappingEstimator
.KeyOrdinality, IDataView)"/>
235
internal sealed class ColumnOptions :
ValueToKeyMappingEstimator
.ColumnOptionsBase
245
/// <param name="keyOrdinality">How items should be ordered when vectorized. If <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByOccurrence"/> choosen they will be in the order encountered.
246
/// If <see cref="
ValueToKeyMappingEstimator
.KeyOrdinality.ByValue"/>, items are sorted according to their default comparison, for example, text sorting will be case sensitive (for example, 'A' then 'Z' then 'a').</param>
249
int maximumNumberOfKeys =
ValueToKeyMappingEstimator
.Defaults.MaximumNumberOfKeys,
ValueToKeyMappingEstimator
.KeyOrdinality keyOrdinality =
ValueToKeyMappingEstimator
.Defaults.Ordinality)
265
private
ValueToKeyMappingEstimator
_term;
344
_term = (
ValueToKeyMappingEstimator
)_term.WithOnFitDelegate(onFit);
OneHotHashEncoding.cs (1)
327
_host = env.Register(nameof(
ValueToKeyMappingEstimator
));
Text\WordBagTransform.cs (5)
490
var columnOptions = new List<
ValueToKeyMappingEstimator
.ColumnOptionsBase>();
496
var colOptions = new
ValueToKeyMappingEstimator
.ColumnOptions(
502
keyOrdinality: termLoaderArgs?.Sort ??
ValueToKeyMappingEstimator
.KeyOrdinality.ByOccurrence);
605
public
ValueToKeyMappingEstimator
.KeyOrdinality Sort =
ValueToKeyMappingEstimator
.KeyOrdinality.ByOccurrence;