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