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