2 writes to ImplOptions
Microsoft.ML.Data (2)
Commands\DataCommand.cs (2)
92
ImplOptions
= options;
103
ImplOptions
= impl.ImplOptions;
206 references to ImplOptions
Microsoft.ML.Data (206)
Commands\CrossValidationCommand.cs (45)
109
Host.CheckUserArg(
ImplOptions
.NumFolds >= 2, nameof(
ImplOptions
.NumFolds), "Number of folds must be greater than or equal to 2.");
111
Utils.CheckOptionalUserDirectory(
ImplOptions
.SummaryFilename, nameof(
ImplOptions
.SummaryFilename));
112
Utils.CheckOptionalUserDirectory(
ImplOptions
.OutputDataFile, nameof(
ImplOptions
.OutputDataFile));
126
var settings = CmdParser.GetSettings(Host,
ImplOptions
, new Arguments());
141
SendTelemetryComponent(pipe,
ImplOptions
.Trainer);
150
if (
ImplOptions
.ContinueTrain && !TrainUtils.TryLoadPredictor(ch, Host,
ImplOptions
.InputModelFile, out inputPredictor))
157
var preXf =
ImplOptions
.PreTransforms;
158
if (!string.IsNullOrEmpty(
ImplOptions
.OutputDataFile))
160
string name = TrainUtils.MatchNameOrDefaultOrNull(ch, loader.Schema, nameof(
ImplOptions
.NameColumn),
ImplOptions
.NameColumn, DefaultColumnNames.Name);
184
var scorer =
ImplOptions
.Scorer;
185
var evaluator =
ImplOptions
.Evaluator;
188
if (
ImplOptions
.ValidationFile != null)
195
return impl.CreateRawLoader(dataFile:
ImplOptions
.ValidationFile);
200
ImplOptions
, CreateRoleMappedData, ApplyAllTransformsToData, scorer, evaluator,
201
validDataCreator, ApplyAllTransformsToData, inputPredictor, cmd, loader, !string.IsNullOrEmpty(
ImplOptions
.OutputDataFile));
220
MetricWriter.PrintOverallMetrics(Host, ch,
ImplOptions
.SummaryFilename, overall,
ImplOptions
.NumFolds);
226
if (!string.IsNullOrWhiteSpace(
ImplOptions
.OutputDataFile))
228
var perInstance = EvaluateUtils.ConcatenatePerInstanceDataViews(Host, eval,
ImplOptions
.CollateMetrics,
229
ImplOptions
.OutputExampleFoldIndex, tasks.Select(t => t.Result.PerInstanceResults).ToArray(), out var variableSizeVectorColumnNames);
235
if (
ImplOptions
.CollateMetrics)
238
MetricWriter.SavePerInstance(Host, ch,
ImplOptions
.OutputDataFile, perInstance[0]);
245
MetricWriter.SavePerInstance(Host, ch, ConstructPerFoldName(
ImplOptions
.OutputDataFile, i), idv);
267
foreach (var kvp in
ImplOptions
.Transforms)
271
string label = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.LabelColumn),
ImplOptions
.LabelColumn, DefaultColumnNames.Label);
272
string features = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.FeatureColumn),
ImplOptions
.FeatureColumn, DefaultColumnNames.Features);
273
string weight = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.WeightColumn),
ImplOptions
.WeightColumn, DefaultColumnNames.Weight);
274
string name = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.NameColumn),
ImplOptions
.NameColumn, DefaultColumnNames.Name);
275
string group = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.GroupColumn),
ImplOptions
.GroupColumn, DefaultColumnNames.GroupId);
277
TrainUtils.AddNormalizerIfNeeded(env, ch, trainer, ref data, features,
ImplOptions
.NormalizeFeatures);
280
var customCols = TrainUtils.CheckAndGenerateCustomColumns(ch,
ImplOptions
.CustomColumns);
293
if (!string.IsNullOrWhiteSpace(
ImplOptions
.StratificationColumn))
294
stratificationColumn =
ImplOptions
.StratificationColumn;
297
string group = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.GroupColumn),
ImplOptions
.GroupColumn, DefaultColumnNames.GroupId);
Commands\DataCommand.cs (28)
101
impl.Host.AssertValue(impl.
ImplOptions
);
103
ImplOptions = impl.
ImplOptions
;
132
if (
ImplOptions
.Transforms != null)
134
foreach (var transform in
ImplOptions
.Transforms)
218
if (!string.IsNullOrWhiteSpace(
ImplOptions
.OutputModelFile))
220
using (var file = Host.CreateOutputFile(
ImplOptions
.OutputModelFile))
255
using (var file = Host.OpenInputFile(
ImplOptions
.InputModelFile))
271
var loaderFactory =
ImplOptions
.Loader;
276
pipe = loaderFactory.CreateComponent(Host, new MultiFileSource(
ImplOptions
.DataFile));
277
if (
ImplOptions
.LoadTransforms == true)
279
Host.CheckUserArg(!string.IsNullOrWhiteSpace(
ImplOptions
.InputModelFile), nameof(
ImplOptions
.InputModelFile));
285
var loadTrans =
ImplOptions
.LoadTransforms ?? true;
286
pipe = LoadLoader(rep,
ImplOptions
.DataFile, loadTrans);
291
if (Utils.Size(
ImplOptions
.Transforms) > 0)
292
pipe = LegacyCompositeDataLoader.Create(Host, pipe,
ImplOptions
.Transforms);
328
return LegacyCompositeDataLoader.Create(Host, loader,
ImplOptions
.Transforms);
336
dataFile =
ImplOptions
.DataFile;
339
if (!string.IsNullOrWhiteSpace(
ImplOptions
.InputModelFile) &&
ImplOptions
.Loader == null)
342
using (var file = Host.OpenInputFile(
ImplOptions
.InputModelFile))
345
loader = LoadLoader(rep, dataFile,
ImplOptions
.LoadTransforms ?? true);
351
var loaderFactory =
ImplOptions
.Loader;
372
if (
ImplOptions
.LoadTransforms == true)
374
Host.CheckUserArg(!string.IsNullOrWhiteSpace(
ImplOptions
.InputModelFile), nameof(
ImplOptions
.InputModelFile));
383
Host.Assert(!string.IsNullOrWhiteSpace(
ImplOptions
.InputModelFile));
385
using (var file = Host.OpenInputFile(
ImplOptions
.InputModelFile))
Commands\EvaluateCommand.cs (13)
208
Utils.CheckOptionalUserDirectory(
ImplOptions
.SummaryFilename, nameof(
ImplOptions
.SummaryFilename));
209
Utils.CheckOptionalUserDirectory(
ImplOptions
.OutputDataFile, nameof(
ImplOptions
.OutputDataFile));
231
ImplOptions
.LabelColumn, DefaultColumnNames.Label);
233
ImplOptions
.GroupColumn, DefaultColumnNames.GroupId);
235
ImplOptions
.WeightColumn, DefaultColumnNames.Weight);
237
ImplOptions
.NameColumn, DefaultColumnNames.Name);
238
var customCols = TrainUtils.CheckAndGenerateCustomColumns(ch,
ImplOptions
.CustomColumns);
241
var evaluator =
ImplOptions
.Evaluator?.CreateComponent(Host) ??
251
MetricWriter.PrintOverallMetrics(Host, ch,
ImplOptions
.SummaryFilename, overall, 1);
253
if (!string.IsNullOrWhiteSpace(
ImplOptions
.OutputDataFile))
258
MetricWriter.SavePerInstance(Host, ch,
ImplOptions
.OutputDataFile, idv);
Commands\SaveDataCommand.cs (13)
62
if (
ImplOptions
.Saver == null)
64
var ext = Path.GetExtension(
ImplOptions
.OutputDataFile);
82
saver =
ImplOptions
.Saver.CreateComponent(Host);
86
using (var file = Host.CreateOutputFile(
ImplOptions
.OutputDataFile))
87
DataSaverUtils.SaveDataView(ch, saver, loader, file,
ImplOptions
.KeepHidden);
132
if (!string.IsNullOrWhiteSpace(
ImplOptions
.Columns))
134
var keepColumns =
ImplOptions
.Columns
141
if (
ImplOptions
.Saver != null)
142
saver =
ImplOptions
.Saver.CreateComponent(Host);
144
saver = new TextSaver(Host, new TextSaver.Arguments() { Dense =
ImplOptions
.Dense });
148
if (!
ImplOptions
.KeepHidden && data.Schema[i].IsHidden)
159
if (
ImplOptions
.Rows > 0)
161
var args = new SkipTakeFilter.TakeOptions() { Count =
ImplOptions
.Rows };
Commands\ScoreCommand.cs (33)
85
Host.CheckUserArg(!string.IsNullOrWhiteSpace(
ImplOptions
.InputModelFile), nameof(
ImplOptions
.InputModelFile), "The input model file is required.");
86
Host.CheckUserArg(!string.IsNullOrWhiteSpace(
ImplOptions
.OutputDataFile), nameof(
ImplOptions
.OutputDataFile), "The output data file is required.");
87
Utils.CheckOptionalUserDirectory(
ImplOptions
.OutputDataFile, nameof(
ImplOptions
.OutputDataFile));
110
var scorer =
ImplOptions
.Scorer;
117
nameof(
ImplOptions
.FeatureColumn),
ImplOptions
.FeatureColumn, DefaultColumnNames.Features);
119
nameof(
ImplOptions
.GroupColumn),
ImplOptions
.GroupColumn, DefaultColumnNames.GroupId);
120
var customCols = TrainUtils.CheckAndGenerateCustomColumns(ch,
ImplOptions
.CustomColumns);
130
loader = LegacyCompositeDataLoader.Create(Host, loader,
ImplOptions
.PostTransform);
132
if (!string.IsNullOrWhiteSpace(
ImplOptions
.OutputModelFile))
135
SaveLoader(loader,
ImplOptions
.OutputModelFile);
140
if (
ImplOptions
.Saver == null)
142
var ext = Path.GetExtension(
ImplOptions
.OutputDataFile);
155
writer =
ImplOptions
.Saver.CreateComponent(Host);
161
ImplOptions
.OutputAllColumns == true
162
|| (
ImplOptions
.OutputAllColumns == null && Utils.Size(
ImplOptions
.OutputColumns) == 0 && outputIsBinary);
165
ImplOptions
.OutputAllColumns == true || Utils.Size(
ImplOptions
.OutputColumns) == 0;
167
if (
ImplOptions
.OutputAllColumns == true && Utils.Size(
ImplOptions
.OutputColumns) != 0)
168
ch.Warning(nameof(
ImplOptions
.OutputAllColumns) + "=+ always writes all columns irrespective of " + nameof(
ImplOptions
.OutputColumns) + " specified.");
170
if (!outputAllColumns && Utils.Size(
ImplOptions
.OutputColumns) != 0)
172
foreach (var outCol in
ImplOptions
.OutputColumns)
186
if (!
ImplOptions
.KeepHidden && loader.Schema[i].IsHidden)
203
using (var file = Host.CreateOutputFile(
ImplOptions
.OutputDataFile))
232
if (
ImplOptions
.OutputColumns != null && Array.FindIndex(
ImplOptions
.OutputColumns, schema[i].Name.Equals) >= 0)
Commands\ShowSchemaCommand.cs (1)
72
RunOnData(schemaWriter,
ImplOptions
, loader);
Commands\TestCommand.cs (25)
66
Host.CheckUserArg(!string.IsNullOrEmpty(
ImplOptions
.InputModelFile), nameof(
ImplOptions
.InputModelFile), "The input model file is required.");
67
Utils.CheckOptionalUserDirectory(
ImplOptions
.SummaryFilename, nameof(
ImplOptions
.SummaryFilename));
68
Utils.CheckOptionalUserDirectory(
ImplOptions
.OutputDataFile, nameof(
ImplOptions
.OutputDataFile));
77
var settings = CmdParser.GetSettings(Host,
ImplOptions
, new Arguments());
101
string label = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.LabelColumn),
102
ImplOptions
.LabelColumn, DefaultColumnNames.Label);
103
string features = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.FeatureColumn),
104
ImplOptions
.FeatureColumn, DefaultColumnNames.Features);
105
string group = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.GroupColumn),
106
ImplOptions
.GroupColumn, DefaultColumnNames.GroupId);
107
string weight = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.WeightColumn),
108
ImplOptions
.WeightColumn, DefaultColumnNames.Weight);
109
string name = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(
ImplOptions
.NameColumn),
110
ImplOptions
.NameColumn, DefaultColumnNames.Name);
111
var customCols = TrainUtils.CheckAndGenerateCustomColumns(ch,
ImplOptions
.CustomColumns);
115
ch.Assert(
ImplOptions
.Scorer == null ||
ImplOptions
.Scorer is ICommandLineComponentFactory, "TestCommand should only be used from the command line.");
116
IDataScorerTransform scorePipe = ScoreUtils.GetScorer(
ImplOptions
.Scorer, predictor, loader, features, group, customCols, Host, trainSchema);
119
var evaluator =
ImplOptions
.Evaluator?.CreateComponent(Host) ??
128
MetricWriter.PrintOverallMetrics(Host, ch,
ImplOptions
.SummaryFilename, overall, 1);
132
if (!string.IsNullOrWhiteSpace(
ImplOptions
.OutputDataFile))
137
MetricWriter.SavePerInstance(Host, ch,
ImplOptions
.OutputDataFile, idv);
Commands\TrainCommand.cs (13)
117
var settings = CmdParser.GetSettings(Host,
ImplOptions
, new Arguments());
145
if (
ImplOptions
.ContinueTrain && !TrainUtils.TryLoadPredictor(ch, Host,
ImplOptions
.InputModelFile, out inputPredictor))
158
TrainUtils.AddNormalizerIfNeeded(Host, ch, trainer, ref view, feature,
ImplOptions
.NormalizeFeatures);
162
var customCols = TrainUtils.CheckAndGenerateCustomColumns(ch,
ImplOptions
.CustomColumns);
167
if (!string.IsNullOrWhiteSpace(
ImplOptions
.ValidationFile))
176
IDataView validPipe = CreateRawLoader(dataFile:
ImplOptions
.ValidationFile);
187
if (!string.IsNullOrWhiteSpace(
ImplOptions
.TestFile))
194
IDataView testPipeUsedInTrainer = CreateRawLoader(dataFile:
ImplOptions
.TestFile);
201
ImplOptions
.Calibrator,
ImplOptions
.MaxCalibrationExamples,
ImplOptions
.CacheData, inputPredictor, testDataUsedInTrainer);
203
using (var file = Host.CreateOutputFile(
ImplOptions
.OutputModelFile))
Commands\TrainTestCommand.cs (29)
100
var settings = CmdParser.GetSettings(Host,
ImplOptions
, new Arguments());
115
SendTelemetryComponent(pipe,
ImplOptions
.Trainer);
125
ITrainer trainer =
ImplOptions
.Trainer.CreateComponent(Host);
128
if (
ImplOptions
.ContinueTrain && !TrainUtils.TryLoadPredictor(ch, Host,
ImplOptions
.InputModelFile, out inputPredictor))
136
ImplOptions
.LabelColumn, DefaultColumnNames.Label);
138
ImplOptions
.FeatureColumn, DefaultColumnNames.Features);
140
ImplOptions
.GroupColumn, DefaultColumnNames.GroupId);
142
ImplOptions
.WeightColumn, DefaultColumnNames.Weight);
144
ImplOptions
.NameColumn, DefaultColumnNames.Name);
146
TrainUtils.AddNormalizerIfNeeded(Host, ch, trainer, ref trainPipe, features,
ImplOptions
.NormalizeFeatures);
149
var customCols = TrainUtils.CheckAndGenerateCustomColumns(ch,
ImplOptions
.CustomColumns);
153
if (!string.IsNullOrWhiteSpace(
ImplOptions
.ValidationFile))
162
IDataView validPipe = CreateRawLoader(dataFile:
ImplOptions
.ValidationFile);
173
if (!string.IsNullOrWhiteSpace(
ImplOptions
.TestFile))
180
IDataView testPipeUsedInTrainer = CreateRawLoader(dataFile:
ImplOptions
.TestFile);
187
ImplOptions
.Calibrator,
ImplOptions
.MaxCalibrationExamples,
ImplOptions
.CacheData, inputPredictor, testDataUsedInTrainer);
190
bool hasOutfile = !string.IsNullOrEmpty(
ImplOptions
.OutputModelFile);
193
using (var file = new SimpleFileHandle(ch, hasOutfile ?
ImplOptions
.OutputModelFile : tempFilePath, true, !hasOutfile))
199
testPipe = LoadLoader(rep,
ImplOptions
.TestFile, true);
204
ch.Assert(
ImplOptions
.Scorer == null ||
ImplOptions
.Scorer is ICommandLineComponentFactory, "TrainTestCommand should only be used from the command line.");
205
IDataScorerTransform scorePipe = ScoreUtils.GetScorer(
ImplOptions
.Scorer, predictor, testPipe, features, group, customCols, Host, data.Schema);
208
var evaluator =
ImplOptions
.Evaluator?.CreateComponent(Host) ??
218
MetricWriter.PrintOverallMetrics(Host, ch,
ImplOptions
.SummaryFilename, overall, 1);
222
if (!string.IsNullOrWhiteSpace(
ImplOptions
.OutputDataFile))
227
MetricWriter.SavePerInstance(Host, ch,
ImplOptions
.OutputDataFile, idv);
Model\Pfa\SavePfaCommand.cs (6)
127
if (string.IsNullOrEmpty(
ImplOptions
.InputModelFile))
132
Host.CheckUserArg(
ImplOptions
.LoadPredictor != true, nameof(
ImplOptions
.LoadPredictor),
133
"Cannot be set to true unless " + nameof(
ImplOptions
.InputModelFile) + " is also specified.");
212
if (!string.IsNullOrWhiteSpace(
ImplOptions
.OutputModelFile))
216
SaveLoader(loader,
ImplOptions
.OutputModelFile);