125 references to Write
Microsoft.ML.CodeGenerator (125)
Templates\Console\ModelBuilder.cs (125)
35this.Write("\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.IO;\r\nusing Syste" + 37this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); 38this.Write(".Model;\r\n"); 39this.Write(this.ToStringHelper.ToStringWithCulture(GeneratedUsings)); 40this.Write("\r\nnamespace "); 41this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); 42this.Write(".ConsoleApp\r\n{\r\n public static class ModelBuilder\r\n {\r\n private stat" + 44this.Write(this.ToStringHelper.ToStringWithCulture(Path)); 45this.Write("\";\r\n"); 47this.Write(" private static string TEST_DATA_FILEPATH = @\""); 48this.Write(this.ToStringHelper.ToStringWithCulture(TestPath)); 49this.Write("\";\r\n"); 51this.Write(@" private static string MODEL_FILE = ConsumeModel.MLNetModelPath; 63this.Write(this.ToStringHelper.ToStringWithCulture(HasHeader.ToString().ToLowerInvariant())); 64this.Write(",\r\n separatorChar : \'"); 65this.Write(this.ToStringHelper.ToStringWithCulture(Regex.Escape(Separator.ToString()))); 66this.Write("\',\r\n allowQuoting : "); 67this.Write(this.ToStringHelper.ToStringWithCulture(AllowQuoting.ToString().ToLowerInvariant())); 68this.Write(",\r\n allowSparse: "); 69this.Write(this.ToStringHelper.ToStringWithCulture(AllowSparse.ToString().ToLowerInvariant())); 70this.Write(");\r\n\r\n"); 72this.Write(" IDataView testDataView = mlContext.Data.LoadFromTextFile<ModelInput>(" + 75this.Write(this.ToStringHelper.ToStringWithCulture(HasHeader.ToString().ToLowerInvariant())); 76this.Write(",\r\n separatorChar : \'"); 77this.Write(this.ToStringHelper.ToStringWithCulture(Regex.Escape(Separator.ToString()))); 78this.Write("\',\r\n allowQuoting : "); 79this.Write(this.ToStringHelper.ToStringWithCulture(AllowQuoting.ToString().ToLowerInvariant())); 80this.Write(",\r\n allowSparse: "); 81this.Write(this.ToStringHelper.ToStringWithCulture(AllowSparse.ToString().ToLowerInvariant())); 82this.Write(");\r\n"); 84this.Write(@" // Build training pipeline 92this.Write(" // Evaluate quality of Model\r\n Evaluate(mlContext, trainin" + 96this.Write(" // Evaluate quality of Model\r\n EvaluateModel(mlContext, ml" + 99this.Write(" // Save model\r\n SaveModel(mlContext, mlModel, MODEL_FILE, " + 103this.Write(" // Data process configuration with pipeline data transformations \r\n " + 108{ Write("\r\n .Append("); 110Write("mlContext.Transforms."+PreTrainerTransforms[i]); 112{ Write(")"); 116Write("\r\n .AppendCacheCheckpoint(mlContext)"); 118this.Write(";\r\n"); 121this.Write(" // Set the training algorithm \r\n var trainer = mlContext."); 122this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 124this.Write("()"); 126this.Write(".Trainers."); 127this.Write(this.ToStringHelper.ToStringWithCulture(Trainer)); 130Write("\r\n .Append("); 131Write("mlContext.Transforms."+PostTrainerTransforms[i]); 132Write(")"); 134this.Write(";\r\n"); 136this.Write("\r\n"); 138this.Write(" var trainingPipeline = dataProcessPipeline.Append(trainer);\r\n"); 141this.Write("\t\t\tvar trainingPipeline = dataProcessPipeline;\r\n"); 144this.Write(" var trainingPipeline = trainer;\r\n"); 146this.Write(@" 162this.Write(@" private static void EvaluateModel(MLContext mlContext, ITransformer mlModel, IDataView testDataView) 169this.Write(" var metrics = mlContext."); 170this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 171this.Write(".EvaluateNonCalibrated(predictions, \""); 172this.Write(this.ToStringHelper.ToStringWithCulture(LabelName)); 173this.Write("\", \"Score\");\r\n PrintBinaryClassificationMetrics(metrics);\r\n"); 175this.Write(" var metrics = mlContext."); 176this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 177this.Write(".Evaluate(predictions, \""); 178this.Write(this.ToStringHelper.ToStringWithCulture(LabelName)); 179this.Write("\", \"Score\");\r\n PrintMulticlassClassificationMetrics(metrics);\r\n"); 181this.Write(" var metrics = mlContext."); 182this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 184this.Write("()"); 186this.Write(".Evaluate(predictions, \""); 187this.Write(this.ToStringHelper.ToStringWithCulture(LabelName)); 188this.Write("\", \"Score\");\r\n PrintRegressionMetrics(metrics);\r\n"); 190this.Write(" var metrics = mlContext."); 191this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 192this.Write(".Evaluate(predictions, \""); 193this.Write(this.ToStringHelper.ToStringWithCulture(LabelName)); 194this.Write("\", \"Score\");\r\n PrintRankingMetrics(metrics);\r\n"); 196this.Write(" }\r\n"); 198this.Write(@" private static void Evaluate(MLContext mlContext, IDataView trainingDataView, IEstimator<ITransformer> trainingPipeline) 205this.Write(" var crossValidationResults = mlContext."); 206this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 207this.Write(".CrossValidateNonCalibrated(trainingDataView, trainingPipeline, numberOfFolds: "); 208this.Write(this.ToStringHelper.ToStringWithCulture(Kfolds)); 209this.Write(", labelColumnName:\""); 210this.Write(this.ToStringHelper.ToStringWithCulture(LabelName)); 211this.Write("\");\r\n PrintBinaryClassificationFoldsAverageMetrics(crossValidationResu" + 215this.Write(" var crossValidationResults = mlContext."); 216this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 217this.Write(".CrossValidate(trainingDataView, trainingPipeline, numberOfFolds: "); 218this.Write(this.ToStringHelper.ToStringWithCulture(Kfolds)); 219this.Write(", labelColumnName:\""); 220this.Write(this.ToStringHelper.ToStringWithCulture(LabelName)); 221this.Write("\");\r\n PrintMulticlassClassificationFoldsAverageMetrics(crossValidation" + 225this.Write(" var crossValidationResults = mlContext."); 226this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 227this.Write(".CrossValidate(trainingDataView, trainingPipeline, numberOfFolds: "); 228this.Write(this.ToStringHelper.ToStringWithCulture(Kfolds)); 229this.Write(", labelColumnName:\""); 230this.Write(this.ToStringHelper.ToStringWithCulture(LabelName)); 231this.Write("\");\r\n PrintRegressionFoldsAverageMetrics(crossValidationResults);\r\n"); 234this.Write(" var crossValidationResults = mlContext."); 235this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 236this.Write(".CrossValidate(trainingDataView, trainingPipeline, numberOfFolds: "); 237this.Write(this.ToStringHelper.ToStringWithCulture(Kfolds)); 238this.Write(", labelColumnName:\""); 239this.Write(this.ToStringHelper.ToStringWithCulture(LabelName)); 240this.Write("\");\r\n PrintRankingFoldsAverageMetrics(crossValidationResults);\r\n"); 242this.Write(" }\r\n"); 244this.Write(@" 265this.Write(" public static void PrintRegressionMetrics(RegressionMetrics metrics)\r\n " + 268this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 269this.Write(@" model ""); 289this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 290this.Write(@" model ""); 301this.Write(" public static void PrintBinaryClassificationMetrics(BinaryClassificationM" + 336this.Write(" public static void PrintMulticlassClassificationMetrics(MulticlassClassif" + 400this.Write(" public static void PrintRankingMetrics(RankingMetrics metrics)\r\n {" + 403this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 404this.Write(@" model ""); 419this.Write(this.ToStringHelper.ToStringWithCulture(TaskType)); 420this.Write(@" model ""); 428this.Write(" }\r\n}\r\n"); 454this.Write(@"//***************************************************************************************** 467this.Write("// This file was auto-generated by ML.NET Model Builder. \r\n"); 608this.Write(textToAppend); 617this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));