Skip to content

Commit 47e1397

Browse files
srsaggamDmitry-A
authored andcommitted
Include some missed logging in the generated code. (dotnet#199)
* added logging messages for generated code * added log messages * deleted file
1 parent 82528ef commit 47e1397

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/mlnet.Test/ApprovalTests/ConsoleCodeGeneratorTests.GeneratedTrainCodeTest.approved.txt

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ namespace MyNamespace
6464
var trainingPipeline = dataProcessPipeline.Append(trainer);
6565

6666
// Train the model fitting to the DataSet
67+
Console.WriteLine("=============== Training the model ===============");
6768
var trainedModel = trainingPipeline.Fit(trainingDataView);
6869

6970
// Evaluate the model and show accuracy stats
@@ -73,6 +74,7 @@ namespace MyNamespace
7374
ConsoleHelper.PrintBinaryClassificationMetrics(trainer.ToString(), metrics);
7475

7576
// Save/persist the trained model to a .ZIP file
77+
Console.WriteLine($"=============== Saving the model ===============");
7678
using (var fs = new FileStream(ModelPath, FileMode.Create, FileAccess.Write, FileShare.Write))
7779
mlContext.Model.Save(trainedModel, fs);
7880

src/mlnet/Templates/Console/MLCodeGen.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ private static ITransformer BuildTrainEvaluateAndSaveModel(MLContext mlContext)
150150
"rics(trainer.ToString(), crossValidationResults);\r\n");
151151
}
152152
}
153-
this.Write("\r\n // Train the model fitting to the DataSet\r\n var trainedM" +
154-
"odel = trainingPipeline.Fit(trainingDataView);\r\n\r\n");
153+
this.Write("\r\n // Train the model fitting to the DataSet\r\n Console.Writ" +
154+
"eLine(\"=============== Training the model ===============\");\r\n var tr" +
155+
"ainedModel = trainingPipeline.Fit(trainingDataView);\r\n\r\n");
155156
if(!string.IsNullOrEmpty(TestPath)){
156157
this.Write(" // Evaluate the model and show accuracy stats\r\n Console.Wr" +
157158
"iteLine(\"===== Evaluating Model\'s accuracy with Test data =====\");\r\n " +
@@ -171,6 +172,7 @@ private static ITransformer BuildTrainEvaluateAndSaveModel(MLContext mlContext)
171172
}
172173
this.Write(@"
173174
// Save/persist the trained model to a .ZIP file
175+
Console.WriteLine($""=============== Saving the model ==============="");
174176
using (var fs = new FileStream(ModelPath, FileMode.Create, FileAccess.Write, FileShare.Write))
175177
mlContext.Model.Save(trainedModel, fs);
176178

src/mlnet/Templates/Console/MLCodeGen.tt

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ else{#>
101101
} #>
102102

103103
// Train the model fitting to the DataSet
104+
Console.WriteLine("=============== Training the model ===============");
104105
var trainedModel = trainingPipeline.Fit(trainingDataView);
105106

106107
<# if(!string.IsNullOrEmpty(TestPath)){ #>
@@ -117,6 +118,7 @@ else{#>
117118
<# } #>
118119

119120
// Save/persist the trained model to a .ZIP file
121+
Console.WriteLine($"=============== Saving the model ===============");
120122
using (var fs = new FileStream(ModelPath, FileMode.Create, FileAccess.Write, FileShare.Write))
121123
mlContext.Model.Save(trainedModel, fs);
122124

0 commit comments

Comments
 (0)