@@ -50,32 +50,27 @@ public virtual string TransformText()
50
50
this . Write ( this . ToStringHelper . ToStringWithCulture ( TestPath ) ) ;
51
51
this . Write ( "\" ;\r \n " ) ;
52
52
}
53
- this . Write ( @" private static string ModelPath = @""./model.zip"";
54
-
55
- static void Main(string[] args)
56
- {
57
- //Create MLContext to be shared across the model creation workflow objects
58
- //Set a random seed for repeatable/deterministic results across multiple trainings.
59
- var mlContext = new MLContext(seed: 1);
60
-
61
- // Create, Train, Evaluate and Save a model
62
- BuildTrainEvaluateAndSaveModel(mlContext);
63
- ConsoleHelper.ConsoleWriteHeader(""=============== End of training process ==============="");
64
-
65
- // Make a single test prediction loding the model from .ZIP file
66
- TestSinglePrediction(mlContext);
67
-
68
- ConsoleHelper.ConsoleWriteHeader(""=============== End of process, hit any key to finish ==============="");
69
- Console.ReadKey();
70
-
71
- }
72
-
73
- private static ITransformer BuildTrainEvaluateAndSaveModel(MLContext mlContext)
74
- {
75
- // Data loading
76
- IDataView trainingDataView = mlContext.Data.ReadFromTextFile<SampleObservation>(
77
- path: TrainDataPath,
78
- hasHeader : " ) ;
53
+ this . Write ( " private static string ModelPath = @\" ./model.zip\" ;\r \n \r \n // Set this " +
54
+ "flag to enable the training process.\r \n private static bool EnableTraining" +
55
+ " = false;\r \n \r \n static void Main(string[] args)\r \n {\r \n // " +
56
+ "Create MLContext to be shared across the model creation workflow objects \r \n " +
57
+ " // Set a random seed for repeatable/deterministic results across multiple" +
58
+ " trainings.\r \n var mlContext = new MLContext(seed: 1);\r \n \r \n " +
59
+ "if (EnableTraining)\r \n {\r \n // Create, Train, Evaluate a" +
60
+ "nd Save a model\r \n BuildTrainEvaluateAndSaveModel(mlContext);\r \n " +
61
+ " ConsoleHelper.ConsoleWriteHeader(\" =============== End of training p" +
62
+ "rocess ===============\" );\r \n }\r \n else\r \n {\r \n " +
63
+ " ConsoleHelper.ConsoleWriteHeader(\" Skipping the training process. Plea" +
64
+ "se set the flag : \' EnableTraining\' to \' true\' to enable the training process.\" );\r " +
65
+ "\n }\r \n \r \n // Make a single test prediction loading the model" +
66
+ " from .ZIP file\r \n TestSinglePrediction(mlContext);\r \n \r \n Con" +
67
+ "soleHelper.ConsoleWriteHeader(\" =============== End of process, hit any key to fi" +
68
+ "nish ===============\" );\r \n Console.ReadKey();\r \n \r \n }\r \n \r \n " +
69
+ "private static ITransformer BuildTrainEvaluateAndSaveModel(MLContext mlContext)\r " +
70
+ "\n {\r \n // Data loading\r \n IDataView trainingDataView " +
71
+ "= mlContext.Data.ReadFromTextFile<SampleObservation>(\r \n " +
72
+ " path: TrainDataPath,\r \n " +
73
+ " hasHeader : " ) ;
79
74
this . Write ( this . ToStringHelper . ToStringWithCulture ( HasHeader . ToString ( ) . ToLowerInvariant ( ) ) ) ;
80
75
this . Write ( ",\r \n separatorChar : \' " ) ;
81
76
this . Write ( this . ToStringHelper . ToStringWithCulture ( Regex . Escape ( Separator . ToString ( ) ) ) ) ;
0 commit comments