@@ -11,6 +11,7 @@ namespace Microsoft.ML.CLI.Templates.Console
11
11
{
12
12
using System . Linq ;
13
13
using System . Text ;
14
+ using System . Text . RegularExpressions ;
14
15
using System . Collections . Generic ;
15
16
using Microsoft . ML . CLI . Utilities ;
16
17
using System ;
@@ -44,14 +45,14 @@ public virtual string TransformText()
44
45
using Microsoft.Data.DataView;
45
46
using " ) ;
46
47
47
- #line 20 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
48
+ #line 21 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
48
49
this . Write ( this . ToStringHelper . ToStringWithCulture ( Namespace ) ) ;
49
50
50
51
#line default
51
52
#line hidden
52
53
this . Write ( ".Model.DataModels;\r \n \r \n \r \n namespace " ) ;
53
54
54
- #line 23 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
55
+ #line 24 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
55
56
this . Write ( this . ToStringHelper . ToStringWithCulture ( Namespace ) ) ;
56
57
57
58
#line default
@@ -60,35 +61,35 @@ public virtual string TransformText()
60
61
"nd use for predictions\r \n private const string MODEL_FILEPATH = @\" MLModel." +
61
62
"zip\" ;\r \n \r \n //Dataset to use for predictions \r \n " ) ;
62
63
63
- #line 31 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
64
+ #line 32 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
64
65
if ( string . IsNullOrEmpty ( TestDataPath ) ) {
65
66
66
67
#line default
67
68
#line hidden
68
69
this . Write ( " private const string DATA_FILEPATH = @\" " ) ;
69
70
70
- #line 32 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
71
+ #line 33 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
71
72
this . Write ( this . ToStringHelper . ToStringWithCulture ( TrainDataPath ) ) ;
72
73
73
74
#line default
74
75
#line hidden
75
76
this . Write ( "\" ;\r \n " ) ;
76
77
77
- #line 33 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
78
+ #line 34 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
78
79
} else {
79
80
80
81
#line default
81
82
#line hidden
82
83
this . Write ( " private const string DATA_FILEPATH = @\" " ) ;
83
84
84
- #line 34 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
85
+ #line 35 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
85
86
this . Write ( this . ToStringHelper . ToStringWithCulture ( TestDataPath ) ) ;
86
87
87
88
#line default
88
89
#line hidden
89
90
this . Write ( "\" ;\r \n " ) ;
90
91
91
- #line 35 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
92
+ #line 36 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
92
93
}
93
94
94
95
#line default
@@ -120,50 +121,50 @@ private static void Predict(MLContext mlContext, ITransformer mlModel, SampleObs
120
121
var predictionResult = predEngine.Predict(sampleData);
121
122
" ) ;
122
123
123
- #line 61 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
124
+ #line 62 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
124
125
if ( "BinaryClassification" . Equals ( TaskType ) ) {
125
126
126
127
#line default
127
128
#line hidden
128
129
this . Write ( " Console.WriteLine($\" Single Prediction --> Actual value: {sampleData." ) ;
129
130
130
- #line 62 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
131
+ #line 63 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
131
132
this . Write ( this . ToStringHelper . ToStringWithCulture ( Utils . Normalize ( LabelName ) ) ) ;
132
133
133
134
#line default
134
135
#line hidden
135
136
this . Write ( "} | Predicted value: {predictionResult.Prediction}\" );\r \n " ) ;
136
137
137
- #line 63 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
138
+ #line 64 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
138
139
} else if ( "Regression" . Equals ( TaskType ) ) {
139
140
140
141
#line default
141
142
#line hidden
142
143
this . Write ( " Console.WriteLine($\" Single Prediction --> Actual value: {sampleData." ) ;
143
144
144
- #line 64 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
145
+ #line 65 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
145
146
this . Write ( this . ToStringHelper . ToStringWithCulture ( Utils . Normalize ( LabelName ) ) ) ;
146
147
147
148
#line default
148
149
#line hidden
149
150
this . Write ( "} | Predicted value: {predictionResult.Score}\" );\r \n " ) ;
150
151
151
- #line 65 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
152
+ #line 66 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
152
153
} else if ( "MulticlassClassification" . Equals ( TaskType ) ) {
153
154
154
155
#line default
155
156
#line hidden
156
157
this . Write ( " Console.WriteLine($\" Single Prediction --> Actual value: {sampleData." ) ;
157
158
158
- #line 66 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
159
+ #line 67 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
159
160
this . Write ( this . ToStringHelper . ToStringWithCulture ( Utils . Normalize ( LabelName ) ) ) ;
160
161
161
162
#line default
162
163
#line hidden
163
164
this . Write ( "} | Predicted value: {predictionResult.Prediction} | Predicted scores: [{String.J" +
164
- "oin(\\ \" , \\ \ " , resultprediction.Scores )}]\" );\r \n " ) ;
165
+ "oin(\" , \ " , predictionResult.Score )}]\" );\r \n " ) ;
165
166
166
- #line 67 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
167
+ #line 68 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
167
168
}
168
169
169
170
#line default
@@ -188,8 +189,35 @@ private static SampleObservation CreateSingleDataSample(MLContext mlContext, str
188
189
// Read dataset to get a single row for trying a prediction
189
190
IDataView dataView = mlContext.Data.LoadFromTextFile<SampleObservation>(
190
191
path: dataFilePath,
191
- hasHeader: true,
192
- separatorChar: ',');
192
+ hasHeader : " ) ;
193
+
194
+ #line 89 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
195
+ this . Write ( this . ToStringHelper . ToStringWithCulture ( HasHeader . ToString ( ) . ToLowerInvariant ( ) ) ) ;
196
+
197
+ #line default
198
+ #line hidden
199
+ this . Write ( ",\r \n separatorChar : \' " ) ;
200
+
201
+ #line 90 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
202
+ this . Write ( this . ToStringHelper . ToStringWithCulture ( Regex . Escape ( Separator . ToString ( ) ) ) ) ;
203
+
204
+ #line default
205
+ #line hidden
206
+ this . Write ( "\' ,\r \n allowQuoting : " ) ;
207
+
208
+ #line 91 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
209
+ this . Write ( this . ToStringHelper . ToStringWithCulture ( AllowQuoting . ToString ( ) . ToLowerInvariant ( ) ) ) ;
210
+
211
+ #line default
212
+ #line hidden
213
+ this . Write ( ",\r \n allowSparse: " ) ;
214
+
215
+ #line 92 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
216
+ this . Write ( this . ToStringHelper . ToStringWithCulture ( AllowSparse . ToString ( ) . ToLowerInvariant ( ) ) ) ;
217
+
218
+ #line default
219
+ #line hidden
220
+ this . Write ( @");
193
221
194
222
// Here (SampleObservation object) you could provide new test data, hardcoded or from the end-user application, instead of the row from the file.
195
223
SampleObservation sampleForPrediction = mlContext.Data.CreateEnumerable<SampleObservation>(dataView, false)
@@ -202,13 +230,17 @@ private static SampleObservation CreateSingleDataSample(MLContext mlContext, str
202
230
return this . GenerationEnvironment . ToString ( ) ;
203
231
}
204
232
205
- #line 98 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
233
+ #line 101 "E:\src\machinelearning-automl\src\mlnet\Templates\Console\PredictProgram.tt"
206
234
207
235
public string TaskType { get ; set ; }
208
236
public string Namespace { get ; set ; }
209
237
public string LabelName { get ; set ; }
210
238
public string TestDataPath { get ; set ; }
211
239
public string TrainDataPath { get ; set ; }
240
+ public char Separator { get ; set ; }
241
+ public bool AllowQuoting { get ; set ; }
242
+ public bool AllowSparse { get ; set ; }
243
+ public bool HasHeader { get ; set ; }
212
244
213
245
214
246
#line default
0 commit comments