21 writes to ML
Microsoft.ML.TestFramework (1)
BaseTestBaseline.cs (1)
109
ML
= new MLContext(42);
Microsoft.ML.Tests (20)
PermutationFeatureImportanceTests.cs (20)
52
ML
= new MLContext(42);
61
ML
= new MLContext(42);
126
ML
= new MLContext(42);
135
ML
= new MLContext(42);
194
ML
= new MLContext(42);
203
ML
= new MLContext(42);
282
ML
= new MLContext(42);
291
ML
= new MLContext(42);
357
ML
= new MLContext(42);
366
ML
= new MLContext(42);
431
ML
= new MLContext(42);
440
ML
= new MLContext(42);
539
ML
= new MLContext(42);
548
ML
= new MLContext(42);
612
ML
= new MLContext(42);
621
ML
= new MLContext(42);
691
ML
= new MLContext(0);
700
ML
= new MLContext(0);
759
ML
= new MLContext(42);
768
ML
= new MLContext(42);
1199 references to ML
Microsoft.ML.Core.Tests (17)
UnitTests\TestCustomTypeRegister.cs (9)
184
var tribeDataView =
ML
.Data.LoadFromEnumerable(tribe);
185
var heroEstimator = new CustomMappingEstimator<AlienHero, SuperAlienHero>(
ML
, AlienFusionProcess.MergeBody, "LambdaAlienHero");
188
var tribeEnumerable =
ML
.Data.CreateEnumerable<SuperAlienHero>(tribeTransformed, false).ToList();
193
ML
.Model.Save(model, tribeDataView.Schema, "customTransform.zip");
194
modelForPrediction =
ML
.Model.Load("customTransform.zip", out var tribeDataViewSchema);
205
var engine =
ML
.Model.CreatePredictionEngine<AlienHero, SuperAlienHero>(modelForPrediction);
223
ML
.ComponentCatalog.RegisterAssembly(typeof(AlienFusionProcess).Assembly);
226
var trainedModel =
ML
.Model.Load(modelPath, out var dataViewSchema);
228
var engine =
ML
.Model.CreatePredictionEngine<AlienHero, SuperAlienHero>(trainedModel);
UnitTests\TestEntryPoints.cs (8)
2014
var mlr =
ML
.MulticlassClassification.Trainers.LbfgsMaximumEntropy();
4719
var data =
ML
.Data.LoadFromTextFile(dataPath, new[]
4724
var estimator =
ML
.Transforms.CountTargetEncode("Text", builder: CountTableBuilderBase.CreateDictionaryCountTableBuilder(), combine: false);
4726
ML
.Model.Save(transformer, data.Schema, countsModel);
4761
var data =
ML
.Data.LoadFromTextFile(dataPath, new[]
4766
var estimator =
ML
.Transforms.CountTargetEncode("Text", builder: CountTableBuilderBase.CreateDictionaryCountTableBuilder(), combine: false);
4768
ML
.Model.Save(transformer, data.Schema, countsModel);
6664
ML
.Data.SaveAsText(data, f);
Microsoft.ML.OnnxTransformerTest (97)
DnnImageFeaturizerTest.cs (27)
78
var pipe =
ML
.Transforms.DnnFeaturizeImage("output_1", m => m.ModelSelector.ResNet18(m.Environment, m.OutputColumn, m.InputColumn), "data_0");
80
var invalidDataWrongNames =
ML
.Data.LoadFromEnumerable(xyData);
81
var invalidDataWrongTypes =
ML
.Data.LoadFromEnumerable(stringData);
82
var invalidDataWrongVectorSize =
ML
.Data.LoadFromEnumerable(sizeData);
104
var data =
ML
.Data.LoadFromTextFile(dataFile, new[] {
109
var pipe =
ML
.Transforms.LoadImages("data_0", imageFolder, "imagePath")
110
.Append(
ML
.Transforms.ResizeImages("data_0", imageHeight, imageWidth))
111
.Append(
ML
.Transforms.ExtractPixels("data_0", interleavePixelColors: true))
112
.Append(
ML
.Transforms.DnnFeaturizeImage("output_1", m => m.ModelSelector.ResNet18(m.Environment, m.OutputColumn, m.InputColumn), "data_0"));
143
var dataView =
ML
.Data.LoadFromEnumerable(
153
var est =
ML
.Transforms.DnnFeaturizeImage(outputNames, m => m.ModelSelector.ResNet18(m.Environment, m.OutputColumn, m.InputColumn), inputNames);
214
var data =
ML
.Data.LoadFromTextFile<ModelInput>(
221
var dataProcessPipeline =
ML
.Transforms.Conversion.MapValueToKey("Label", "Label")
222
.Append(
ML
.Transforms.LoadImages("ImagePath_featurized", imageFolder, "ImagePath"))
223
.Append(
ML
.Transforms.ResizeImages("ImagePath_featurized", 224, 224, "ImagePath_featurized"))
224
.Append(
ML
.Transforms.ExtractPixels("ImagePath_featurized", "ImagePath_featurized"))
225
.Append(
ML
.Transforms.DnnFeaturizeImage("ImagePath_featurized", m => m.ModelSelector.ResNet18(m.Environment, m.OutputColumn, m.InputColumn), "ImagePath_featurized"))
226
.Append(
ML
.Transforms.Concatenate("Features", new[] { "ImagePath_featurized" }))
227
.Append(
ML
.Transforms.NormalizeMinMax("Features", "Features"))
228
.AppendCacheCheckpoint(
ML
);
230
var trainer =
ML
.MulticlassClassification.Trainers.OneVersusAll(
ML
.BinaryClassification.Trainers.AveragedPerceptron(labelColumnName: "Label", numberOfIterations: 10, featureColumnName: "Features"), labelColumnName: "Label")
231
.Append(
ML
.Transforms.Conversion.MapKeyToValue("PredictedLabel", "PredictedLabel"));
237
ML
.Model.Save(model, data.Schema, modelPath);
238
var loadedModel =
ML
.Model.Load(modelPath, out var inputSchema);
240
var predEngine =
ML
.Model.CreatePredictionEngine<ModelInput, ModelOutput>(loadedModel);
241
ModelInput sample =
ML
.Data.CreateEnumerable<ModelInput>(data, false).First();
OnnxTransformTests.cs (70)
120
ML
.GpuDeviceId = _gpuDeviceId;
121
ML
.FallbackToCpu = _fallbackToCpu;
131
var dataView =
ML
.Data.LoadFromEnumerable(
157
ML
.Transforms.ApplyOnnxModel(options) :
158
ML
.Transforms.ApplyOnnxModel(options.OutputColumns, options.InputColumns, modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
160
var invalidDataWrongNames =
ML
.Data.LoadFromEnumerable(xyData);
161
var invalidDataWrongTypes =
ML
.Data.LoadFromEnumerable(stringData);
162
var invalidDataWrongVectorSize =
ML
.Data.LoadFromEnumerable(sizeData);
186
var dataView =
ML
.Data.LoadFromEnumerable(
196
var est =
ML
.Transforms.ApplyOnnxModel(outputNames, inputNames, modelFile, gpuDeviceId, fallbackToCpu);
249
var data =
ML
.Data.LoadFromTextFile(dataFile, new[] {
254
var pipe =
ML
.Transforms.LoadImages("data_0", imageFolder, "imagePath")
255
.Append(
ML
.Transforms.ResizeImages("data_0", imageHeight, imageWidth))
256
.Append(
ML
.Transforms.ExtractPixels("data_0", interleavePixelColors: true))
257
.Append(
ML
.Transforms.ApplyOnnxModel("softmaxout_1", "data_0", fileStream, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu));
266
ML
.Model.Save(model, data.Schema, tempPath);
267
var loadedModel =
ML
.Model.Load(tempPath, out DataViewSchema modelSchema);
300
var data =
ML
.Data.LoadFromTextFile(dataFile, new[] {
305
var pipe =
ML
.Transforms.LoadImages("data_0", imageFolder, "imagePath")
306
.Append(
ML
.Transforms.ResizeImages("data_0", imageHeight, imageWidth))
307
.Append(
ML
.Transforms.ExtractPixels("data_0", interleavePixelColors: true))
308
.Append(
ML
.Transforms.ApplyOnnxModel("softmaxout_1", "data_0", modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu));
317
ML
.Model.Save(model, data.Schema, tempPath);
318
var loadedModel =
ML
.Model.Load(tempPath, out DataViewSchema modelSchema);
361
var dataView =
ML
.Data.LoadFromEnumerable(
369
var pipeline =
ML
.Transforms.ApplyOnnxModel("softmaxout_1", "data_0", modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
394
var dataView =
ML
.Data.LoadFromEnumerable(
407
ML
.SetOnnxSessionOption(onnxSessionOptions);
408
var pipeline =
ML
.Transforms.ApplyOnnxModel("softmaxout_1", "data_0", modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
416
ML
.SetOnnxSessionOption(onnxSessionOptions);
417
Assert.Throws<InvalidOperationException>(() =>
ML
.Transforms.ApplyOnnxModel("softmaxout_1", "data_0", modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu));
428
var dataView =
ML
.Data.LoadFromEnumerable(
436
var pipeline =
ML
.Transforms.ApplyOnnxModel(new[] { "outa", "outb" }, new[] { "ina", "inb" }, modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
467
var dataView =
ML
.Data.LoadFromEnumerable(
476
var pipeline =
ML
.Transforms.ApplyOnnxModel(new[] { "outb", "outa" }, new[] { "ina", "inb" }, modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
502
pipeline =
ML
.Transforms.ApplyOnnxModel(new[] { "outb" }, new[] { "ina", "inb" }, modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
536
var pipeline =
ML
.Transforms.ApplyOnnxModel(modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
562
var pipeline =
ML
.Transforms.ApplyOnnxModel(modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
637
var dataView =
ML
.Data.LoadFromEnumerable(dataPoints);
643
var pipeline =
ML
.Transforms.ExtractPixels("data_0", "Image") // Map column "Image" to column "data_0"
644
.Append(
ML
.Transforms.ApplyOnnxModel("softmaxout_1", "data_0", modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu)); // Map column "data_0" to column "softmaxout_1"
651
var transformedDataPoints =
ML
.Data.CreateEnumerable<ImageDataPoint>(onnx, false).ToList();
693
var dataView =
ML
.Data.LoadFromEnumerable(dataPoints);
694
var pipeline =
ML
.Transforms.ApplyOnnxModel(new[] { "output" }, new[] { "input" }, modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
719
var transformedDataPoints =
ML
.Data.CreateEnumerable<ZipMapInt64Output>(transformedDataView, false).ToList();
746
var dataView =
ML
.Data.LoadFromEnumerable(dataPoints);
747
var pipeline =
ML
.Transforms.ApplyOnnxModel(new[] { "output" }, new[] { "input" }, modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
772
var transformedDataPoints =
ML
.Data.CreateEnumerable<ZipMapStringOutput>(transformedDataView, false).ToList();
794
var onnxModel = OnnxModel.CreateFromBytes(modelInBytes,
ML
);
812
var onnxModel = new OnnxModel(
ML
, modelFile);
860
var dataView =
ML
.Data.LoadFromEnumerable(dataPoints);
861
var pipeline =
ML
.Transforms.CustomMapping(action, contractName: null);
864
var transformedDataPoints =
ML
.Data.CreateEnumerable<OnnxMapOutput>(transformedDataView, false).ToList();
900
var dataView =
ML
.Data.LoadFromEnumerable(dataPoints);
909
pipeline[0] =
ML
.Transforms.ApplyOnnxModel(
916
pipeline[1] =
ML
.Transforms.ApplyOnnxModel(
923
pipeline[2] =
ML
.Transforms.ApplyOnnxModel(modelFile, shapeDictionary, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
930
var transformedDataPoints =
ML
.Data.CreateEnumerable<PredictionWithCustomShape>(transformedDataView, false).ToList();
962
var dataView =
ML
.Data.LoadFromEnumerable(
972
var pipeline =
ML
.Transforms.ApplyOnnxModel(new[] { "outa", "outb" }, new[] { "ina", "inb" },
1070
var dataView =
ML
.Data.LoadFromEnumerable(dataPoints);
1072
var pipeline =
ML
.Transforms.ApplyOnnxModel(nameof(PredictionWithCustomShape.argmax),
1084
ML
.Model.Save(model, null, fs);
1088
loadedModel =
ML
.Model.Load(fs, out var schema);
1094
var transformedDataPoints =
ML
.Data.CreateEnumerable<PredictionWithCustomShape>(transformedDataView, false).ToList();
1129
var data =
ML
.Data.LoadFromTextFile(dataFile, new[] {
1134
var pipe =
ML
.Transforms.LoadImages("data_0", imageFolder, "imagePath")
1135
.Append(
ML
.Transforms.ResizeImages("data_0", imageHeight, imageWidth))
1136
.Append(
ML
.Transforms.ExtractPixels("data_0", interleavePixelColors: true))
1137
.Append(
ML
.Transforms.ApplyOnnxModel(new[] { "softmaxout_1" }, new[] { "data_0" }, modelFile,
Microsoft.ML.Predictor.Tests (11)
TestPredictors.cs (11)
627
var dataView =
ML
.Data.LoadFromTextFile(dataPath);
632
fastTrees[i] = FastTree.TrainBinary(
ML
, new FastTreeBinaryTrainer.Options
648
var dataView =
ML
.Data.LoadFromTextFile(dataPath);
650
var cat =
ML
.Transforms.Categorical.OneHotEncoding("Features", "Categories").Fit(dataView).Transform(dataView);
654
fastTrees[i] = FastTree.TrainBinary(
ML
, new FastTreeBinaryTrainer.Options
757
var dataView =
ML
.Data.LoadFromTextFile(dataPath);
761
FastTree.TrainBinary(
ML
, new FastTreeBinaryTrainer.Options
769
AveragedPerceptronTrainer.TrainBinary(
ML
, new AveragedPerceptronTrainer.Options()
777
LbfgsLogisticRegressionBinaryTrainer.TrainBinary(
ML
, new LbfgsLogisticRegressionBinaryTrainer.Options()
785
LbfgsLogisticRegressionBinaryTrainer.TrainBinary(
ML
, new LbfgsLogisticRegressionBinaryTrainer.Options()
803
var dataView =
ML
.Data.LoadFromTextFile(dataPath);
Microsoft.ML.TensorFlow.Tests (25)
TensorFlowEstimatorTests.cs (25)
64
var dataView =
ML
.Data.LoadFromEnumerable(
81
using var model =
ML
.Model.LoadTensorFlowModel(modelFile);
84
var invalidDataWrongNames =
ML
.Data.LoadFromEnumerable(xyData);
85
var invalidDataWrongTypes =
ML
.Data.LoadFromEnumerable(stringData);
86
var invalidDataWrongVectorSize =
ML
.Data.LoadFromEnumerable(sizeData);
105
var dataView =
ML
.Data.LoadFromEnumerable(
123
using var model =
ML
.Model.LoadTensorFlowModel(modelFile);
156
var data =
ML
.Data.LoadFromTextFile(dataFile, new[] {
162
var pipe =
ML
.Transforms.LoadImages("Input", imageFolder, "imagePath")
163
.Append(
ML
.Transforms.ResizeImages("Input", imageHeight, imageWidth))
164
.Append(
ML
.Transforms.ExtractPixels("Input", interleavePixelColors: true))
165
.Append(
ML
.Model.LoadTensorFlowModel(modelLocation).ScoreTensorFlowModel("Output", "Input"));
198
var data =
ML
.Data.LoadFromTextFile(dataFile, new[] {
205
var pipe =
ML
.Transforms.LoadImages("Input", imageFolder, "imagePath")
206
.Append(
ML
.Transforms.ResizeImages("Input", imageHeight, imageWidth))
207
.Append(
ML
.Transforms.ExtractPixels("Input", interleavePixelColors: true))
208
.Append(
ML
.Model.LoadTensorFlowModel(modelLocation, false).ScoreTensorFlowModel("Output", "Input"));
219
pipe =
ML
.Transforms.LoadImages("Input", imageFolder, "imagePath")
220
.Append(
ML
.Transforms.ResizeImages("Input", imageHeight, imageWidth))
221
.Append(
ML
.Transforms.ExtractPixels("Input", interleavePixelColors: true))
222
.Append(
ML
.Model.LoadTensorFlowModel(modelLocation).ScoreTensorFlowModel("Output", "Input"));
249
var data =
ML
.Data.LoadFromTextFile(dataFile, new[] {
255
var pipe =
ML
.Transforms.LoadImages("Input", imageFolder, "imagePath")
256
.Append(
ML
.Transforms.ResizeImages("Input", imageHeight, imageWidth))
257
.Append(
ML
.Transforms.ExtractPixels("Input", interleavePixelColors: true))
Microsoft.ML.TestFramework (10)
BaseTestBaseline.cs (3)
110
ML
.Log += LogTestOutput;
111
ML
.AddStandardComponents();
1024
return Maml.MainCore(
ML
, args, false);
DataPipe\TestDataPipe.cs (4)
858
IDataView view1 =
ML
.Transforms.SelectColumns(colsChoose).Fit(pipe).Transform(pipe);
859
view2 =
ML
.Transforms.SelectColumns(colsChoose).Fit(view2).Transform(view2);
1549
var est =
ML
.Transforms.Text.LatentDirichletAllocation(opt);
1606
var lda =
ML
.Transforms.Text.LatentDirichletAllocation("Zeros").Fit(srcView).Transform(srcView);
DataPipe\TestDataPipeBase.cs (3)
83
ML
.Model.Save(transformer, validFitInput.Schema, modelPath);
88
loadedTransformer =
ML
.Model.Load(fs, out loadedInputSchema);
424
var loadedData =
ML
.Data.LoadFromTextFile(pathData, options: args);
Microsoft.ML.Tests (957)
AnomalyDetectionTests.cs (4)
34
var metrics =
ML
.AnomalyDetection.Evaluate(transformedData, falsePositiveCount: 5);
50
Assert.Throws<ArgumentOutOfRangeException>(() =>
ML
.AnomalyDetection.Evaluate(transformedData));
239
var loader =
ML
.Data.CreateTextLoader(new[]
249
var trainer =
ML
.AnomalyDetection.Trainers.RandomizedPca();
BinaryLoaderSaverTests.cs (2)
24
var data =
ML
.Data.LoadFromBinary(GetDataPath("schema-codec-test.idv"));
30
ML
.Data.SaveAsText(data, fs, headerRow: false);
CachingTests.cs (16)
45
var pipe =
ML
.Transforms.CopyColumns("F1", "Features")
46
.Append(
ML
.Transforms.NormalizeMinMax("Norm1", "F1"))
47
.Append(
ML
.Transforms.NormalizeMeanVariance("Norm2", "F1"));
49
pipe.Fit(
ML
.Data.LoadFromEnumerable(trainData));
54
pipe =
ML
.Transforms.CopyColumns("F1", "Features")
55
.AppendCacheCheckpoint(
ML
)
56
.Append(
ML
.Transforms.NormalizeMinMax("Norm1", "F1"))
57
.Append(
ML
.Transforms.NormalizeMeanVariance("Norm2", "F1"));
59
pipe.Fit(
ML
.Data.LoadFromEnumerable(trainData));
74
new EstimatorChain<ITransformer>().AppendCacheCheckpoint(
ML
)
75
.Append(
ML
.Transforms.CopyColumns("F1", "Features"))
76
.Append(
ML
.Transforms.NormalizeMinMax("Norm1", "F1"))
77
.Append(
ML
.Transforms.NormalizeMeanVariance("Norm2", "F1"));
84
var data =
ML
.Data.LoadFromEnumerable(src);
90
data =
ML
.Data.LoadFromEnumerable(src);
91
data =
ML
.Data.Cache(data);
CalibratedModelParametersTests.cs (12)
27
var model =
ML
.BinaryClassification.Trainers.LbfgsLogisticRegression(
31
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
33
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
49
var model =
ML
.BinaryClassification.Trainers.Gam(
53
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
55
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
72
var model =
ML
.BinaryClassification.Trainers.FastTree(
76
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
78
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
133
var pipeline =
ML
.Transforms.Concatenate("Features", "X1", "X2Important", "X3", "X4Rand")
134
.Append(
ML
.Transforms.NormalizeMinMax("Features"));
136
return pipeline.Append(
ML
.Transforms.Conversion.ConvertType("Label", outputKind: DataKind.Boolean))
FeatureContributionTests.cs (53)
31
var model =
ML
.Regression.Trainers.Ols().Fit(data);
33
var estPipe =
ML
.Transforms.CalculateFeatureContribution(model)
34
.Append(
ML
.Transforms.CalculateFeatureContribution(model, normalize: false))
35
.Append(
ML
.Transforms.CalculateFeatureContribution(model, numberOfPositiveContributions: 0))
36
.Append(
ML
.Transforms.CalculateFeatureContribution(model, numberOfNegativeContributions: 0))
37
.Append(
ML
.Transforms.CalculateFeatureContribution(model, numberOfPositiveContributions: 0, numberOfNegativeContributions: 0));
47
TestFeatureContribution(
ML
.Regression.Trainers.Ols(), GetSparseDataset(numberOfInstances: 100), "LeastSquaresRegression");
53
TestFeatureContribution(
ML
.Regression.Trainers.LightGbm(), GetSparseDataset(numberOfInstances: 100), "LightGbmRegression");
59
TestFeatureContribution(
ML
.Regression.Trainers.LightGbm(new LightGbmRegressionTrainer.Options() { UseCategoricalSplit = true }), GetOneHotEncodedData(numberOfInstances: 100), "LightGbmRegressionWithCategoricalSplit");
65
TestFeatureContribution(
ML
.Regression.Trainers.FastTree(), GetSparseDataset(numberOfInstances: 100), "FastTreeRegression");
71
TestFeatureContribution(
ML
.Regression.Trainers.FastForest(), GetSparseDataset(numberOfInstances: 100), "FastForestRegression");
77
TestFeatureContribution(
ML
.Regression.Trainers.FastTreeTweedie(), GetSparseDataset(numberOfInstances: 100), "FastTreeTweedieRegression");
83
TestFeatureContribution(
ML
.Regression.Trainers.Sdca(
90
TestFeatureContribution(
ML
.Regression.Trainers.OnlineGradientDescent(), GetSparseDataset(numberOfInstances: 100), "OnlineGradientDescentRegression");
96
TestFeatureContribution(
ML
.Regression.Trainers.LbfgsPoissonRegression(
103
TestFeatureContribution(
ML
.Regression.Trainers.Gam(), GetSparseDataset(numberOfInstances: 100), "GAMRegression");
110
TestFeatureContribution(
ML
.Ranking.Trainers.FastTree(), GetSparseDataset(TaskType.Ranking, 100), "FastTreeRanking");
116
TestFeatureContribution(
ML
.Ranking.Trainers.LightGbm(), GetSparseDataset(TaskType.Ranking, 100), "LightGbmRanking");
123
TestFeatureContribution(
ML
.BinaryClassification.Trainers.AveragedPerceptron(), GetSparseDataset(TaskType.BinaryClassification, 100), "AveragePerceptronBinary");
129
TestFeatureContribution(
ML
.BinaryClassification.Trainers.LinearSvm(), GetSparseDataset(TaskType.BinaryClassification, 100), "SVMBinary");
135
TestFeatureContribution(
ML
.BinaryClassification.Trainers.LbfgsLogisticRegression(), GetSparseDataset(TaskType.BinaryClassification, 100), "LogisticRegressionBinary", 3);
141
TestFeatureContribution(
ML
.BinaryClassification.Trainers.FastForest(), GetSparseDataset(TaskType.BinaryClassification, 100), "FastForestBinary");
147
TestFeatureContribution(
ML
.BinaryClassification.Trainers.FastTree(), GetSparseDataset(TaskType.BinaryClassification, 100), "FastTreeBinary");
153
TestFeatureContribution(
ML
.BinaryClassification.Trainers.LightGbm(), GetSparseDataset(TaskType.BinaryClassification, 100), "LightGbmBinary");
159
TestFeatureContribution(
ML
.BinaryClassification.Trainers.SdcaNonCalibrated(
166
TestFeatureContribution(
ML
.BinaryClassification.Trainers.SgdCalibrated(
177
TestFeatureContribution(
ML
.BinaryClassification.Trainers.SymbolicSgdLogisticRegression(
188
TestFeatureContribution(
ML
.BinaryClassification.Trainers.Gam(), GetSparseDataset(TaskType.BinaryClassification, 100), "GAMBinary");
201
var est =
ML
.Transforms.CalculateFeatureContribution(model, numberOfPositiveContributions: 3, numberOfNegativeContributions: 0)
202
.Append(
ML
.Transforms.CalculateFeatureContribution(model, numberOfPositiveContributions: 0, numberOfNegativeContributions: 3))
203
.Append(
ML
.Transforms.CalculateFeatureContribution(model, numberOfPositiveContributions: 1, numberOfNegativeContributions: 1))
204
.Append(
ML
.Transforms.CalculateFeatureContribution(model, numberOfPositiveContributions: 1, numberOfNegativeContributions: 1, normalize: false));
225
var est =
ML
.Transforms.CalculateFeatureContribution(model, numberOfPositiveContributions: 3, numberOfNegativeContributions: 0)
226
.Append(
ML
.Transforms.CalculateFeatureContribution(model, numberOfPositiveContributions: 0, numberOfNegativeContributions: 3))
227
.Append(
ML
.Transforms.CalculateFeatureContribution(model, numberOfPositiveContributions: 1, numberOfNegativeContributions: 1))
228
.Append(
ML
.Transforms.CalculateFeatureContribution(model, numberOfPositiveContributions: 1, numberOfNegativeContributions: 1, normalize: false));
242
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, OutputHeader = false });
243
var savedData =
ML
.Data.TakeRows(estimator.Fit(data).Transform(data), 4);
314
var pipeline =
ML
.Transforms.Concatenate("Features", "X1", "X2VBuffer", "X3Important")
315
.Append(
ML
.Transforms.NormalizeMinMax("Features"));
318
return pipeline.Append(
ML
.Transforms.Conversion.ConvertType("Label", outputKind: DataKind.Boolean))
321
return pipeline.Append(
ML
.Transforms.Conversion.MapValueToKey("Label"))
324
return pipeline.Append(
ML
.Transforms.Conversion.MapValueToKey("GroupId"))
418
IDataView trainingDataView =
ML
.Data.LoadFromTextFile<TaxiTrip>(trainDataPath, hasHeader: true, separatorChar: ',');
424
var dataProcessPipeline =
ML
.Transforms.CopyColumns(outputColumnName: DefaultColumnNames.Label, inputColumnName: nameof(TaxiTrip.FareAmount))
425
.Append(
ML
.Transforms.Categorical.OneHotEncoding(outputColumnName: vendorIdEncoded, inputColumnName: nameof(TaxiTrip.VendorId)))
426
.Append(
ML
.Transforms.Categorical.OneHotEncoding(outputColumnName: rateCodeEncoded, inputColumnName: nameof(TaxiTrip.RateCode)))
427
.Append(
ML
.Transforms.Categorical.OneHotEncoding(outputColumnName: paymentTypeEncoded, inputColumnName: nameof(TaxiTrip.PaymentType)))
428
.Append(
ML
.Transforms.NormalizeMeanVariance(outputColumnName: nameof(TaxiTrip.PassengerCount)))
429
.Append(
ML
.Transforms.NormalizeMeanVariance(outputColumnName: nameof(TaxiTrip.TripTime)))
430
.Append(
ML
.Transforms.NormalizeMeanVariance(outputColumnName: nameof(TaxiTrip.TripDistance)))
431
.Append(
ML
.Transforms.Concatenate(DefaultColumnNames.Features, vendorIdEncoded, rateCodeEncoded, paymentTypeEncoded,
434
var someRows =
ML
.Data.TakeRows(trainingDataView, numberOfInstances);
ImagesTests.cs (6)
86
ML
.Model.Save(model, null, fs);
89
model2 =
ML
.Model.Load(fs, out var schema);
236
var data =
ML
.Data.LoadFromEnumerable(images);
239
var pipeline =
ML
.Transforms.ConvertToGrayscale("GrayImage", "Image");
248
var transformedDataPoints =
ML
.Data.CreateEnumerable<ImageDataPoint>(transformedData, false);
276
var engine =
ML
.Model.CreatePredictionEngine<ImageDataPoint, ImageDataPoint>(model);
OnnxConversionTest.cs (45)
280
var dataView =
ML
.Data.LoadFromTextFile<BreastCancerBinaryClassification>(dataPath, separatorChar: '\t', hasHeader: true);
283
ML
.BinaryClassification.Trainers.AveragedPerceptron(),
284
ML
.BinaryClassification.Trainers.FastForest(),
285
ML
.BinaryClassification.Trainers.FastTree(),
286
ML
.BinaryClassification.Trainers.LbfgsLogisticRegression(),
287
ML
.BinaryClassification.Trainers.LinearSvm(),
288
ML
.BinaryClassification.Trainers.Prior(),
289
ML
.BinaryClassification.Trainers.SdcaLogisticRegression(),
290
ML
.BinaryClassification.Trainers.SdcaNonCalibrated(),
291
ML
.BinaryClassification.Trainers.SgdCalibrated(),
292
ML
.BinaryClassification.Trainers.SgdNonCalibrated(),
293
ML
.BinaryClassification.Trainers.SymbolicSgdLogisticRegression(),
297
estimators.Add(
ML
.BinaryClassification.Trainers.LightGbm());
300
var initialPipeline =
ML
.Transforms.ReplaceMissingValues("Features").
301
Append(
ML
.Transforms.NormalizeMinMax("Features"));
319
IDataView dataSoloCalibrator =
ML
.Data.LoadFromEnumerable(GetCalibratorTestData());
324
IDataView dataSoloCalibratorNonStandard =
ML
.Data.LoadFromEnumerable(GetCalibratorTestDataNonStandard());
334
CommonCalibratorOnnxConversionTest(
ML
.BinaryClassification.Calibrators.Platt(),
335
ML
.BinaryClassification.Calibrators.Platt(scoreColumnName: "ScoreX"));
342
CommonCalibratorOnnxConversionTest(
ML
.BinaryClassification.Calibrators.Platt(slope: -1f, offset: -0.05f),
343
ML
.BinaryClassification.Calibrators.Platt(slope: -1f, offset: -0.05f, scoreColumnName: "ScoreX"));
349
CommonCalibratorOnnxConversionTest(
ML
.BinaryClassification.Calibrators.Naive(),
350
ML
.BinaryClassification.Calibrators.Naive(scoreColumnName: "ScoreX"));
386
var dataView =
ML
.Data.LoadFromTextFile(dataPath, new[] {
769
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
870
var dataView =
ML
.Data.LoadFromTextFile(dataPath, new[] {
975
var pipeline =
ML
.Transforms.ProjectToPrincipalComponents("pca", "features", rank: 5, seed: 1, ensureZeroMean: zeroMean);
1034
var data =
ML
.Data.LoadFromTextFile(dataFile, new[]
1042
var pipeline =
ML
.Transforms.Conversion.Hash("ValueHashed", "Value");
1603
var dataView =
ML
.Data.LoadFromTextFile(dataPath, new[] {
1886
var dataView =
ML
.Data.LoadFromTextFile(dataPath, new[] {
2025
var dataView =
ML
.Data.LoadFromTextFile<BreastCancerCatFeatureExample>(dataPath);
2026
var pipe =
ML
.Transforms.Categorical.OneHotHashEncoding(new[]{
2114
pipe =
ML
.Transforms.NormalizeMinMax(nameof(DataPoint.Features), fixZero: fixZero);
2119
pipe =
ML
.Transforms.NormalizeMinMax(nameof(DataPoint.Features), fixZero: fixZero);
2124
pipe =
ML
.Transforms.NormalizeMeanVariance(nameof(DataPoint.Features), fixZero: fixZero);
2129
pipe =
ML
.Transforms.NormalizeMeanVariance(nameof(DataPoint.Features), fixZero: fixZero);
2134
pipe =
ML
.Transforms.NormalizeLogMeanVariance(nameof(DataPoint.Features), fixZero: fixZero, useCdf: false);
2139
pipe =
ML
.Transforms.NormalizeLogMeanVariance(nameof(DataPoint.Features), fixZero: fixZero, useCdf: false);
2144
pipe =
ML
.Transforms.NormalizeRobustScaling(nameof(DataPoint.Features), centerData: fixZero);
2149
pipe =
ML
.Transforms.NormalizeRobustScaling(nameof(DataPoint.Features), centerData: fixZero);
2186
var dataView =
ML
.Data.LoadFromEnumerable(data, schemaDefinition);
2223
var dataView =
ML
.Data.LoadFromEnumerable(data, schemaDefinition);
2243
var onnxModel =
ML
.Model.ConvertToOnnxProtobuf(model, dataView);
2254
var onnxEstimator =
ML
.Transforms.ApplyOnnxModel(onnxModelPath, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu);
PermutationFeatureImportanceTests.cs (64)
38
var model =
ML
.Regression.Trainers.OnlineGradientDescent().Fit(data);
46
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
48
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
55
pfi =
ML
.Regression.PermutationFeatureImportance(castedModel, data);
64
pfi =
ML
.Regression.PermutationFeatureImportance(model, data);
106
var model =
ML
.Transforms.CopyColumns("Label", "Label").Append(
ML
.Regression.Trainers.OnlineGradientDescent()).Fit(data);
114
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
116
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
129
pfi =
ML
.Regression.PermutationFeatureImportance(castedModel, data);
138
pfi =
ML
.Regression.PermutationFeatureImportance(model.LastTransformer, data);
180
var model =
ML
.Regression.Trainers.OnlineGradientDescent().Fit(data);
188
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
190
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
197
pfi =
ML
.Regression.PermutationFeatureImportance(castedModel, data, permutationCount: 20);
206
pfi =
ML
.Regression.PermutationFeatureImportance(model, data, permutationCount: 20);
268
var model =
ML
.Regression.Trainers.OnlineGradientDescent().Fit(data);
276
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
278
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
285
results =
ML
.Regression.PermutationFeatureImportance(castedModel, data);
294
results =
ML
.Regression.PermutationFeatureImportance(model, data);
342
var model =
ML
.BinaryClassification.Trainers.LbfgsLogisticRegression(
351
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
353
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
360
pfi =
ML
.BinaryClassification.PermutationFeatureImportance(castedModel, data);
369
pfi =
ML
.BinaryClassification.PermutationFeatureImportance(model, data);
416
var model =
ML
.BinaryClassification.Trainers.LbfgsLogisticRegression(
425
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
427
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
434
pfi =
ML
.BinaryClassification.PermutationFeatureImportance(castedModel, data);
443
pfi =
ML
.BinaryClassification.PermutationFeatureImportance(model, data);
488
var ff =
ML
.BinaryClassification.Trainers.FastForest();
489
var data =
ML
.Data.LoadFromTextFile(dataPath,
493
var pfi =
ML
.BinaryClassification.PermutationFeatureImportance(model, data);
525
var model =
ML
.MulticlassClassification.Trainers.LbfgsMaximumEntropy().Fit(data);
533
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
535
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
542
pfi =
ML
.MulticlassClassification.PermutationFeatureImportance(castedModel, data);
551
pfi =
ML
.MulticlassClassification.PermutationFeatureImportance(model, data);
597
var model =
ML
.MulticlassClassification.Trainers.LbfgsMaximumEntropy(
606
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
608
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
615
pfi =
ML
.MulticlassClassification.PermutationFeatureImportance(castedModel, data);
624
pfi =
ML
.MulticlassClassification.PermutationFeatureImportance(model, data);
676
var model =
ML
.Ranking.Trainers.FastTree().Fit(data);
684
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
686
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
694
pfi =
ML
.Ranking.PermutationFeatureImportance(castedModel, data);
703
pfi =
ML
.Ranking.PermutationFeatureImportance(model, data);
745
var model =
ML
.Ranking.Trainers.FastTree().Fit(data);
753
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
755
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
762
pfi =
ML
.Ranking.PermutationFeatureImportance(castedModel, data);
771
pfi =
ML
.Ranking.PermutationFeatureImportance(model, data);
858
var pipeline =
ML
.Transforms.Concatenate("Features", "X1", "X2Important", "X3", "X4Rand")
859
.Append(
ML
.Transforms.NormalizeMinMax("Features"));
861
return pipeline.Append(
ML
.Transforms.Conversion.ConvertType("Label", outputKind: DataKind.Boolean))
864
return pipeline.Append(
ML
.Transforms.Conversion.MapValueToKey("Label"))
867
return pipeline.Append(
ML
.Transforms.Conversion.MapValueToKey("GroupId"))
938
var pipeline =
ML
.Transforms.Concatenate("Features", "X1", "X2VBuffer", "X3Important")
939
.Append(
ML
.Transforms.NormalizeMinMax("Features"));
942
return pipeline.Append(
ML
.Transforms.Conversion.ConvertType("Label", outputKind: DataKind.Boolean))
947
return pipeline.Append(
ML
.Transforms.Conversion.MapValueToKey("Label"))
951
return pipeline.Append(
ML
.Transforms.Conversion.MapValueToKey("GroupId"))
RangeFilterTests.cs (4)
22
var builder = new ArrayDataViewBuilder(
ML
);
27
var data1 =
ML
.Data.FilterRowsByColumn(data, "Floats", upperBound: 2.8);
31
data =
ML
.Transforms.Conversion.Hash("Key", "Strings", numberOfBits: 20).Fit(data).Transform(data);
32
var data2 =
ML
.Data.FilterRowsByKeyColumnFraction(data, "Key", upperBound: 0.15);
SvmLightTests.cs (37)
43
var data =
ML
.Data.LoadFromSvmLightFile(path, inputSize: inputSize, zeroBased: zeroBased, numberOfRows: numberOfRows);
50
ML
.Data.SaveInSvmLightFormat(expectedData, stream, zeroBasedIndexing: zeroBased, exampleWeightColumnName: "Weight");
51
data =
ML
.Data.LoadFromSvmLightFile(savingPath, inputSize: inputSize, zeroBased: zeroBased);
77
var expectedData =
ML
.Data.LoadFromEnumerable(new SvmLightOutput[]
105
var expectedData =
ML
.Data.LoadFromEnumerable(new SvmLightOutput[]
134
var expectedData =
ML
.Data.LoadFromEnumerable(new SvmLightOutput[]
155
var model =
ML
.Data.CreateSvmLightLoaderWithFeatureNames(dataSample: new MultiFileSource(path));
164
var expectedData =
ML
.Data.LoadFromEnumerable(new SvmLightOutput[]
175
ML
.Data.SaveInSvmLightFormat(expectedData, stream, zeroBasedIndexing: true, rowGroupColumnName: "GroupId");
176
data =
ML
.Data.LoadFromSvmLightFile(outputPath, zeroBased: true);
188
expectedData =
ML
.Data.LoadFromEnumerable(new SvmLightOutput[]
198
ML
.Data.SaveInSvmLightFormat(expectedData, stream);
199
data =
ML
.Data.LoadFromSvmLightFile(outputPath);
207
var data =
ML
.Data.LoadFromSvmLightFileWithFeatureNames(path);
212
var expectedData =
ML
.Data.LoadFromEnumerable(new SvmLightOutput[]
221
ML
.Data.SaveInSvmLightFormat(expectedData, stream, zeroBasedIndexing: true);
222
data =
ML
.Data.LoadFromSvmLightFile(outputPath, zeroBased: true);
238
var view =
ML
.Data.LoadFromSvmLightFileWithFeatureNames(path);
258
var data =
ML
.Data.LoadFromSvmLightFile(path);
277
var data =
ML
.Data.LoadFromSvmLightFile(path);
307
var expectedData =
ML
.Data.LoadFromEnumerable(new SvmLightOutput[]
325
var data =
ML
.Data.LoadFromSvmLightFile(path);
349
var data =
ML
.Data.LoadFromSvmLightFile(path);
368
data =
ML
.Data.LoadFromSvmLightFile(path);
387
data =
ML
.Data.LoadFromSvmLightFile(path);
406
ex = Assert.Throws<InvalidOperationException>(() =>
ML
.Data.LoadFromSvmLightFile(path));
419
var loader =
ML
.Data.CreateSvmLightLoader(inputSize: 4);
432
loader =
ML
.Data.CreateSvmLightLoader(inputSize: 3);
443
var ex = Assert.Throws<InvalidOperationException>(() =>
ML
.Data.CreateSvmLightLoader());
445
ex = Assert.Throws<InvalidOperationException>(() =>
ML
.Data.CreateSvmLightLoaderWithFeatureNames());
464
var expectedData =
ML
.Data.LoadFromEnumerable(new SvmLightOutput[]
491
var expectedData =
ML
.Data.LoadFromEnumerable(new SvmLightOutput[]
506
var loader =
ML
.Data.CreateTextLoader(new[] { new TextLoader.Column("Column", DataKind.Single, 0) });
511
ML
.Data.SaveInSvmLightFormat(loader.Load(new MultiFileSource(null)), stream);
519
ML
.Data.SaveInSvmLightFormat(loader.Load(new MultiFileSource(null)), stream, labelColumnName: "Column");
527
ML
.Data.SaveInSvmLightFormat(loader.Load(new MultiFileSource(null)), stream, labelColumnName: "Column", featureColumnName: "Column", rowGroupColumnName: "Group");
535
ML
.Data.SaveInSvmLightFormat(loader.Load(new MultiFileSource(null)), stream, labelColumnName: "Column", featureColumnName: "Column", exampleWeightColumnName: "Weight");
TermEstimatorTests.cs (9)
56
var loader = new TextLoader(
ML
, new TextLoader.Options
71
var pipe = new ValueToKeyMappingEstimator(
ML
, new[]{
81
data =
ML
.Data.TakeRows(data, 10);
85
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true });
101
var dataView =
ML
.Data.LoadFromEnumerable(data);
107
var invalidData =
ML
.Data.LoadFromEnumerable(xydata);
108
var validFitNotValidTransformData =
ML
.Data.LoadFromEnumerable(stringData);
116
var dataView =
ML
.Data.LoadFromEnumerable(data);
138
var dataView =
ML
.Data.LoadFromEnumerable(data);
TrainerEstimators\CalibratorEstimators.cs (2)
100
var binaryTrainer =
ML
.BinaryClassification.Trainers.AveragedPerceptron();
259
oldPlattCalibratorTransformer =
ML
.Model.Load(fs, out var schema);
TrainerEstimators\FAFMEstimator.cs (1)
80
var est =
ML
.BinaryClassification.Trainers.FieldAwareFactorizationMachine(ffmArgs);
TrainerEstimators\LbfgsTests.cs (11)
22
var trainer =
ML
.BinaryClassification.Trainers.LbfgsLogisticRegression();
36
var trainer =
ML
.MulticlassClassification.Trainers.LbfgsMaximumEntropy();
50
var trainer =
ML
.Regression.Trainers.LbfgsPoissonRegression();
63
pipe = pipe.Append(
ML
.BinaryClassification.Trainers.LbfgsLogisticRegression(new LbfgsLogisticRegressionBinaryTrainer.Options { ShowTrainingStatistics = true }));
83
pipe = pipe.Append(
ML
.BinaryClassification.Trainers.LbfgsLogisticRegression(
122
ML
.Model.Save(transformer, dataView.Schema, modelAndSchemaPath);
126
transformerChain =
ML
.Model.Load(fs, out var schema);
166
var trainer =
ML
.MulticlassClassification.Trainers.LbfgsMaximumEntropy();
185
var trainer =
ML
.MulticlassClassification.Trainers.LbfgsMaximumEntropy(new LbfgsMaximumEntropyMulticlassTrainer.Options
216
ML
.Model.Save(transformer, dataView.Schema, modelAndSchemaPath);
221
transformerChain =
ML
.Model.Load(fs, out var schema);
TrainerEstimators\MatrixFactorizationTests.cs (11)
49
var est =
ML
.Recommendation().Trainers.MatrixFactorization(options);
212
var dataView =
ML
.Data.LoadFromEnumerable(dataMatrix);
323
var dataView =
ML
.Data.LoadFromEnumerable(dataMatrix);
443
var dataView =
ML
.Data.LoadFromEnumerable(dataMatrix);
486
var testDataView =
ML
.Data.LoadFromEnumerable(testDataMatrix);
543
model =
ML
.Model.Load(fs, out var schema);
558
var testDataView =
ML
.Data.LoadFromEnumerable(testDataMatrix);
587
var dataView =
ML
.Data.LoadFromEnumerable(dataMatrix);
628
var testDataView =
ML
.Data.LoadFromEnumerable(testDataMatrix);
770
var dataView =
ML
.Data.LoadFromEnumerable(dataMatrix);
809
var testData =
ML
.Data.LoadFromEnumerable(testMatrix);
TrainerEstimators\MetalinearEstimators.cs (9)
26
var averagePerceptron =
ML
.BinaryClassification.Trainers.AveragedPerceptron(
29
var ova =
ML
.MulticlassClassification.Trainers.OneVersusAll(averagePerceptron, imputeMissingLabelsAsNegative: true,
46
var sdcaTrainer =
ML
.BinaryClassification.Trainers.SdcaNonCalibrated(
49
pipeline = pipeline.Append(
ML
.MulticlassClassification.Trainers.OneVersusAll(sdcaTrainer, useProbabilities: false))
64
var sdcaTrainer =
ML
.BinaryClassification.Trainers.SdcaNonCalibrated(
67
pipeline = pipeline.Append(
ML
.MulticlassClassification.Trainers.PairwiseCoupling(sdcaTrainer))
68
.Append(
ML
.Transforms.Conversion.MapKeyToValue("PredictedLabelValue", "PredictedLabel"));
87
var sdcaTrainer =
ML
.BinaryClassification.Trainers.SdcaNonCalibrated(
99
.Append(
ML
.MulticlassClassification.Trainers.OneVersusAll(sdcaTrainer))
TrainerEstimators\OlsLinearRegressionTests.cs (2)
18
var trainer =
ML
.Regression.Trainers.Ols(new OlsTrainer.Options());
26
trainer =
ML
.Regression.Trainers.Ols(new OlsTrainer.Options() { CalculateStatistics = false });
TrainerEstimators\OneDalEstimators.cs (5)
40
var loader =
ML
.Data.CreateTextLoader(columns: new[] {
57
var preprocessingPipeline =
ML
.Transforms.Concatenate("Features", new string[] { "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7" });
72
var trainer =
ML
.BinaryClassification.Trainers.FastForest(options);
75
var trainingMetrics =
ML
.BinaryClassification.EvaluateNonCalibrated(trainingPredictions, labelColumnName: "target");
77
var testingMetrics =
ML
.BinaryClassification.EvaluateNonCalibrated(testingPredictions, labelColumnName: "target");
TrainerEstimators\OnlineLinearTests.cs (7)
20
var regressionData =
ML
.Data.LoadFromTextFile(dataPath, new[] {
25
var regressionPipe =
ML
.Transforms.NormalizeMinMax("Features");
29
var ogdTrainer =
ML
.Regression.Trainers.OnlineGradientDescent();
34
var binaryData =
ML
.Data.LoadFromTextFile(dataPath, new[] {
39
var binaryPipe =
ML
.Transforms.NormalizeMinMax("Features");
42
var apTrainer =
ML
.BinaryClassification.Trainers.AveragedPerceptron(
49
var svmTrainer =
ML
.BinaryClassification.Trainers.LinearSvm();
TrainerEstimators\PriorRandomTests.cs (1)
35
var pipe =
ML
.BinaryClassification.Trainers.Prior("Label");
TrainerEstimators\SdcaTests.cs (9)
21
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
26
data =
ML
.Data.Cache(data);
28
var binaryData =
ML
.Transforms.Conversion.ConvertType("Label", outputKind: DataKind.Boolean)
31
var binaryTrainer =
ML
.BinaryClassification.Trainers.SdcaLogisticRegression(
35
var nonCalibratedBinaryTrainer =
ML
.BinaryClassification.Trainers.SdcaNonCalibrated(
39
var regressionTrainer =
ML
.Regression.Trainers.Sdca(
43
var mcData =
ML
.Transforms.Conversion.MapValueToKey("Label").Fit(data).Transform(data);
45
var mcTrainer =
ML
.MulticlassClassification.Trainers.SdcaMaximumEntropy(
49
var mcTrainerNonCalibrated =
ML
.MulticlassClassification.Trainers.SdcaNonCalibrated(
TrainerEstimators\SymSgdClassificationTests.cs (1)
36
var initPredictor =
ML
.BinaryClassification.Trainers.SdcaLogisticRegression().Fit(transformedData);
TrainerEstimators\TrainerEstimators.cs (13)
92
var trainers = new[] {
ML
.BinaryClassification.Trainers.SgdCalibrated(l2Regularization: 0, numberOfIterations: 80),
93
ML
.BinaryClassification.Trainers.SgdCalibrated(new Trainers.SgdCalibratedTrainer.Options(){ L2Regularization = 0, NumberOfIterations = 80})};
108
var metrics =
ML
.BinaryClassification.Evaluate(result);
124
var trainers = new[] {
ML
.BinaryClassification.Trainers.SgdNonCalibrated(lossFunction : new SmoothedHingeLoss()),
125
ML
.BinaryClassification.Trainers.SgdNonCalibrated(new Trainers.SgdNonCalibratedTrainer.Options() { LossFunction = new HingeLoss() }) };
139
var metrics =
ML
.BinaryClassification.EvaluateNonCalibrated(result);
155
pipe = pipe.Append(
ML
.MulticlassClassification.Trainers.NaiveBayes("Label", "Features"));
164
ML
.BinaryClassification.Trainers.LdSvm(new LdSvmTrainer.Options() { LambdaTheta = 0.02f, NumberOfIterations = 100 }),
165
ML
.BinaryClassification.Trainers.LdSvm(numberOfIterations: 100),
166
ML
.BinaryClassification.Trainers.LdSvm(numberOfIterations: 100, useCachedData: false)
180
var metrics =
ML
.BinaryClassification.EvaluateNonCalibrated(result);
218
var oneHotPipeline = pipeline.Append(
ML
.Transforms.Categorical.OneHotEncoding("LoggedIn"));
219
oneHotPipeline.Append(
ML
.Transforms.Concatenate("Features", "Features", "LoggedIn"));
TrainerEstimators\TreeEnsembleFeaturizerTest.cs (100)
22
var dataView =
ML
.Data.LoadFromEnumerable(data);
25
var trainer =
ML
.BinaryClassification.Trainers.FastTree(
129
var dataView =
ML
.Data.LoadFromEnumerable(data);
132
var trainer =
ML
.BinaryClassification.Trainers.FastTree(
149
var treeFeaturizer = new TreeEnsembleFeaturizationTransformer(
ML
, dataView.Schema, dataView.Schema["Features"], model.Model.SubModel,
181
var dataView =
ML
.Data.LoadFromEnumerable(data);
184
var trainer =
ML
.BinaryClassification.Trainers.FastForest(
200
var treeFeaturizer = new TreeEnsembleFeaturizationTransformer(
ML
, dataView.Schema, dataView.Schema["Features"], model.Model,
235
var dataView =
ML
.Data.LoadFromEnumerable(data);
236
dataView =
ML
.Data.Cache(dataView);
239
var trainer =
ML
.BinaryClassification.Trainers.FastTree(
265
var treeFeaturizer =
ML
.Transforms.FeaturizeByPretrainTreeEnsemble(options).Fit(dataView);
303
var dataView =
ML
.Data.LoadFromEnumerable(data);
304
dataView =
ML
.Data.Cache(dataView);
307
var trainer =
ML
.BinaryClassification.Trainers.FastTree(
330
var pipeline =
ML
.Transforms.FeaturizeByPretrainTreeEnsemble(options)
331
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "Trees", "Leaves", "Paths"))
332
.Append(
ML
.BinaryClassification.Trainers.SdcaLogisticRegression("Label", "CombinedFeatures"));
335
var metrics =
ML
.BinaryClassification.Evaluate(prediction);
338
var naivePipeline =
ML
.BinaryClassification.Trainers.SdcaLogisticRegression("Label", "Features");
341
var naiveMetrics =
ML
.BinaryClassification.Evaluate(naivePrediction);
354
var dataView =
ML
.Data.LoadFromEnumerable(data);
355
dataView =
ML
.Data.Cache(dataView);
376
var pipeline =
ML
.Transforms.FeaturizeByFastTreeBinary(options)
377
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "Trees", "Leaves", "Paths"))
378
.Append(
ML
.BinaryClassification.Trainers.SdcaLogisticRegression("Label", "CombinedFeatures"));
381
var metrics =
ML
.BinaryClassification.Evaluate(prediction);
393
var dataView =
ML
.Data.LoadFromEnumerable(data);
394
dataView =
ML
.Data.Cache(dataView);
415
var pipeline =
ML
.Transforms.FeaturizeByFastForestBinary(options)
416
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "Trees", "Leaves", "Paths"))
417
.Append(
ML
.BinaryClassification.Trainers.SdcaLogisticRegression("Label", "CombinedFeatures"));
420
var metrics =
ML
.BinaryClassification.Evaluate(prediction);
432
var dataView =
ML
.Data.LoadFromEnumerable(data);
433
dataView =
ML
.Data.Cache(dataView);
454
var pipeline =
ML
.Transforms.FeaturizeByFastTreeRegression(options)
455
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "Trees", "Leaves", "Paths"))
456
.Append(
ML
.Regression.Trainers.Sdca("Label", "CombinedFeatures"));
459
var metrics =
ML
.Regression.Evaluate(prediction);
470
var dataView =
ML
.Data.LoadFromEnumerable(data);
471
dataView =
ML
.Data.Cache(dataView);
492
var pipeline =
ML
.Transforms.FeaturizeByFastForestRegression(options)
493
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "Trees", "Leaves", "Paths"))
494
.Append(
ML
.Regression.Trainers.Sdca("Label", "CombinedFeatures"));
497
var metrics =
ML
.Regression.Evaluate(prediction);
508
var dataView =
ML
.Data.LoadFromEnumerable(data);
509
dataView =
ML
.Data.Cache(dataView);
530
var pipeline =
ML
.Transforms.FeaturizeByFastTreeTweedie(options)
531
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "Trees", "Leaves", "Paths"))
532
.Append(
ML
.Regression.Trainers.Sdca("Label", "CombinedFeatures"));
535
var metrics =
ML
.Regression.Evaluate(prediction);
546
var dataView =
ML
.Data.LoadFromEnumerable(data);
547
dataView =
ML
.Data.Cache(dataView);
568
var pipeline =
ML
.Transforms.FeaturizeByFastTreeRanking(options)
569
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "Trees", "Leaves", "Paths"))
570
.Append(
ML
.Regression.Trainers.Sdca("Label", "CombinedFeatures"));
573
var metrics =
ML
.Regression.Evaluate(prediction);
584
var dataView =
ML
.Data.LoadFromEnumerable(data);
585
dataView =
ML
.Data.Cache(dataView);
606
var pipeline =
ML
.Transforms.FeaturizeByFastForestRegression(options)
607
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "Trees", "Leaves", "Paths"))
608
.Append(
ML
.Regression.Trainers.Sdca("Label", "CombinedFeatures"));
611
var metrics =
ML
.Regression.Evaluate(prediction);
622
ML
.Model.Save(model, null, fs);
625
loadedModel =
ML
.Model.Load(fs, out var schema);
628
var loadedMetrics =
ML
.Regression.Evaluate(loadedPrediction);
639
var dataView =
ML
.Data.LoadFromEnumerable(data);
640
dataView =
ML
.Data.Cache(dataView);
662
var pipeline =
ML
.Transforms.CopyColumns("CopiedFeatures", "Features")
663
.Append(
ML
.Transforms.FeaturizeByFastForestRegression(options))
664
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "OhMyTrees", "OhMyLeaves", "OhMyPaths"))
665
.Append(
ML
.Regression.Trainers.Sdca("Label", "CombinedFeatures"));
668
var metrics =
ML
.Regression.Evaluate(prediction);
679
ML
.Model.Save(model, null, fs);
682
loadedModel =
ML
.Model.Load(fs, out var schema);
687
var loadedMetrics =
ML
.Regression.Evaluate(loadedPrediction);
693
var secondPipeline =
ML
.Transforms.CopyColumns("CopiedFeatures", "Features")
694
.Append(
ML
.Transforms.NormalizeBinning("CopiedFeatures"))
695
.Append(
ML
.Transforms.FeaturizeByFastForestRegression(options))
696
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "OhMyTrees", "OhMyLeaves", "OhMyPaths"))
697
.Append(
ML
.Regression.Trainers.Sdca("Label", "CombinedFeatures"));
700
var secondMetrics =
ML
.Regression.Evaluate(secondPrediction);
713
var dataView =
ML
.Data.LoadFromEnumerable(data);
714
dataView =
ML
.Data.Cache(dataView);
739
var wrongPipeline =
ML
.Transforms.FeaturizeByFastTreeBinary(options)
740
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "Trees", "Leaves", "Paths"))
741
.Append(
ML
.BinaryClassification.Trainers.SdcaLogisticRegression("Label", "CombinedFeatures"));
750
var pipeline =
ML
.Transforms.FeaturizeByFastTreeBinary(options)
751
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Features", "Leaves"))
752
.Append(
ML
.BinaryClassification.Trainers.SdcaLogisticRegression("Label", "CombinedFeatures"));
755
var metrics =
ML
.BinaryClassification.Evaluate(prediction);
771
var dataView =
ML
.Data.LoadFromEnumerable(data);
772
dataView =
ML
.Data.Cache(dataView);
799
var split =
ML
.Data.TrainTestSplit(dataView, 0.5);
803
var pipeline =
ML
.Transforms.Conversion.MapValueToKey("KeyLabel", "Label")
804
.Append(
ML
.Transforms.CustomMapping(actionConvertKeyToFloat, "KeyLabel"))
805
.Append(
ML
.Transforms.FeaturizeByFastForestRegression(options))
806
.Append(
ML
.Transforms.Concatenate("CombinedFeatures", "Trees", "Leaves", "Paths"))
807
.Append(
ML
.MulticlassClassification.Trainers.SdcaMaximumEntropy("KeyLabel", "CombinedFeatures"));
811
var metrics =
ML
.MulticlassClassification.Evaluate(prediction, labelColumnName: "KeyLabel");
TrainerEstimators\TreeEstimators.cs (29)
41
var trainer =
ML
.BinaryClassification.Trainers.FastTree(
64
var trainer =
ML
.BinaryClassification.Trainers.LightGbm(new LightGbmBinaryTrainer.Options
86
var trainer =
ML
.BinaryClassification.Trainers.LightGbm(new LightGbmBinaryTrainer.Options
112
var trainer =
ML
.BinaryClassification.Trainers.LightGbm(new LightGbmBinaryTrainer.Options
152
var trainer =
ML
.BinaryClassification.Trainers.FastForest(
175
var trainer =
ML
.Ranking.Trainers.FastTree(
199
var trainer =
ML
.Ranking.Trainers.LightGbm(new LightGbmRankingTrainer.Options() { LabelColumnName = "Label0", FeatureColumnName = "NumericFeatures", RowGroupColumnName = "Group", LearningRate = 0.4 });
216
var trainer =
ML
.Regression.Trainers.FastTree(
234
var trainer =
ML
.Regression.Trainers.LightGbm(new LightGbmRegressionTrainer.Options
271
var trainer =
ML
.Regression.Trainers.FastTreeTweedie(
290
var trainer =
ML
.Regression.Trainers.FastForest(
309
var trainer =
ML
.MulticlassClassification.Trainers.LightGbm(learningRate: 0.4);
326
var trainer =
ML
.MulticlassClassification.Trainers.LightGbm(fStream);
349
var trainer =
ML
.MulticlassClassification.Trainers.LightGbm(options);
365
var trainer =
ML
.MulticlassClassification.Trainers.LightGbm(new LightGbmMulticlassTrainer.Options
390
var trainer =
ML
.MulticlassClassification.Trainers.LightGbm(new LightGbmMulticlassTrainer.Options
409
var trainer =
ML
.MulticlassClassification.Trainers.LightGbm(new LightGbmMulticlassTrainer.Options
780
var trainer =
ML
.MulticlassClassification.Trainers.LightGbm(learningRate: 0.4);
782
.Append(
ML
.Transforms.Conversion.MapKeyToValue("PredictedLabel"));
784
var metrics =
ML
.MulticlassClassification.Evaluate(model.Transform(dataView));
875
summaryDataEnumerable =
ML
.Data.CreateEnumerable<SummaryDataRow>(summaryDataView, false);
877
summaryDataEnumerable =
ML
.Data.CreateEnumerable<QuantileTestSummaryDataRow>(summaryDataView, false);
909
var trainer =
ML
.Regression.Trainers.FastTree(
927
var trainer =
ML
.Regression.Trainers.FastForest(
945
var trainer =
ML
.Regression.Trainers.FastTreeTweedie(
966
var trainer =
ML
.Regression.Trainers.LightGbm(
988
var estimator = pipeline.Append(
ML
.BinaryClassification.Trainers.FastTree(
1006
var estimator = pipeline.Append(
ML
.BinaryClassification.Trainers.FastForest(
1049
var trainer = pipeline.Append(
ML
.BinaryClassification.Trainers.LightGbm(
Transformers\CategoricalHashTests.cs (20)
51
var dataView =
ML
.Data.LoadFromEnumerable(data);
52
var pipe =
ML
.Transforms.Categorical.OneHotHashEncoding(new[]{
72
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
81
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
88
var invalidData =
ML
.Data.LoadFromEnumerable(wrongCollection);
89
var est =
ML
.Transforms.Text.TokenizeIntoWords("VarVectorString", "ScalarString")
90
.Append(
ML
.Transforms.Categorical.OneHotHashEncoding("A", "ScalarString", outputKind: OneHotEncodingEstimator.OutputKind.Indicator))
91
.Append(
ML
.Transforms.Categorical.OneHotHashEncoding("B", "VectorString", outputKind: OneHotEncodingEstimator.OutputKind.Indicator))
92
.Append(
ML
.Transforms.Categorical.OneHotHashEncoding("C", "VectorString", outputKind: OneHotEncodingEstimator.OutputKind.Bag))
93
.Append(
ML
.Transforms.Categorical.OneHotHashEncoding("D", "ScalarString", outputKind: OneHotEncodingEstimator.OutputKind.Binary))
94
.Append(
ML
.Transforms.Categorical.OneHotHashEncoding("E", "VectorString", outputKind: OneHotEncodingEstimator.OutputKind.Binary))
95
.Append(
ML
.Transforms.Categorical.OneHotHashEncoding("F", "VarVectorString", outputKind: OneHotEncodingEstimator.OutputKind.Bag))
97
.Append(
ML
.Transforms.Categorical.OneHotHashEncoding("G", "SingleVectorString", outputKind: OneHotEncodingEstimator.OutputKind.Bag));
102
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
103
var view =
ML
.Transforms.SelectColumns("A", "B", "C", "D", "E", "F").Fit(savedData).Transform(savedData);
105
ML
.Data.SaveAsText(view, fs, headerRow: true, keepHidden: true);
119
var dataView =
ML
.Data.LoadFromEnumerable(data);
120
var bagPipe =
ML
.Transforms.Categorical.OneHotHashEncoding(
224
var dataView =
ML
.Data.LoadFromEnumerable(data);
225
var pipe =
ML
.Transforms.Categorical.OneHotHashEncoding(new[]{
Transformers\CategoricalTests.cs (18)
70
var dataView =
ML
.Data.LoadFromEnumerable(data);
71
var pipe =
ML
.Transforms.Categorical.OneHotEncoding(new[]{
91
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
157
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
163
var invalidData =
ML
.Data.LoadFromEnumerable(wrongCollection);
164
var est =
ML
.Transforms.Text.TokenizeIntoWords("VarVectorString", "ScalarString")
165
.Append(
ML
.Transforms.Categorical.OneHotEncoding("A", "ScalarString", outputKind: OneHotEncodingEstimator.OutputKind.Indicator))
166
.Append(
ML
.Transforms.Categorical.OneHotEncoding("B", "VectorString", outputKind: OneHotEncodingEstimator.OutputKind.Indicator))
167
.Append(
ML
.Transforms.Categorical.OneHotEncoding("C", "VectorString", outputKind: OneHotEncodingEstimator.OutputKind.Bag))
168
.Append(
ML
.Transforms.Categorical.OneHotEncoding("D", "ScalarString", outputKind: OneHotEncodingEstimator.OutputKind.Binary))
169
.Append(
ML
.Transforms.Categorical.OneHotEncoding("E", "VectorString", outputKind: OneHotEncodingEstimator.OutputKind.Binary));
174
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
175
var view =
ML
.Transforms.SelectColumns("A", "B", "C", "D", "E").Fit(savedData).Transform(savedData);
177
ML
.Data.SaveAsText(view, fs, headerRow: true, keepHidden: true);
192
var dataView =
ML
.Data.LoadFromEnumerable(data);
193
var pipe =
ML
.Transforms.Categorical.OneHotEncoding(new[] {
318
var dataView =
ML
.Data.LoadFromEnumerable(data);
319
var pipe =
ML
.Transforms.Categorical.OneHotEncoding(new[]{
Transformers\CharTokenizeTests.cs (3)
41
var dataView =
ML
.Data.LoadFromEnumerable(data);
43
var invalidDataView =
ML
.Data.LoadFromEnumerable(invalidData);
61
var dataView =
ML
.Data.LoadFromEnumerable(data);
Transformers\ConcatTests.cs (14)
28
var pipe =
ML
.Transforms.Concatenate("Features");
46
var loader = new TextLoader(
ML
, new TextLoader.Options
65
var pipe =
ML
.Transforms.Concatenate("f1", "float1")
66
.Append(
ML
.Transforms.Concatenate("f2", "float1", "float1"))
67
.Append(
ML
.Transforms.Concatenate("f3", "float4", "float1"))
68
.Append(
ML
.Transforms.Concatenate("f4", "float6", "vfloat", "float1"));
70
data =
ML
.Data.TakeRows(data, 10);
83
data =
ML
.Transforms.SelectColumns("f1", "f2", "f3", "f4").Fit(data).Transform(data);
89
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, Dense = true });
104
var loader = new TextLoader(
ML
, new TextLoader.Options
122
data =
ML
.Data.TakeRows(data, 10);
124
var concater = new ColumnConcatenatingTransformer(
ML
,
147
data =
ML
.Transforms.SelectColumns("f2", "f3").Fit(data).Transform(data);
153
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, Dense = true });
Transformers\ConvertTests.cs (16)
129
var dataView =
ML
.Data.LoadFromEnumerable(data);
130
var pipe =
ML
.Transforms.Conversion.ConvertType(columns: new[] {new TypeConvertingEstimator.ColumnOptions("ConvA", DataKind.Single, "A"),
168
var allTypesDataView =
ML
.Data.LoadFromEnumerable(allTypesData);
169
var allTypesPipe =
ML
.Transforms.Conversion.ConvertType(columns: new[] {
248
var expectedConvertedValues =
ML
.Data.LoadFromEnumerable(allTypesDataConverted);
253
var allInputTypesDataView =
ML
.Data.LoadFromEnumerable(allInputTypesData);
254
var allInputTypesDataPipe =
ML
.Transforms.Conversion.ConvertType(columns: new[] {new TypeConvertingEstimator.ColumnOptions("A1", DataKind.String, "A"),
266
var expectedValuesDataView =
ML
.Data.LoadFromEnumerable(expectedValuesData);
319
var dataView =
ML
.Data.LoadFromEnumerable(data);
320
var pipe =
ML
.Transforms.Conversion.ConvertType(columns: new[] {new TypeConvertingEstimator.ColumnOptions("ConvA", typeof(double), "A"),
338
var pipe =
ML
.Transforms.Categorical.OneHotEncoding(new[] {
341
}).Append(
ML
.Transforms.Conversion.ConvertType(new[] {
345
var dataView =
ML
.Data.LoadFromEnumerable(data);
388
var dataView =
ML
.Data.LoadFromEnumerable(dataArray);
396
modelOld =
ML
.Model.Load(fs, out var schema);
400
var modelNew =
ML
.Transforms.Conversion.ConvertType(new[] { new TypeConvertingEstimator.ColumnOptions("convertedKey",
Transformers\CountTargetEncodingTests.cs (23)
26
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
32
var estimator =
ML
.Transforms.CountTargetEncode(new[] {
42
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] { new TextLoader.Column("Label", DataKind.Single, 0),
44
var estimator =
ML
.Transforms.CountTargetEncode("Text", builder: CountTableBuilderBase.CreateCMCountTableBuilder(2, 1 << 6));
47
estimator =
ML
.Transforms.CountTargetEncode("Text", transformer);
57
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
63
var estimator =
ML
.Transforms.CountTargetEncode(new[] {
67
estimator =
ML
.Transforms.CountTargetEncode(new[] { new InputOutputColumnPair("ScalarString"), new InputOutputColumnPair("VectorString") }, transformer);
77
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
84
var estimator =
ML
.Transforms.CountTargetEncode(new[] {
86
.Append(
ML
.Transforms.Concatenate("Features", "ScalarString", "VectorString"))
87
.Append(
ML
.BinaryClassification.Trainers.AveragedPerceptron().WithOnFitDelegate(x => weights = x.Model.Weights));
92
estimator =
ML
.Transforms.CountTargetEncode(new[] {
94
.Append(
ML
.Transforms.Concatenate("Features", "ScalarString", "VectorString"))
95
.Append(
ML
.BinaryClassification.Trainers.AveragedPerceptron().WithOnFitDelegate(x => weightsNoNoise = x.Model.Weights));
101
estimator =
ML
.Transforms.CountTargetEncode(new[] {
103
.Append(
ML
.Transforms.Concatenate("Features", "ScalarString", "VectorString"))
104
.Append(
ML
.BinaryClassification.Trainers.AveragedPerceptron().WithOnFitDelegate(x => weightsNoNoise2 = x.Model.Weights));
115
var select =
ML
.Transforms.SelectColumns("Features").Fit(transformed);
162
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
168
var estimator =
ML
.Transforms.CountTargetEncode("VectorString1", "VectorString", builder: CountTableBuilderBase.CreateCMCountTableBuilder(3, 1 << 10),
170
ML
.Transforms.CountTargetEncode(new[] { new InputOutputColumnPair("ScalarString1", "ScalarString"), new InputOutputColumnPair("VectorString2", "VectorString") },
172
ML
.Transforms.CountTargetEncode("ScalarString2", "ScalarString", builder: CountTableBuilderBase.CreateDictionaryCountTableBuilder(1)));
Transformers\CustomMappingTests.cs (13)
56
var loader =
ML
.Data.CreateTextLoader(new[] {
74
ML
.ComponentCatalog.RegisterAssembly(typeof(MyLambda).Assembly);
79
var inputs =
ML
.Data.CreateEnumerable<MyInput>(transformedData, true);
80
var outputs =
ML
.Data.CreateEnumerable<MyOutput>(transformedData, true);
92
var loader =
ML
.Data.CreateTextLoader(new[] {
101
var est =
ML
.Transforms.CustomMapping(mapping, null);
106
var badData1 =
ML
.Transforms.CopyColumns("Text1", "Float1").Fit(data).Transform(data);
114
var badData2 =
ML
.Transforms.SelectColumns(new[] { "Float1" }).Fit(data).Transform(data);
170
var loader =
ML
.Data.CreateTextLoader(new[] {
195
var loader =
ML
.Data.CreateTextLoader(new[] {
201
var filteredData =
ML
.Data.FilterByCustomPredicate<MyInput>(data, input => input.Float1 % 2 == 0);
219
var data =
ML
.Data.LoadFromEnumerable(new[]
232
var filteredData =
ML
.Data.FilterByStatefulCustomPredicate<MyFilterInput, MyFilterState>(data,
Transformers\ExpressionTransformerTests.cs (7)
24
var loader = new TextLoader(
ML
, new TextLoader.Options
40
var expr =
ML
.Transforms.Expression("Expr1", "x=>x/2", "Double").
41
Append(
ML
.Transforms.Expression("Expr2", "(x,y)=>(x+y)/3", "Float", "FloatVector")).
42
Append(
ML
.Transforms.Expression("Expr3", "(x,y)=>x*y", "Float", "Int")).
43
Append(
ML
.Transforms.Expression("Expr4", "(x,y,z)=>abs(x-y)*z", "Float", "FloatVector", "Double")).
44
Append(
ML
.Transforms.Expression("Expr5", "x=>len(concat(upper(x),lower(x)))", "Text")).
45
Append(
ML
.Transforms.Expression("Expr6", "(x,y)=>right(x,y)", "TextVector", "Int"));
Transformers\FeatureSelectionTests.cs (38)
31
var data =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
36
var invalidData =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
41
var est = new WordBagEstimator(
ML
, "bag_of_words", "text")
42
.AppendCacheCheckpoint(
ML
)
43
.Append(
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnCount("bag_of_words_count", "bag_of_words", 10)
44
.Append(
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnMutualInformation("bag_of_words_mi", "bag_of_words", labelColumnName: "label")));
49
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true });
50
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
51
savedData =
ML
.Transforms.SelectColumns("bag_of_words_count", "bag_of_words_mi").Fit(savedData).Transform(savedData);
65
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
81
var trans = new SlotsDroppingTransformer(
ML
, columns);
86
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, OutputHeader = false });
87
var savedData =
ML
.Data.TakeRows(trans.Transform(data), 4);
107
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
120
var est =
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnCount("FeatureSelect", "VectorFloat", count: 1)
121
.Append(
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnCount(columns));
128
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, OutputHeader = false });
129
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
148
var dataView =
ML
.Data.LoadFromTextFile(dataPath, new[] {
153
var pipe =
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnCount("FeatureSelect", "VectorFloat", count: 1);
159
TrainUtils.SaveModel(
ML
, Env.Start("saving"), ms, null, resultRoles);
161
var loadedView = ModelFileUtils.LoadTransforms(
ML
, dataView, ms);
170
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
177
var est =
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnMutualInformation("FeatureSelect", "VectorFloat", slotsInOutput: 1, labelColumnName: "Label")
178
.Append(
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnMutualInformation(labelColumnName: "Label", slotsInOutput: 2, numberOfBins: 100,
188
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, OutputHeader = false });
189
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
208
var dataView =
ML
.Data.LoadFromTextFile(dataPath, new[] {
213
var pipe =
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnMutualInformation("FeatureSelect", "VectorFloat", slotsInOutput: 1, labelColumnName: "Label");
219
TrainUtils.SaveModel(
ML
, Env.Start("saving"), ms, null, resultRoles);
221
var loadedView = ModelFileUtils.LoadTransforms(
ML
, dataView, ms);
230
var dataView =
ML
.Data.LoadFromTextFile(dataPath, new[] {
238
var pipeline =
ML
.Transforms.Text.TokenizeIntoWords("Features")
239
.Append(
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnCount("Features"));
246
var pipeline =
ML
.Transforms.Text.TokenizeIntoWords("Features")
247
.Append(
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnMutualInformation("Features", labelColumnName: "BadLabel"));
254
var pipeline =
ML
.Transforms.Text.TokenizeIntoWords("Features")
255
.Append(
ML
.Transforms.FeatureSelection.SelectFeaturesBasedOnMutualInformation("Features"));
Transformers\GroupUngroup.cs (4)
49
var dataView =
ML
.Data.LoadFromEnumerable(data);
52
var grouped =
ML
.Data.CreateEnumerable<UngroupExample>(groupTransform, false).ToList();
86
var dataView =
ML
.Data.LoadFromEnumerable(data);
89
var ungrouped =
ML
.Data.CreateEnumerable<GroupExample>(ungroupTransform, false).ToList();
Transformers\HashTests.cs (13)
50
var dataView =
ML
.Data.LoadFromEnumerable(data);
51
var pipe =
ML
.Transforms.Conversion.Hash(new[]{
72
var dataView =
ML
.Data.LoadFromEnumerable(data);
73
var pipe =
ML
.Transforms.Conversion.Hash(new[] {
112
var dataView =
ML
.Data.LoadFromEnumerable(data);
113
var pipe =
ML
.Transforms.Conversion.Hash(new[]{
335
IDataView data =
ML
.Data.LoadFromEnumerable(samples);
338
var model =
ML
.Model.Load(modelPath, out var _);
357
var dataView =
ML
.Data.LoadFromTextFile(dataPath, new[]
363
var model =
ML
.Model.Load(modelPath, out _);
381
var dataView =
ML
.Data.LoadFromEnumerable(data);
383
var pipeline =
ML
.Transforms.Concatenate("D", "A")
384
.Append(
ML
.Transforms.Conversion.Hash(
Transformers\KeyToBinaryVectorEstimatorTest.cs (9)
47
var dataView =
ML
.Data.LoadFromEnumerable(data);
54
var pipe =
ML
.Transforms.Conversion.MapKeyToBinaryVector(new[] { new InputOutputColumnPair("CatA", "TermA"), new InputOutputColumnPair("CatC", "TermC") });
63
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
74
var est =
ML
.Transforms.Conversion.MapKeyToBinaryVector("ScalarString", "A")
75
.Append(
ML
.Transforms.Conversion.MapKeyToBinaryVector("VectorString", "B"));
91
var dataView =
ML
.Data.LoadFromEnumerable(data);
100
var pipe =
ML
.Transforms.Conversion.MapKeyToBinaryVector(new[] {
147
var dataView =
ML
.Data.LoadFromEnumerable(data);
155
var pipe =
ML
.Transforms.Conversion.MapKeyToBinaryVector(new[] { new InputOutputColumnPair("CatA", "TermA"), new InputOutputColumnPair("CatB", "TermB"), new InputOutputColumnPair("CatC", "TermC") });
Transformers\KeyToValueTests.cs (5)
68
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
78
var est =
ML
.Transforms.Conversion.MapKeyToValue("ScalarString", "A")
79
.Append(
ML
.Transforms.Conversion.MapKeyToValue("VectorString", "B"));
85
var dataLeft =
ML
.Transforms.SelectColumns(new[] { "ScalarString", "VectorString" }).Fit(data).Transform(data);
86
var dataRight =
ML
.Transforms.SelectColumns(new[] { "ScalarString", "VectorString" }).Fit(data2Transformed).Transform(data2Transformed);
Transformers\KeyToVectorEstimatorTests.cs (10)
54
var dataView =
ML
.Data.LoadFromEnumerable(data);
61
var pipe =
ML
.Transforms.Conversion.MapKeyToVector(new KeyToVectorMappingEstimator.ColumnOptions("CatA", "TermA", false),
73
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
83
var est =
ML
.Transforms.Conversion.MapKeyToVector("ScalarString", "A")
84
.Append(
ML
.Transforms.Conversion.MapKeyToVector("VectorString", "B"))
85
.Append(
ML
.Transforms.Conversion.MapKeyToVector("VectorBaggedString", "B", true));
101
var dataView =
ML
.Data.LoadFromEnumerable(data);
114
var pipe =
ML
.Transforms.Conversion.MapKeyToVector(
206
var dataView =
ML
.Data.LoadFromEnumerable(data);
214
var pipe =
ML
.Transforms.Conversion.MapKeyToVector(
Transformers\NAIndicatorTests.cs (13)
46
var dataView =
ML
.Data.LoadFromEnumerable(data);
47
var pipe =
ML
.Transforms.IndicateMissingValues(new[] {
74
var dataView =
ML
.Data.LoadFromEnumerable(data);
75
var pipe =
ML
.Transforms.IndicateMissingValues(new[] {
95
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
103
var invalidData =
ML
.Data.LoadFromEnumerable(wrongCollection);
104
var est =
ML
.Transforms.IndicateMissingValues(new[]
114
using (var ch = ((IHostEnvironment)
ML
).Start("save"))
116
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true });
117
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
137
var dataView =
ML
.Data.LoadFromEnumerable(data);
138
var pipe =
ML
.Transforms.Categorical.OneHotEncoding("CatA", "A");
139
var newpipe = pipe.Append(
ML
.Transforms.IndicateMissingValues("NAA", "CatA"));
Transformers\NAReplaceTests.cs (17)
66
var dataView =
ML
.Data.LoadFromEnumerable(data);
67
var pipe =
ML
.Transforms.ReplaceMissingValues(
87
var expectedOutputDataview =
ML
.Data.LoadFromEnumerable(expectedOutput);
111
var dataView =
ML
.Data.LoadFromEnumerable(data);
112
var pipe =
ML
.Transforms.ReplaceMissingValues(
125
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
133
var invalidData =
ML
.Data.LoadFromEnumerable(wrongCollection);
135
var est =
ML
.Transforms.ReplaceMissingValues("A", "ScalarFloat", replacementMode: MissingValueReplacingEstimator.ReplacementMode.Maximum)
136
.Append(
ML
.Transforms.ReplaceMissingValues("B", "ScalarDouble", replacementMode: MissingValueReplacingEstimator.ReplacementMode.Mean))
137
.Append(
ML
.Transforms.ReplaceMissingValues("C", "VectorFloat", replacementMode: MissingValueReplacingEstimator.ReplacementMode.Mean))
138
.Append(
ML
.Transforms.ReplaceMissingValues("D", "VectorDouble", replacementMode: MissingValueReplacingEstimator.ReplacementMode.Minimum))
139
.Append(
ML
.Transforms.ReplaceMissingValues("E", "VectorDouble", replacementMode: MissingValueReplacingEstimator.ReplacementMode.Mode));
143
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
144
var view =
ML
.Transforms.SelectColumns("A", "B", "C", "D", "E").Fit(savedData).Transform(savedData);
146
ML
.Data.SaveAsText(view, fs, headerRow: true, keepHidden: true);
169
var dataView =
ML
.Data.LoadFromEnumerable(data);
170
var pipe =
ML
.Transforms.ReplaceMissingValues(
Transformers\NormalizerTests.cs (74)
91
var dataView =
ML
.Transforms.DropColumns(new[] { "float0" }).Fit(transformedData).Transform(transformedData);
484
var est4 =
ML
.Transforms.NormalizeMinMax("float4", "float4");
485
var est5 =
ML
.Transforms.NormalizeMinMax("float4");
505
var est8 =
ML
.Transforms.NormalizeMeanVariance("float4", "float4");
518
var est11 =
ML
.Transforms.NormalizeLogMeanVariance("float4", "float4");
531
var est14 =
ML
.Transforms.NormalizeBinning("float4", "float4");
544
var est17 =
ML
.Transforms.NormalizeSupervisedBinning("float4", "float4");
557
var est20 =
ML
.Transforms.NormalizeRobustScaling("float4", "float4");
586
var est1 =
ML
.Transforms.NormalizeMinMax("float4", "float4");
587
var est2 =
ML
.Transforms.NormalizeMeanVariance("float4", "float4");
588
var est3 =
ML
.Transforms.NormalizeLogMeanVariance("float4", "float4");
589
var est4 =
ML
.Transforms.NormalizeBinning("float4", "float4");
590
var est5 =
ML
.Transforms.NormalizeSupervisedBinning("float4", "float4");
593
var est6 =
ML
.Transforms.NormalizeMinMax("float4", "float4");
594
var est7 =
ML
.Transforms.NormalizeMeanVariance("float4", "float4");
595
var est8 =
ML
.Transforms.NormalizeLogMeanVariance("float4", "float4");
596
var est9 =
ML
.Transforms.NormalizeBinning("float4", "float4");
597
var est10 =
ML
.Transforms.NormalizeSupervisedBinning("float4", "float4");
642
var est =
ML
.Transforms.NormalizeMinMax("output", "input");
656
var data =
ML
.Data.LoadFromTextFile(dataSource, new[] {
661
var invalidData =
ML
.Data.LoadFromTextFile(dataSource, new[] {
666
var est =
ML
.Transforms.NormalizeLpNorm("lpnorm", "features")
667
.Append(
ML
.Transforms.NormalizeGlobalContrast("gcnorm", "features"))
668
.Append(new VectorWhiteningEstimator(
ML
, "whitened", "features"));
674
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, OutputHeader = false });
675
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
676
savedData =
ML
.Transforms.SelectColumns("lpnorm", "gcnorm", "whitened").Fit(savedData).Transform(savedData);
690
var data =
ML
.Data.LoadFromTextFile(dataSource, new[] {
695
var invalidData =
ML
.Data.LoadFromTextFile(dataSource, new[] {
701
var est = new VectorWhiteningEstimator(
ML
, "whitened1", "features")
702
.Append(new VectorWhiteningEstimator(
ML
, "whitened2", "features", kind: WhiteningKind.PrincipalComponentAnalysis, rank: 5));
708
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, OutputHeader = false });
709
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
710
savedData =
ML
.Transforms.SelectColumns("whitened1", "whitened2").Fit(savedData).Transform(savedData);
732
var dataView =
ML
.Data.LoadFromTextFile(dataSource, new[] {
737
var pipe = new VectorWhiteningEstimator(
ML
, "whitened", "features");
743
TrainUtils.SaveModel(
ML
, Env.Start("saving"), ms, null, resultRoles);
745
var loadedView = ModelFileUtils.LoadTransforms(
ML
, dataView, ms);
754
var data =
ML
.Data.LoadFromTextFile(dataSource, new[] {
759
var invalidData =
ML
.Data.LoadFromTextFile(dataSource, new[] {
764
var est =
ML
.Transforms.NormalizeLpNorm("lpNorm1", "features")
765
.Append(
ML
.Transforms.NormalizeLpNorm("lpNorm2", "features", norm: LpNormNormalizingEstimatorBase.NormFunction.L1, ensureZeroMean: true));
771
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, OutputHeader = false });
772
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
773
savedData =
ML
.Transforms.SelectColumns("lpNorm1", "lpNorm2").Fit(savedData).Transform(savedData);
793
var dataView =
ML
.Data.LoadFromTextFile(dataSource, new[] {
798
var pipe =
ML
.Transforms.NormalizeLpNorm("whitened", "features");
804
TrainUtils.SaveModel(
ML
, Env.Start("saving"), ms, null, resultRoles);
806
var loadedView = ModelFileUtils.LoadTransforms(
ML
, dataView, ms);
814
var data =
ML
.Data.LoadFromTextFile(dataSource, new[] {
819
var invalidData =
ML
.Data.LoadFromTextFile(dataSource, new[] {
824
var est =
ML
.Transforms.NormalizeGlobalContrast("gcnNorm1", "features")
825
.Append(
ML
.Transforms.NormalizeGlobalContrast("gcnNorm2", "features", ensureZeroMean: false, ensureUnitStandardDeviation: true, scale: 3));
831
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, OutputHeader = false });
832
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
833
savedData =
ML
.Transforms.SelectColumns("gcnNorm1", "gcnNorm2").Fit(savedData).Transform(savedData);
853
var dataView =
ML
.Data.LoadFromTextFile(dataSource, new[] {
858
var pipe =
ML
.Transforms.NormalizeGlobalContrast("whitened", "features");
864
TrainUtils.SaveModel(
ML
, Env.Start("saving"), ms, null, resultRoles);
866
var loadedView = ModelFileUtils.LoadTransforms(
ML
, dataView, ms);
874
var dataView = TextLoader.Create(
ML
, new TextLoader.Options(), new MultiFileSource(dataFile));
905
var data =
ML
.Data.LoadFromEnumerable(samples);
908
var normalize =
ML
.Transforms.NormalizeLogMeanVariance("Features", true, useCdf: true);
911
var normalizeNoCdf =
ML
.Transforms.NormalizeLogMeanVariance("Features", true, useCdf: false);
930
var transformedDataArray =
ML
.Data.CreateEnumerable<DataPointOne>(noCdfData, false).ToImmutableArray();
946
var data =
ML
.Data.LoadFromEnumerable(samples);
949
var normalize =
ML
.Transforms.NormalizeLogMeanVariance("Features", true, useCdf: true);
952
var normalizeNoCdf =
ML
.Transforms.NormalizeLogMeanVariance("Features", true, useCdf: false);
974
var transformedDataArray =
ML
.Data.CreateEnumerable<DataPointVec>(noCdfData, false).ToImmutableArray();
1006
var normalizer =
ML
.Model.Load(modelPath, out var schema);
1054
var data =
ML
.Data.LoadFromEnumerable(samples);
1055
var model =
ML
.Transforms.NormalizeMinMax("output", "input").Fit(data);
1059
ML
.Model.Save(model, data.Schema, modelAndSchemaPath);
1060
var loadedModel =
ML
.Model.Load(modelAndSchemaPath, out var schema);
Transformers\PcaTests.cs (10)
23
_saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true, OutputHeader = false });
29
var data =
ML
.Data.LoadFromTextFile(_dataSource, new[] {
35
var invalidData =
ML
.Data.LoadFromTextFile(_dataSource, new[] {
41
var est =
ML
.Transforms.ProjectToPrincipalComponents("pca", "features", rank: 4, seed: 10);
44
var estNonDefaultArgs =
ML
.Transforms.ProjectToPrincipalComponents("pca", "features", rank: 3, exampleWeightColumnName: "weight", overSampling: 2, ensureZeroMean: false);
53
var data =
ML
.Data.LoadFromTextFile(_dataSource, new[] {
58
var est =
ML
.Transforms.ProjectToPrincipalComponents("pca", "features", rank: 5, seed: 1);
60
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
61
savedData =
ML
.Transforms.SelectColumns("pca").Fit(savedData).Transform(savedData);
64
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
Transformers\RffTests.cs (10)
50
var invalidData =
ML
.Data.LoadFromEnumerable(new[] { new TestClassInvalidSchema { A = 1 }, new TestClassInvalidSchema { A = 1 } });
51
var validFitInvalidData =
ML
.Data.LoadFromEnumerable(new[] { new TestClassBiggerSize { A = new float[200] }, new TestClassBiggerSize { A = new float[200] } });
52
var dataView =
ML
.Data.LoadFromEnumerable(data);
54
var pipe =
ML
.Transforms.ApproximatedKernelMap(new[]{
67
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
72
var est =
ML
.Transforms.ApproximatedKernelMap("RffVectorFloat", "VectorFloat", 3, true);
77
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
79
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
98
var dataView =
ML
.Data.LoadFromEnumerable(data);
100
var est =
ML
.Transforms.ApproximatedKernelMap(new[]{
Transformers\SelectColumnsTests.cs (22)
48
var dataView =
ML
.Data.LoadFromEnumerable(data);
67
var dataView =
ML
.Data.LoadFromEnumerable(data);
88
var dataView =
ML
.Data.LoadFromEnumerable(data);
107
var dataView =
ML
.Data.LoadFromEnumerable(data);
108
var invalidDataView =
ML
.Data.LoadFromEnumerable(invalidData);
111
var est =
ML
.Transforms.SelectColumns(new[] { "A", "B" });
115
est =
ML
.Transforms.SelectColumns(new[] { "A", "B" }, true);
123
var dataView =
ML
.Data.LoadFromEnumerable(data);
132
var dataView =
ML
.Data.LoadFromEnumerable(data);
155
var dataView =
ML
.Data.LoadFromEnumerable(data);
157
var chain = est.Append(
ML
.Transforms.SelectColumns(new[] { "B", "A" }, true));
178
var dataView =
ML
.Data.LoadFromEnumerable(data);
183
ML
.Model.Save(transformer, null, ms);
185
var loadedTransformer =
ML
.Model.Load(ms, out var schema);
197
var dataView =
ML
.Data.LoadFromEnumerable(data);
199
ML
.Transforms.SelectColumns(new[] { "A", "B" }, false));
203
ML
.Model.Save(transformer, null, ms);
205
var loadedTransformer =
ML
.Model.Load(ms, out var schema);
219
var dataView =
ML
.Data.LoadFromEnumerable(data);
247
var dataView =
ML
.Data.LoadFromEnumerable(data);
275
var dataView =
ML
.Data.LoadFromEnumerable(data);
303
var dataView =
ML
.Data.LoadFromEnumerable(data);
Transformers\TextFeaturizerTests.cs (90)
49
var dataView =
ML
.Data.LoadFromEnumerable(data);
52
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options, "A");
54
var engine = model.CreatePredictionEngine<TestClass, TestClass>(
ML
);
67
var dataView =
ML
.Data.LoadFromEnumerable(data);
76
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options, "A");
78
var engine = model.CreatePredictionEngine<TestClass, TestClass>(
ML
);
96
var dataView =
ML
.Data.LoadFromEnumerable(data);
106
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options, null);
138
var dataView =
ML
.Data.LoadFromEnumerable(data);
148
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options);
180
var dataView =
ML
.Data.LoadFromEnumerable(data);
189
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options, "A");
191
var engine = model.CreatePredictionEngine<TestClass, TestClass>(
ML
);
209
var dataView =
ML
.Data.LoadFromEnumerable(data);
217
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options, "A");
219
var engine = model.CreatePredictionEngine<TestClass, TestClass>(
ML
);
240
var dataView =
ML
.Data.LoadFromEnumerable(data);
251
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options, "A");
253
var engine = model.CreatePredictionEngine<TestClass, TestClass>(
ML
);
268
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options, "A");
270
var engine = model.CreatePredictionEngine<TestClass, TestClass>(
ML
);
301
var dataView =
ML
.Data.LoadFromEnumerable(data);
317
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options, "A");
319
var engine = model.CreatePredictionEngine<TestClass, TestClass>(
ML
);
340
var dataView =
ML
.Data.LoadFromEnumerable(data);
354
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options, "A");
356
var engine = model.CreatePredictionEngine<TestClass, TestClass>(
ML
);
378
var dataView =
ML
.Data.LoadFromEnumerable(data);
392
var pipeline =
ML
.Transforms.Text.FeaturizeText("Features", options, "A");
394
var engine = model.CreatePredictionEngine<TestClass, TestClass>(
ML
);
415
var dataView =
ML
.Data.LoadFromEnumerable(data);
426
var data =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
431
var invalidData =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
436
var feat =
ML
.Transforms.Text.FeaturizeText("Data", new TextFeaturizingEstimator.Options { OutputTokensColumnName = "OutputTokens" }, new[] { "text" });
441
using (var ch = ((IHostEnvironment)
ML
).Start("save"))
443
var saver = new TextSaver(
ML
, new TextSaver.Arguments { Silent = true });
444
var savedData =
ML
.Data.TakeRows(feat.Fit(data).Transform(data), 4);
445
savedData =
ML
.Transforms.SelectColumns("Data", "OutputTokens").Fit(savedData).Transform(savedData);
459
var data =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
464
var invalidData =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
469
var est = new WordTokenizingEstimator(
ML
, "words", "text")
470
.Append(new TokenizingByCharactersEstimator(
ML
, "chars", "text"))
471
.Append(new KeyToValueMappingEstimator(
ML
, "chars"));
475
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
476
savedData =
ML
.Transforms.SelectColumns("text", "words", "chars").Fit(savedData).Transform(savedData);
479
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
489
var data =
ML
.Data.LoadFromTextFile(dataPath, new[] {
495
var outdata =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
496
var savedData =
ML
.Transforms.SelectColumns("words").Fit(outdata).Transform(outdata);
526
var data =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
531
var invalidData =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
536
var est =
ML
.Transforms.Text.NormalizeText("text")
537
.Append(
ML
.Transforms.Text.TokenizeIntoWords("words", "text"))
538
.Append(
ML
.Transforms.Text.RemoveDefaultStopWords("NoDefaultStopwords", "words"))
539
.Append(
ML
.Transforms.Text.RemoveStopWords("NoStopWords", "words", "xbox", "this", "is", "a", "the", "THAT", "bY"));
544
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
545
savedData =
ML
.Transforms.SelectColumns("text", "NoDefaultStopwords", "NoStopWords").Fit(savedData).Transform(savedData);
547
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
558
var data = TextLoader.Create(
ML
, new TextLoader.Options()
566
var tokenized = new WordTokenizingTransformer(
ML
, new[]
571
var xf = factory.CreateComponent(
ML
, tokenized,
589
var data =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
594
var invalidData =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
599
var est = new WordBagEstimator(
ML
, "bag_of_words", "text").
600
Append(new WordHashBagEstimator(
ML
, "bag_of_wordshash", "text", maximumNumberOfInverts: -1));
605
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
606
savedData =
ML
.Transforms.SelectColumns("text", "bag_of_words", "bag_of_wordshash").Fit(savedData).Transform(savedData);
609
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
619
var data =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
624
var invalidData =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
629
var est = new WordTokenizingEstimator(
ML
, "text", "text")
630
.Append(new ValueToKeyMappingEstimator(
ML
, "terms", "text"))
631
.Append(new NgramExtractingEstimator(
ML
, "ngrams", "terms"))
632
.Append(new NgramHashingEstimator(
ML
, "ngramshash", "terms"))
635
.Append(new NgramHashingEstimator(
ML
, "ngramshashinvert", "terms", maximumNumberOfInverts: 2));
640
var savedData =
ML
.Data.TakeRows(est.Fit(data).Transform(data), 4);
641
savedData =
ML
.Transforms.SelectColumns("text", "terms", "ngrams", "ngramshash").Fit(savedData).Transform(savedData);
644
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
656
var data =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
673
var data =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
678
var invalidData =
ML
.Data.LoadFromTextFile(sentimentDataPath, new[] {
699
var savedData =
ML
.Data.TakeRows(transformedData, 4);
700
savedData =
ML
.Transforms.SelectColumns("topics").Fit(savedData).Transform(savedData);
751
var model =
ML
.Model.Load(modelPath, out var inputSchema);
760
var engine =
ML
.Model.CreatePredictionEngine<SentimentData, SentimentPrediction>(model, inputSchema);
761
var testData =
ML
.Data.CreateEnumerable<SentimentData>(
762
ML
.Data.LoadFromTextFile(GetDataPath(TestDatasets.Sentiment.testFilename),
777
var dataView =
ML
.Data.LoadFromTextFile(dataPath, new[] {
782
var pipeline =
ML
.Transforms.Text.ProduceWordBags("Features")
783
.Append(
ML
.BinaryClassification.Trainers.FastTree());
Transformers\TextNormalizer.cs (12)
42
var dataView =
ML
.Data.LoadFromEnumerable(data);
43
var pipe = new TextNormalizingEstimator(
ML
, columns: new[] { ("NormA", "A"), ("NormB", "B") });
47
var invalidDataView =
ML
.Data.LoadFromEnumerable(invalidData);
51
dataView =
ML
.Data.LoadFromTextFile(dataPath, new[] {
56
var pipeVariations = new TextNormalizingEstimator(
ML
, columns: new[] { ("NormText", "text") }).Append(
57
new TextNormalizingEstimator(
ML
, caseMode: TextNormalizingEstimator.CaseMode.Upper, columns: new[] { ("UpperText", "text") })).Append(
58
new TextNormalizingEstimator(
ML
, keepDiacritics: true, columns: new[] { ("WithDiacriticsText", "text") })).Append(
59
new TextNormalizingEstimator(
ML
, keepNumbers: false, columns: new[] { ("NoNumberText", "text") })).Append(
60
new TextNormalizingEstimator(
ML
, keepPunctuations: false, columns: new[] { ("NoPuncText", "text") }));
63
var savedData =
ML
.Data.TakeRows(pipeVariations.Fit(dataView).Transform(dataView), 5);
65
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
81
var dataView =
ML
.Data.LoadFromEnumerable(data);
Transformers\ValueMappingTests.cs (43)
53
var dataView =
ML
.Data.LoadFromEnumerable(data);
91
var dataView =
ML
.Data.LoadFromEnumerable(data);
137
var dataView =
ML
.Data.LoadFromEnumerable(data);
146
Append(
ML
.Transforms.Conversion.MapValue(keyValuePairs, true, new[] { new InputOutputColumnPair("VecD", "TokenizeA"), new InputOutputColumnPair("E", "B"), new InputOutputColumnPair("F", "C") }));
172
var dataView =
ML
.Data.LoadFromEnumerable(data);
227
var dataView =
ML
.Data.LoadFromEnumerable(data);
234
var mapView =
ML
.Data.LoadFromEnumerable(map);
261
var dataView =
ML
.Data.LoadFromEnumerable(data);
305
var dataView =
ML
.Data.LoadFromEnumerable(data);
343
var dataView =
ML
.Data.LoadFromEnumerable(data);
362
var dataView =
ML
.Data.LoadFromEnumerable(data);
370
var est =
ML
.Transforms.Conversion.MapValue(keyValuePairs,
394
var dataView =
ML
.Data.LoadFromEnumerable(data);
402
var estimator =
ML
.Transforms.Conversion.MapValue(keyValuePairs, true,
427
var dataView =
ML
.Data.LoadFromEnumerable(data);
437
var estimator =
ML
.Transforms.Conversion.MapValue(keyValuePairs, true, new[] { new InputOutputColumnPair("D", "A"), new InputOutputColumnPair("E", "B"), new InputOutputColumnPair("F", "C") });
469
var dataView =
ML
.Data.LoadFromEnumerable(data);
478
var estimator =
ML
.Transforms.Conversion.MapValue(keyValuePairs, true, new[] { new InputOutputColumnPair("D", "A"), new InputOutputColumnPair("E", "B"), new InputOutputColumnPair("F", "C") });
509
var dataView =
ML
.Data.LoadFromEnumerable(data);
519
var estimator =
ML
.Transforms.Conversion.MapValue(keyValuePairs, true, new[] { new InputOutputColumnPair("D", "A"), new InputOutputColumnPair("E", "B"), new InputOutputColumnPair("F", "C") });
550
var dataView =
ML
.Data.LoadFromEnumerable(data);
558
var estimator =
ML
.Transforms.Conversion.MapValue("D", keyValuePairs, "A", true).
559
Append(
ML
.Transforms.Conversion.MapKeyToValue("DOutput", "D"));
590
var dataView =
ML
.Data.LoadFromEnumerable(data);
592
var badDataView =
ML
.Data.LoadFromEnumerable(badData);
601
var est =
ML
.Transforms.Conversion.MapValue(keyValuePairs, new[] { new InputOutputColumnPair("D", "A"), new InputOutputColumnPair("E", "B"), new InputOutputColumnPair("F", "C") });
609
var dataView =
ML
.Data.LoadFromEnumerable(data);
611
var badDataView =
ML
.Data.LoadFromEnumerable(badData);
620
var est =
ML
.Transforms.Conversion.MapValue(keyValuePairs, new[] { new InputOutputColumnPair("D", "A"), new InputOutputColumnPair("E", "B"), new InputOutputColumnPair("F", "C") });
628
var dataView =
ML
.Data.LoadFromEnumerable(data);
631
var badDataView =
ML
.Data.LoadFromEnumerable(badData);
640
var est =
ML
.Transforms.Text.TokenizeIntoWords("TokenizeB", "B")
641
.Append(
ML
.Transforms.Conversion.MapValue("VecB", keyValuePairs, "TokenizeB"));
685
var dataView =
ML
.Data.LoadFromEnumerable(data);
692
var est =
ML
.Transforms.Conversion.MapValue(keyValuePairs,
698
ML
.Model.Save(transformer, null, ms);
700
var loadedTransformer =
ML
.Model.Load(ms, out var schema);
715
var dataView =
ML
.Data.LoadFromEnumerable(data);
732
var dataView =
ML
.Data.LoadFromEnumerable(data);
763
var data =
ML
.Data.LoadFromEnumerable(rawData);
775
var lookupIdvMap =
ML
.Data.LoadFromEnumerable(lookupData);
778
var pipeline =
ML
.Transforms.Conversion.MapValue("PriceCategory", lookupIdvMap, lookupIdvMap.Schema["Value"], lookupIdvMap.Schema["Category"], "Price");
784
var features =
ML
.Data.CreateEnumerable<TransformedData>(transformedData, reuseRowObject: false).ToList();
Transformers\WordEmbeddingsTests.cs (16)
29
var data = new TextLoader(
ML
,
41
var est =
ML
.Transforms.Text.NormalizeText("NormalizedText", "SentimentText", keepDiacritics: false, keepPunctuations: false)
42
.Append(
ML
.Transforms.Text.TokenizeIntoWords("Words", "NormalizedText"))
43
.Append(
ML
.Transforms.Text.RemoveDefaultStopWords("CleanWords", "Words"));
46
var pipe =
ML
.Transforms.Text.ApplyWordEmbedding("WordEmbeddings", "CleanWords", modelKind: WordEmbeddingEstimator.PretrainedModelKind.SentimentSpecificWordEmbedding);
51
var savedData =
ML
.Data.TakeRows(pipe.Fit(words).Transform(words), 4);
52
savedData =
ML
.Transforms.SelectColumns("WordEmbeddings").Fit(savedData).Transform(savedData);
55
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
64
var data = new TextLoader(
ML
,
76
var est =
ML
.Transforms.Text.NormalizeText("NormalizedText", "SentimentText", keepDiacritics: false, keepPunctuations: false)
77
.Append(
ML
.Transforms.Text.TokenizeIntoWords("Words", "NormalizedText"))
78
.Append(
ML
.Transforms.Text.RemoveDefaultStopWords("CleanWords", "Words"));
89
var pipe =
ML
.Transforms.Text.ApplyWordEmbedding("WordEmbeddings", pathToCustomModel, "CleanWords");
94
var savedData =
ML
.Data.TakeRows(pipe.Fit(words).Transform(words), 10);
95
savedData =
ML
.Transforms.SelectColumns("WordEmbeddings", "CleanWords").Fit(savedData).Transform(savedData);
98
ML
.Data.SaveAsText(savedData, fs, headerRow: true, keepHidden: true);
Transformers\WordTokenizeTests.cs (4)
55
var dataView =
ML
.Data.LoadFromEnumerable(data);
57
var invalidDataView =
ML
.Data.LoadFromEnumerable(invalidData);
69
var nativeResult =
ML
.Data.CreateEnumerable<NativeResult>(result, false).First();
99
var dataView =
ML
.Data.LoadFromEnumerable(data);
Microsoft.ML.TimeSeries.Tests (18)
TimeSeriesEstimatorTests.cs (14)
54
var dataView =
ML
.Data.LoadFromEnumerable(data);
69
var invalidDataWrongNames =
ML
.Data.LoadFromEnumerable(xyData);
70
var invalidDataWrongTypes =
ML
.Data.LoadFromEnumerable(stringData);
105
var invalidDataWrongNames =
ML
.Data.LoadFromEnumerable(xyData);
106
var invalidDataWrongTypes =
ML
.Data.LoadFromEnumerable(stringData);
124
var dataView =
ML
.Data.LoadFromEnumerable(data);
139
var invalidDataWrongNames =
ML
.Data.LoadFromEnumerable(xyData);
140
var invalidDataWrongTypes =
ML
.Data.LoadFromEnumerable(stringData);
155
var dataView =
ML
.Data.LoadFromEnumerable(data);
166
var invalidDataWrongNames =
ML
.Data.LoadFromEnumerable(xyData);
167
var invalidDataWrongTypes =
ML
.Data.LoadFromEnumerable(stringData);
182
var dataView =
ML
.Data.LoadFromEnumerable(data);
193
var invalidDataWrongNames =
ML
.Data.LoadFromEnumerable(xyData);
194
var invalidDataWrongTypes =
ML
.Data.LoadFromEnumerable(stringData);
TimeSeriesSimpleApiTests.cs (4)
52
var learningPipeline =
ML
.Transforms.DetectIidChangePoint("Data", "Value", 80.0d, size);
96
var learningPipeline =
ML
.Transforms.DetectChangePointBySsa("Data", "Value", 95.0d, changeHistorySize, maxTrainingSize, seasonalitySize);
137
var learningPipeline =
ML
.Transforms.DetectIidSpike("Data", "Value", 80.0d, pvalHistoryLength);
189
var learningPipeline =
ML
.Transforms.DetectSpikeBySsa("Data", "Value", 80.0d, changeHistoryLength, trainingWindowSize, seasonalityWindowSize);
Microsoft.ML.TorchSharp.Tests (64)
NerTests.cs (18)
36
var labels =
ML
.Data.LoadFromEnumerable(
46
var dataView =
ML
.Data.LoadFromEnumerable(
70
var estimator = chain.Append(
ML
.Transforms.Conversion.MapValueToKey("Label", keyData: labels))
71
.Append(
ML
.MulticlassClassification.Trainers.NamedEntityRecognition(outputColumnName: "outputColumn"))
72
.Append(
ML
.Transforms.Conversion.MapKeyToValue("outputColumn"));
112
var labels =
ML
.Data.LoadFromEnumerable(
125
var dataView =
ML
.Data.LoadFromEnumerable(
149
var estimator = chain.Append(
ML
.Transforms.Conversion.MapValueToKey("Label", keyData: labels))
150
.Append(
ML
.MulticlassClassification.Trainers.NamedEntityRecognition(options))
151
.Append(
ML
.Transforms.Conversion.MapKeyToValue("outputColumn"));
191
ML
.FallbackToCpu = false;
192
ML
.GpuDeviceId = 0;
195
var labels =
ML
.Data.LoadFromTextFile(labelFilePath, new TextLoader.Column[]
202
var dataView = TextLoader.Create(
ML
, new TextLoader.Options()
217
var trainTest =
ML
.Data.TrainTestSplit(dataView);
223
var estimator = chain.Append(
ML
.Transforms.Conversion.MapValueToKey("Label", keyData: labels))
224
.Append(
ML
.MulticlassClassification.Trainers.NamedEntityRecognition(options))
225
.Append(
ML
.Transforms.Conversion.MapKeyToValue("outputColumn"));
ObjectDetectionTests.cs (18)
33
var data = TextLoader.Create(
ML
, new TextLoader.Options()
46
var filteredPipeline = chain.Append(
ML
.Transforms.Text.TokenizeIntoWords("Labels", separators: new char[] { ',' }), TransformerScope.Training)
47
.Append(
ML
.Transforms.Conversion.MapValueToKey("Labels"), TransformerScope.Training)
48
.Append(
ML
.Transforms.Text.TokenizeIntoWords("Box", separators: new char[] { ',' }), TransformerScope.Training)
49
.Append(
ML
.Transforms.Conversion.ConvertType("Box"), TransformerScope.Training)
50
.Append(
ML
.Transforms.LoadImages("Image", imageFolder, "ImagePath"))
51
.Append(
ML
.MulticlassClassification.Trainers.ObjectDetection("Labels", boundingBoxColumnName: "Box", maxEpoch: 1))
52
.Append(
ML
.Transforms.Conversion.MapKeyToValue("PredictedLabel"));
63
var pipeline =
ML
.Transforms.Text.TokenizeIntoWords("Labels", separators: new char[] { ',' })
64
.Append(
ML
.Transforms.Conversion.MapValueToKey("Labels"))
65
.Append(
ML
.Transforms.Text.TokenizeIntoWords("Box", separators: new char[] { ',' }))
66
.Append(
ML
.Transforms.Conversion.ConvertType("Box"))
67
.Append(
ML
.Transforms.LoadImages("Image", imageFolder, "ImagePath"))
68
.Append(
ML
.MulticlassClassification.Trainers.ObjectDetection(options))
69
.Append(
ML
.Transforms.Conversion.MapKeyToValue("PredictedLabel"));
73
ML
.Log += (o, e) =>
84
var metrics =
ML
.MulticlassClassification.EvaluateObjectDetection(idv, idv.Schema[2], idv.Schema["Box"], idv.Schema["PredictedLabel"], idv.Schema["PredictedBoundingBoxes"], idv.Schema["Score"]);
92
var dataFiltered = TextLoader.Create(
ML
, new TextLoader.Options()
QATests.cs (6)
32
var dataView =
ML
.Data.LoadFromEnumerable(
43
var estimator = chain.Append(
ML
.MulticlassClassification.Trainers.QuestionAnswer(maxEpochs: 1));
68
ML
.GpuDeviceId = 0;
69
ML
.FallbackToCpu = false;
73
IDataView dataView = TextLoader.Create(
ML
, new TextLoader.Options()
87
var estimator =
ML
.MulticlassClassification.Trainers.QuestionAnswer(maxEpochs: 30);
TextClassificationTests.cs (22)
54
var dataView =
ML
.Data.LoadFromEnumerable(
98
var estimator = chain.Append(
ML
.Transforms.Conversion.MapValueToKey("Label", "Sentiment"), TransformerScope.TrainTest)
99
.Append(
ML
.MulticlassClassification.Trainers.TextClassification(outputColumnName: "outputColumn"))
100
.Append(
ML
.Transforms.Conversion.MapKeyToValue("outputColumn"));
117
var dataNoLabel =
ML
.Data.LoadFromEnumerable(
156
var metrics =
ML
.MulticlassClassification.Evaluate(transformer.Transform(dataView, TransformerScope.Everything), predictedLabelColumnName: "outputColumn");
191
var dataView =
ML
.Data.LoadFromEnumerable(
235
var estimator =
ML
.Transforms.Conversion.MapValueToKey("Label", "Sentiment")
236
.Append(
ML
.MulticlassClassification.Trainers.TextClassification(outputColumnName: "outputColumn"))
237
.Append(
ML
.Transforms.Conversion.MapKeyToValue("outputColumn"));
264
var dataView =
ML
.Data.LoadFromEnumerable(
316
var dataPrep =
ML
.Transforms.Conversion.MapValueToKey("Label");
320
var estimator =
ML
.MulticlassClassification.Trainers.TextClassification(outputColumnName: "outputColumn", sentence1ColumnName: "Sentence", sentence2ColumnName: "Sentence2", validationSet: preppedData)
321
.Append(
ML
.Transforms.Conversion.MapKeyToValue("outputColumn"));
347
var dataView =
ML
.Data.LoadFromEnumerable(
387
var estimator =
ML
.Regression.Trainers.SentenceSimilarity(sentence1ColumnName: "Sentence", sentence2ColumnName: "Sentence2");
412
ML
.GpuDeviceId = 0;
413
ML
.FallbackToCpu = false;
417
IDataView dataView = TextLoader.Create(
ML
, new TextLoader.Options()
430
dataView =
ML
.Data.FilterRowsByMissingValues(dataView, "relevance");
432
var dataSplit =
ML
.Data.TrainTestSplit(dataView, testFraction: 0.2);
442
var estimator =
ML
.Regression.Trainers.SentenceSimilarity(options);