@@ -60,15 +60,28 @@ static void Main(string[] args)
60
60
// Create MLContext to be shared across the model creation workflow objects
61
61
var mlContext = new MLContext();
62
62
63
- // (Optional step) Create, Train, Evaluate and Save the model.zip file
64
- TrainEvaluateAndSaveModel(mlContext);
63
+ var command = Command.Predict; // Your desired action here
65
64
66
- // Make a single test prediction loading the model from model.zip file
67
- Predict(mlContext);
65
+ if (command == Command.Predict)
66
+ {
67
+ Predict(mlContext);
68
+ ConsoleHelper.ConsoleWriteHeader(""=============== If you also want to train a model use Command.TrainAndPredict ==============="");
69
+ }
68
70
69
- ConsoleHelper.ConsoleWriteHeader(""=============== End of process, hit any key to finish ==============="");
71
+ if (command == Command.TrainAndPredict)
72
+ {
73
+ TrainEvaluateAndSaveModel(mlContext);
74
+ Predict(mlContext);
75
+ }
76
+
77
+ Console.WriteLine(""=============== End of process, hit any key to finish ==============="");
70
78
Console.ReadKey();
79
+ }
71
80
81
+ private enum Command
82
+ {
83
+ Predict,
84
+ TrainAndPredict
72
85
}
73
86
74
87
private static ITransformer TrainEvaluateAndSaveModel(MLContext mlContext)
@@ -184,7 +197,7 @@ private static ITransformer TrainEvaluateAndSaveModel(MLContext mlContext)
184
197
mlContext.Model.Save(trainedModel, fs);
185
198
186
199
Console.WriteLine(""The model is saved to {0}"", ModelPath);
187
- ConsoleHelper.ConsoleWriteHeader (""=============== End of training process ==============="");
200
+ Console.WriteLine (""=============== End of training process ==============="");
188
201
189
202
return trainedModel;
190
203
}
0 commit comments