@@ -107,10 +107,10 @@ public sealed class Arguments : DataCommand.ArgumentsBase
107
107
public CrossValidationCommand ( IHostEnvironment env , Arguments args )
108
108
: base ( env , args , RegistrationName )
109
109
{
110
- Host . CheckUserArg ( Args . NumFolds >= 2 , nameof ( Args . NumFolds ) , "Number of folds must be greater than or equal to 2." ) ;
110
+ Host . CheckUserArg ( ImplOptions . NumFolds >= 2 , nameof ( ImplOptions . NumFolds ) , "Number of folds must be greater than or equal to 2." ) ;
111
111
TrainUtils . CheckTrainer ( Host , args . Trainer , args . DataFile ) ;
112
- Utils . CheckOptionalUserDirectory ( Args . SummaryFilename , nameof ( Args . SummaryFilename ) ) ;
113
- Utils . CheckOptionalUserDirectory ( Args . OutputDataFile , nameof ( Args . OutputDataFile ) ) ;
112
+ Utils . CheckOptionalUserDirectory ( ImplOptions . SummaryFilename , nameof ( ImplOptions . SummaryFilename ) ) ;
113
+ Utils . CheckOptionalUserDirectory ( ImplOptions . OutputDataFile , nameof ( ImplOptions . OutputDataFile ) ) ;
114
114
}
115
115
116
116
// This is for "forking" the host environment.
@@ -124,7 +124,7 @@ public override void Run()
124
124
using ( var ch = Host . Start ( LoadName ) )
125
125
using ( var server = InitServer ( ch ) )
126
126
{
127
- var settings = CmdParser . GetSettings ( Host , Args , new Arguments ( ) ) ;
127
+ var settings = CmdParser . GetSettings ( Host , ImplOptions , new Arguments ( ) ) ;
128
128
string cmd = string . Format ( "maml.exe {0} {1}" , LoadName , settings ) ;
129
129
ch . Info ( cmd ) ;
130
130
@@ -139,7 +139,7 @@ public override void Run()
139
139
140
140
protected override void SendTelemetryCore ( IPipe < TelemetryMessage > pipe )
141
141
{
142
- SendTelemetryComponent ( pipe , Args . Trainer ) ;
142
+ SendTelemetryComponent ( pipe , ImplOptions . Trainer ) ;
143
143
base . SendTelemetryCore ( pipe ) ;
144
144
}
145
145
@@ -148,17 +148,17 @@ private void RunCore(IChannel ch, string cmd)
148
148
Host . AssertValue ( ch ) ;
149
149
150
150
IPredictor inputPredictor = null ;
151
- if ( Args . ContinueTrain && ! TrainUtils . TryLoadPredictor ( ch , Host , Args . InputModelFile , out inputPredictor ) )
151
+ if ( ImplOptions . ContinueTrain && ! TrainUtils . TryLoadPredictor ( ch , Host , ImplOptions . InputModelFile , out inputPredictor ) )
152
152
ch . Warning ( "No input model file specified or model file did not contain a predictor. The model state cannot be initialized." ) ;
153
153
154
154
ch . Trace ( "Constructing data pipeline" ) ;
155
155
IDataLoader loader = CreateRawLoader ( ) ;
156
156
157
157
// If the per-instance results are requested and there is no name column, add a GenerateNumberTransform.
158
- var preXf = Args . PreTransforms ;
159
- if ( ! string . IsNullOrEmpty ( Args . OutputDataFile ) )
158
+ var preXf = ImplOptions . PreTransforms ;
159
+ if ( ! string . IsNullOrEmpty ( ImplOptions . OutputDataFile ) )
160
160
{
161
- string name = TrainUtils . MatchNameOrDefaultOrNull ( ch , loader . Schema , nameof ( Args . NameColumn ) , Args . NameColumn , DefaultColumnNames . Name ) ;
161
+ string name = TrainUtils . MatchNameOrDefaultOrNull ( ch , loader . Schema , nameof ( ImplOptions . NameColumn ) , ImplOptions . NameColumn , DefaultColumnNames . Name ) ;
162
162
if ( name == null )
163
163
{
164
164
preXf = preXf . Concat (
@@ -182,24 +182,24 @@ private void RunCore(IChannel ch, string cmd)
182
182
183
183
IDataView pipe = loader ;
184
184
var stratificationColumn = GetSplitColumn ( ch , loader , ref pipe ) ;
185
- var scorer = Args . Scorer ;
186
- var evaluator = Args . Evaluator ;
185
+ var scorer = ImplOptions . Scorer ;
186
+ var evaluator = ImplOptions . Evaluator ;
187
187
188
188
Func < IDataView > validDataCreator = null ;
189
- if ( Args . ValidationFile != null )
189
+ if ( ImplOptions . ValidationFile != null )
190
190
{
191
191
validDataCreator =
192
192
( ) =>
193
193
{
194
194
// Fork the command.
195
195
var impl = new CrossValidationCommand ( this ) ;
196
- return impl . CreateRawLoader ( dataFile : Args . ValidationFile ) ;
196
+ return impl . CreateRawLoader ( dataFile : ImplOptions . ValidationFile ) ;
197
197
} ;
198
198
}
199
199
200
200
FoldHelper fold = new FoldHelper ( Host , RegistrationName , pipe , stratificationColumn ,
201
- Args , CreateRoleMappedData , ApplyAllTransformsToData , scorer , evaluator ,
202
- validDataCreator , ApplyAllTransformsToData , inputPredictor , cmd , loader , ! string . IsNullOrEmpty ( Args . OutputDataFile ) ) ;
201
+ ImplOptions , CreateRoleMappedData , ApplyAllTransformsToData , scorer , evaluator ,
202
+ validDataCreator , ApplyAllTransformsToData , inputPredictor , cmd , loader , ! string . IsNullOrEmpty ( ImplOptions . OutputDataFile ) ) ;
203
203
var tasks = fold . GetCrossValidationTasks ( ) ;
204
204
205
205
var eval = evaluator ? . CreateComponent ( Host ) ??
@@ -218,32 +218,32 @@ private void RunCore(IChannel ch, string cmd)
218
218
throw ch . Except ( "No overall metrics found" ) ;
219
219
220
220
var overall = eval . GetOverallResults ( overallList . ToArray ( ) ) ;
221
- MetricWriter . PrintOverallMetrics ( Host , ch , Args . SummaryFilename , overall , Args . NumFolds ) ;
221
+ MetricWriter . PrintOverallMetrics ( Host , ch , ImplOptions . SummaryFilename , overall , ImplOptions . NumFolds ) ;
222
222
eval . PrintAdditionalMetrics ( ch , tasks . Select ( t => t . Result . Metrics ) . ToArray ( ) ) ;
223
223
Dictionary < string , IDataView > [ ] metricValues = tasks . Select ( t => t . Result . Metrics ) . ToArray ( ) ;
224
224
SendTelemetryMetric ( metricValues ) ;
225
225
226
226
// Save the per-instance results.
227
- if ( ! string . IsNullOrWhiteSpace ( Args . OutputDataFile ) )
227
+ if ( ! string . IsNullOrWhiteSpace ( ImplOptions . OutputDataFile ) )
228
228
{
229
- var perInstance = EvaluateUtils . ConcatenatePerInstanceDataViews ( Host , eval , Args . CollateMetrics ,
230
- Args . OutputExampleFoldIndex , tasks . Select ( t => t . Result . PerInstanceResults ) . ToArray ( ) , out var variableSizeVectorColumnNames ) ;
229
+ var perInstance = EvaluateUtils . ConcatenatePerInstanceDataViews ( Host , eval , ImplOptions . CollateMetrics ,
230
+ ImplOptions . OutputExampleFoldIndex , tasks . Select ( t => t . Result . PerInstanceResults ) . ToArray ( ) , out var variableSizeVectorColumnNames ) ;
231
231
if ( variableSizeVectorColumnNames . Length > 0 )
232
232
{
233
233
ch . Warning ( "Detected columns of variable length: {0}. Consider setting collateMetrics- for meaningful per-Folds results." ,
234
234
string . Join ( ", " , variableSizeVectorColumnNames ) ) ;
235
235
}
236
- if ( Args . CollateMetrics )
236
+ if ( ImplOptions . CollateMetrics )
237
237
{
238
238
ch . Assert ( perInstance . Length == 1 ) ;
239
- MetricWriter . SavePerInstance ( Host , ch , Args . OutputDataFile , perInstance [ 0 ] ) ;
239
+ MetricWriter . SavePerInstance ( Host , ch , ImplOptions . OutputDataFile , perInstance [ 0 ] ) ;
240
240
}
241
241
else
242
242
{
243
243
int i = 0 ;
244
244
foreach ( var idv in perInstance )
245
245
{
246
- MetricWriter . SavePerInstance ( Host , ch , ConstructPerFoldName ( Args . OutputDataFile , i ) , idv ) ;
246
+ MetricWriter . SavePerInstance ( Host , ch , ConstructPerFoldName ( ImplOptions . OutputDataFile , i ) , idv ) ;
247
247
i ++ ;
248
248
}
249
249
}
@@ -265,20 +265,20 @@ private RoleMappedData ApplyAllTransformsToData(IHostEnvironment env, IChannel c
265
265
/// </summary>
266
266
private RoleMappedData CreateRoleMappedData ( IHostEnvironment env , IChannel ch , IDataView data , ITrainer trainer )
267
267
{
268
- foreach ( var kvp in Args . Transforms )
268
+ foreach ( var kvp in ImplOptions . Transforms )
269
269
data = kvp . Value . CreateComponent ( env , data ) ;
270
270
271
271
var schema = data . Schema ;
272
- string label = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( Args . LabelColumn ) , Args . LabelColumn , DefaultColumnNames . Label ) ;
273
- string features = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( Args . FeatureColumn ) , Args . FeatureColumn , DefaultColumnNames . Features ) ;
274
- string weight = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( Args . WeightColumn ) , Args . WeightColumn , DefaultColumnNames . Weight ) ;
275
- string name = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( Args . NameColumn ) , Args . NameColumn , DefaultColumnNames . Name ) ;
276
- string group = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( Args . GroupColumn ) , Args . GroupColumn , DefaultColumnNames . GroupId ) ;
272
+ string label = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( ImplOptions . LabelColumn ) , ImplOptions . LabelColumn , DefaultColumnNames . Label ) ;
273
+ string features = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( ImplOptions . FeatureColumn ) , ImplOptions . FeatureColumn , DefaultColumnNames . Features ) ;
274
+ string weight = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( ImplOptions . WeightColumn ) , ImplOptions . WeightColumn , DefaultColumnNames . Weight ) ;
275
+ string name = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( ImplOptions . NameColumn ) , ImplOptions . NameColumn , DefaultColumnNames . Name ) ;
276
+ string group = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( ImplOptions . GroupColumn ) , ImplOptions . GroupColumn , DefaultColumnNames . GroupId ) ;
277
277
278
- TrainUtils . AddNormalizerIfNeeded ( env , ch , trainer , ref data , features , Args . NormalizeFeatures ) ;
278
+ TrainUtils . AddNormalizerIfNeeded ( env , ch , trainer , ref data , features , ImplOptions . NormalizeFeatures ) ;
279
279
280
280
// Training pipe and examples.
281
- var customCols = TrainUtils . CheckAndGenerateCustomColumns ( ch , Args . CustomColumns ) ;
281
+ var customCols = TrainUtils . CheckAndGenerateCustomColumns ( ch , ImplOptions . CustomColumns ) ;
282
282
283
283
return new RoleMappedData ( data , label , features , group , weight , name , customCols ) ;
284
284
}
@@ -291,11 +291,11 @@ private string GetSplitColumn(IChannel ch, IDataView input, ref IDataView output
291
291
// If no stratification column was specified, but we have a group column of type Single, Double or
292
292
// Key (contiguous) use it.
293
293
string stratificationColumn = null ;
294
- if ( ! string . IsNullOrWhiteSpace ( Args . StratificationColumn ) )
295
- stratificationColumn = Args . StratificationColumn ;
294
+ if ( ! string . IsNullOrWhiteSpace ( ImplOptions . StratificationColumn ) )
295
+ stratificationColumn = ImplOptions . StratificationColumn ;
296
296
else
297
297
{
298
- string group = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( Args . GroupColumn ) , Args . GroupColumn , DefaultColumnNames . GroupId ) ;
298
+ string group = TrainUtils . MatchNameOrDefaultOrNull ( ch , schema , nameof ( ImplOptions . GroupColumn ) , ImplOptions . GroupColumn , DefaultColumnNames . GroupId ) ;
299
299
int index ;
300
300
if ( group != null && schema . TryGetColumnIndex ( group , out index ) )
301
301
{
0 commit comments