From 60d4f2853354025790c267e2a5ec804a67b52f78 Mon Sep 17 00:00:00 2001 From: LittleLittleCloud Date: Tue, 3 Mar 2020 17:06:13 -0800 Subject: [PATCH 1/3] update --- .../Templates/Console/ConsumeModel.cs | 15 ++++--- .../Templates/Console/ConsumeModel.tt | 15 ++++--- ...GeneratorTest.ConsumeModel.cs.approved.txt | 11 +++-- ...GeneratorTest.ConsumeModel.cs.approved.txt | 11 +++-- ...Tests.ConsumeModelContentTest.approved.txt | 11 +++-- ...ctContents_VerifyConsumeModel.approved.txt | 11 +++-- ...TemplateTest.TestConsumeModel.approved.txt | 44 +++++++++++++++++++ .../ApprovalTests/TemplateTest.cs | 16 +++++++ 8 files changed, 112 insertions(+), 22 deletions(-) create mode 100644 test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt diff --git a/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.cs b/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.cs index 7c01186c3b..f8ad4a016c 100644 --- a/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.cs +++ b/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.cs @@ -39,11 +39,18 @@ public virtual string TransformText() { public class ConsumeModel { + private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); + // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { - + ModelOutput result = PredictionEngine.Value.Predict(input); + return result; + } + + public static PredictionEngine CreatePredictionEngine() + { // Create new MLContext MLContext mlContext = new MLContext(); "); @@ -61,10 +68,8 @@ public static ModelOutput Predict(ModelInput input) this.Write(@"""; ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema); var predEngine = mlContext.Model.CreatePredictionEngine(mlModel); - - // Use model to make prediction on input data - ModelOutput result = predEngine.Predict(input); - return result; + + return predEngine; } } } diff --git a/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.tt b/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.tt index 626dde7a8b..dfa0049ebb 100644 --- a/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.tt +++ b/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.tt @@ -20,11 +20,18 @@ namespace <#= Namespace #>.Model { public class ConsumeModel { + private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); + // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { - + ModelOutput result = PredictionEngine.Value.Predict(input); + return result; + } + + public static PredictionEngine CreatePredictionEngine() + { // Create new MLContext MLContext mlContext = new MLContext(); <#if(HasNormalizeMapping){ #> @@ -40,10 +47,8 @@ namespace <#= Namespace #>.Model string modelPath = @"<#= MLNetModelpath #>"; ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema); var predEngine = mlContext.Model.CreatePredictionEngine(mlModel); - - // Use model to make prediction on input data - ModelOutput result = predEngine.Predict(input); - return result; + + return predEngine; } } } diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureCodeGeneratorTest.ConsumeModel.cs.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureCodeGeneratorTest.ConsumeModel.cs.approved.txt index f39eca9bd9..167ec139c4 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureCodeGeneratorTest.ConsumeModel.cs.approved.txt +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureCodeGeneratorTest.ConsumeModel.cs.approved.txt @@ -11,11 +11,18 @@ namespace Test.Model { public class ConsumeModel { + private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); + // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { + ModelOutput result = PredictionEngine.Value.Predict(input); + return result; + } + public static PredictionEngine CreatePredictionEngine() + { // Create new MLContext MLContext mlContext = new MLContext(); @@ -27,9 +34,7 @@ namespace Test.Model ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema); var predEngine = mlContext.Model.CreatePredictionEngine(mlModel); - // Use model to make prediction on input data - ModelOutput result = predEngine.Predict(input); - return result; + return predEngine; } } } diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureImageCodeGeneratorTest.ConsumeModel.cs.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureImageCodeGeneratorTest.ConsumeModel.cs.approved.txt index ed853667b8..9ab55f1b41 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureImageCodeGeneratorTest.ConsumeModel.cs.approved.txt +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureImageCodeGeneratorTest.ConsumeModel.cs.approved.txt @@ -11,11 +11,18 @@ namespace CodeGenTest.Model { public class ConsumeModel { + private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); + // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { + ModelOutput result = PredictionEngine.Value.Predict(input); + return result; + } + public static PredictionEngine CreatePredictionEngine() + { // Create new MLContext MLContext mlContext = new MLContext(); @@ -30,9 +37,7 @@ namespace CodeGenTest.Model ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema); var predEngine = mlContext.Model.CreatePredictionEngine(mlModel); - // Use model to make prediction on input data - ModelOutput result = predEngine.Predict(input); - return result; + return predEngine; } } } diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.ConsumeModelContentTest.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.ConsumeModelContentTest.approved.txt index 61b7b28beb..97cd60c6e6 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.ConsumeModelContentTest.approved.txt +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.ConsumeModelContentTest.approved.txt @@ -15,11 +15,18 @@ namespace TestNamespace.Model { public class ConsumeModel { + private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); + // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { + ModelOutput result = PredictionEngine.Value.Predict(input); + return result; + } + public static PredictionEngine CreatePredictionEngine() + { // Create new MLContext MLContext mlContext = new MLContext(); @@ -28,9 +35,7 @@ namespace TestNamespace.Model ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema); var predEngine = mlContext.Model.CreatePredictionEngine(mlModel); - // Use model to make prediction on input data - ModelOutput result = predEngine.Predict(input); - return result; + return predEngine; } } } diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.Recommendation_GenerateModelProjectContents_VerifyConsumeModel.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.Recommendation_GenerateModelProjectContents_VerifyConsumeModel.approved.txt index 61b7b28beb..97cd60c6e6 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.Recommendation_GenerateModelProjectContents_VerifyConsumeModel.approved.txt +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.Recommendation_GenerateModelProjectContents_VerifyConsumeModel.approved.txt @@ -15,11 +15,18 @@ namespace TestNamespace.Model { public class ConsumeModel { + private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); + // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { + ModelOutput result = PredictionEngine.Value.Predict(input); + return result; + } + public static PredictionEngine CreatePredictionEngine() + { // Create new MLContext MLContext mlContext = new MLContext(); @@ -28,9 +35,7 @@ namespace TestNamespace.Model ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema); var predEngine = mlContext.Model.CreatePredictionEngine(mlModel); - // Use model to make prediction on input data - ModelOutput result = predEngine.Predict(input); - return result; + return predEngine; } } } diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt new file mode 100644 index 0000000000..de660c2b85 --- /dev/null +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt @@ -0,0 +1,44 @@ +// This file was auto-generated by ML.NET Model Builder. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.ML; +using Namespace.Model; + +namespace Namespace.Model +{ + public class ConsumeModel + { + private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); + + // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume + // Method for consuming model in your app + public static ModelOutput Predict(ModelInput input) + { + ModelOutput result = PredictionEngine.Value.Predict(input); + return result; + } + + public static PredictionEngine CreatePredictionEngine() + { + + // Create new MLContext + MLContext mlContext = new MLContext(); + + // Register NormalizeMapping + mlContext.ComponentCatalog.RegisterAssembly(typeof(NormalizeMapping).Assembly); + + // Register LabelMapping + mlContext.ComponentCatalog.RegisterAssembly(typeof(LabelMapping).Assembly); + + // Load model & create prediction engine + string modelPath = @"/path/to/model"; + ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema); + var predEngine = mlContext.Model.CreatePredictionEngine(mlModel); + + return predEngine; + } + } +} diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.cs b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.cs index d4bb4ef9ca..5351a70401 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.cs +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.cs @@ -39,5 +39,21 @@ public void TestPredictProgram_WithSampleData() }; Approvals.Verify(predictProgram.TransformText()); } + + [Fact] + [UseReporter(typeof(DiffReporter))] + [MethodImpl(MethodImplOptions.NoInlining)] + public void TestConsumeModel() + { + var consumeModel = new ConsumeModel() + { + Namespace = "Namespace", + HasNormalizeMapping = true, + HasLabelMapping = true, + MLNetModelpath = @"/path/to/model", + }; + + Approvals.Verify(consumeModel.TransformText()); + } } } From 17498913094dcc42fc19437c4b79442d09b0ee16 Mon Sep 17 00:00:00 2001 From: LittleLittleCloud Date: Wed, 4 Mar 2020 10:08:06 -0800 Subject: [PATCH 2/3] fix test --- .../ApprovalTests/TemplateTest.TestConsumeModel.approved.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt index de660c2b85..3c01db97e1 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt @@ -23,7 +23,6 @@ namespace Namespace.Model public static PredictionEngine CreatePredictionEngine() { - // Create new MLContext MLContext mlContext = new MLContext(); From 806d5fa41215659631b10c78de7dbba1226c5fa3 Mon Sep 17 00:00:00 2001 From: LittleLittleCloud Date: Wed, 4 Mar 2020 12:16:27 -0800 Subject: [PATCH 3/3] fix comment --- .../Templates/Console/ConsumeModel.cs | 12 +++++++----- .../Templates/Console/ConsumeModel.tt | 6 +++--- ...ureCodeGeneratorTest.ConsumeModel.cs.approved.txt | 4 ++-- ...ageCodeGeneratorTest.ConsumeModel.cs.approved.txt | 6 +++--- ...neratorTests.ConsumeModelContentTest.approved.txt | 2 +- ...elProjectContents_VerifyConsumeModel.approved.txt | 2 +- .../TemplateTest.TestConsumeModel.approved.txt | 6 +++--- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.cs b/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.cs index f8ad4a016c..ba1983786b 100644 --- a/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.cs +++ b/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.cs @@ -41,7 +41,7 @@ public class ConsumeModel { private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); - // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume + // For more info on consuming ML.NET models, visit https://aka.ms/mlnet-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { @@ -55,12 +55,14 @@ public static PredictionEngine CreatePredictionEngine() MLContext mlContext = new MLContext(); "); if(HasNormalizeMapping){ - this.Write(" \r\n\t\t\t// Register NormalizeMapping\r\n mlContext.ComponentCatalog.Regist" + - "erAssembly(typeof(NormalizeMapping).Assembly);\r\n"); + this.Write(" \r\n\t\t\t// Register NormalizeMapping to calculate probabilities for each Label.\r\n " + + " mlContext.ComponentCatalog.RegisterAssembly(typeof(NormalizeMapping).A" + + "ssembly);\r\n"); } if(HasLabelMapping){ - this.Write(" \r\n\t\t\t// Register LabelMapping\r\n mlContext.ComponentCatalog.RegisterAs" + - "sembly(typeof(LabelMapping).Assembly);\r\n"); + this.Write(" \r\n\t\t\t// Register LabelMapping to map predicted Labels to their corresponding pro" + + "babilities (likelihood of specified Labels)\r\n mlContext.ComponentCata" + + "log.RegisterAssembly(typeof(LabelMapping).Assembly);\r\n"); } this.Write("\r\n // Load model & create prediction engine\r\n string modelP" + "ath = @\""); diff --git a/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.tt b/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.tt index dfa0049ebb..30128af221 100644 --- a/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.tt +++ b/src/Microsoft.ML.CodeGenerator/Templates/Console/ConsumeModel.tt @@ -22,7 +22,7 @@ namespace <#= Namespace #>.Model { private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); - // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume + // For more info on consuming ML.NET models, visit https://aka.ms/mlnet-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { @@ -35,11 +35,11 @@ namespace <#= Namespace #>.Model // Create new MLContext MLContext mlContext = new MLContext(); <#if(HasNormalizeMapping){ #> - // Register NormalizeMapping + // Register NormalizeMapping to calculate probabilities for each Label. mlContext.ComponentCatalog.RegisterAssembly(typeof(NormalizeMapping).Assembly); <#} #> <#if(HasLabelMapping){ #> - // Register LabelMapping + // Register LabelMapping to map predicted Labels to their corresponding probabilities (likelihood of specified Labels) mlContext.ComponentCatalog.RegisterAssembly(typeof(LabelMapping).Assembly); <#} #> diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureCodeGeneratorTest.ConsumeModel.cs.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureCodeGeneratorTest.ConsumeModel.cs.approved.txt index 167ec139c4..1e9da143aa 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureCodeGeneratorTest.ConsumeModel.cs.approved.txt +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureCodeGeneratorTest.ConsumeModel.cs.approved.txt @@ -13,7 +13,7 @@ namespace Test.Model { private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); - // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume + // For more info on consuming ML.NET models, visit https://aka.ms/mlnet-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { @@ -26,7 +26,7 @@ namespace Test.Model // Create new MLContext MLContext mlContext = new MLContext(); - // Register LabelMapping + // Register LabelMapping to map predicted Labels to their corresponding probabilities (likelihood of specified Labels) mlContext.ComponentCatalog.RegisterAssembly(typeof(LabelMapping).Assembly); // Load model & create prediction engine diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureImageCodeGeneratorTest.ConsumeModel.cs.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureImageCodeGeneratorTest.ConsumeModel.cs.approved.txt index 9ab55f1b41..c7194979d9 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureImageCodeGeneratorTest.ConsumeModel.cs.approved.txt +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.AzureImageCodeGeneratorTest.ConsumeModel.cs.approved.txt @@ -13,7 +13,7 @@ namespace CodeGenTest.Model { private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); - // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume + // For more info on consuming ML.NET models, visit https://aka.ms/mlnet-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { @@ -26,10 +26,10 @@ namespace CodeGenTest.Model // Create new MLContext MLContext mlContext = new MLContext(); - // Register NormalizeMapping + // Register NormalizeMapping to calculate probabilities for each Label. mlContext.ComponentCatalog.RegisterAssembly(typeof(NormalizeMapping).Assembly); - // Register LabelMapping + // Register LabelMapping to map predicted Labels to their corresponding probabilities (likelihood of specified Labels) mlContext.ComponentCatalog.RegisterAssembly(typeof(LabelMapping).Assembly); // Load model & create prediction engine diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.ConsumeModelContentTest.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.ConsumeModelContentTest.approved.txt index 97cd60c6e6..1e5a191392 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.ConsumeModelContentTest.approved.txt +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.ConsumeModelContentTest.approved.txt @@ -17,7 +17,7 @@ namespace TestNamespace.Model { private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); - // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume + // For more info on consuming ML.NET models, visit https://aka.ms/mlnet-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.Recommendation_GenerateModelProjectContents_VerifyConsumeModel.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.Recommendation_GenerateModelProjectContents_VerifyConsumeModel.approved.txt index 97cd60c6e6..1e5a191392 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.Recommendation_GenerateModelProjectContents_VerifyConsumeModel.approved.txt +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.Recommendation_GenerateModelProjectContents_VerifyConsumeModel.approved.txt @@ -17,7 +17,7 @@ namespace TestNamespace.Model { private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); - // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume + // For more info on consuming ML.NET models, visit https://aka.ms/mlnet-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { diff --git a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt index 3c01db97e1..25811efe96 100644 --- a/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt +++ b/test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/TemplateTest.TestConsumeModel.approved.txt @@ -13,7 +13,7 @@ namespace Namespace.Model { private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); - // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume + // For more info on consuming ML.NET models, visit https://aka.ms/mlnet-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { @@ -26,10 +26,10 @@ namespace Namespace.Model // Create new MLContext MLContext mlContext = new MLContext(); - // Register NormalizeMapping + // Register NormalizeMapping to calculate probabilities for each Label. mlContext.ComponentCatalog.RegisterAssembly(typeof(NormalizeMapping).Assembly); - // Register LabelMapping + // Register LabelMapping to map predicted Labels to their corresponding probabilities (likelihood of specified Labels) mlContext.ComponentCatalog.RegisterAssembly(typeof(LabelMapping).Assembly); // Load model & create prediction engine