2 writes to Host
Microsoft.ML.Data (2)
Commands\DataCommand.cs (2)
91
Host
= env.Register(name);
104
Host
= impl.Host.Register(name);
149 references to Host
Microsoft.ML.Data (149)
Commands\CrossValidationCommand.cs (18)
109
Host
.CheckUserArg(ImplOptions.NumFolds >= 2, nameof(ImplOptions.NumFolds), "Number of folds must be greater than or equal to 2.");
110
TrainUtils.CheckTrainer(
Host
, args.Trainer, args.DataFile);
123
using (var ch =
Host
.Start(LoadName))
126
var settings = CmdParser.GetSettings(
Host
, ImplOptions, new Arguments());
130
SendTelemetry(
Host
);
132
using (new TimerScope(
Host
, ch))
147
Host
.AssertValue(ch);
150
if (ImplOptions.ContinueTrain && !TrainUtils.TryLoadPredictor(ch,
Host
, ImplOptions.InputModelFile, out inputPredictor))
178
loader = LegacyCompositeDataLoader.Create(
Host
, loader, preXf);
199
FoldHelper fold = new FoldHelper(
Host
, RegistrationName, pipe, stratificationColumn,
204
var eval = evaluator?.CreateComponent(
Host
) ??
205
EvaluateUtils.GetEvaluator(
Host
, tasks[0].Result.ScoreSchema);
220
MetricWriter.PrintOverallMetrics(
Host
, ch, ImplOptions.SummaryFilename, overall, ImplOptions.NumFolds);
228
var perInstance = EvaluateUtils.ConcatenatePerInstanceDataViews(
Host
, eval, ImplOptions.CollateMetrics,
238
MetricWriter.SavePerInstance(
Host
, ch, ImplOptions.OutputDataFile, perInstance[0]);
245
MetricWriter.SavePerInstance(
Host
, ch, ConstructPerFoldName(ImplOptions.OutputDataFile, i), idv);
308
var splitColumn = DataOperationsCatalog.CreateSplitColumn(
Host
, ref output, stratificationColumn);
314
Host
.AssertNonEmpty(metrics);
Commands\DataCommand.cs (38)
72
Host
.CheckValue(ch, nameof(ch));
73
ch.Check(
Host
!= null, nameof(InitServer) + " called prematurely");
74
return _serverFactory?.CreateComponent(
Host
, ch);
100
Contracts.AssertValue(impl.
Host
);
101
impl.
Host
.AssertValue(impl.ImplOptions);
102
impl.
Host
.AssertValue(name);
104
Host = impl.
Host
.Register(name);
119
Host
.AssertValue(pipe);
120
Host
.AssertValueOrNull(factory);
201
SendTelemetryMetricCore(
Host
, newAverageMetric);
206
return ModelFileUtils.LoadLoader(
Host
, rep, new MultiFileSource(path), loadTransforms);
211
using (var file =
Host
.CreateOutputFile(path))
212
LoaderUtils.SaveLoader(loader, file,
Host
);
220
using (var file =
Host
.CreateOutputFile(ImplOptions.OutputModelFile))
221
LoaderUtils.SaveLoader(loader, file,
Host
);
255
using (var file =
Host
.OpenInputFile(ImplOptions.InputModelFile))
257
using (var rep = RepositoryReader.Open(strm,
Host
))
265
predictor = ModelFileUtils.LoadPredictorOrNull(
Host
, rep);
267
Host
.Check(predictor != null, "Could not load predictor from model file");
276
pipe = loaderFactory.CreateComponent(
Host
, new MultiFileSource(ImplOptions.DataFile));
279
Host
.CheckUserArg(!string.IsNullOrWhiteSpace(ImplOptions.InputModelFile), nameof(ImplOptions.InputModelFile));
292
pipe = LegacyCompositeDataLoader.Create(
Host
, pipe, ImplOptions.Transforms);
299
var trainRoleMappings = ModelFileUtils.LoadRoleMappingsOrNull(
Host
, rep);
307
trainPipe = ModelFileUtils.LoadLoader(
Host
, rep, new MultiFileSource(null), loadTransforms: true);
328
return LegacyCompositeDataLoader.Create(
Host
, loader, ImplOptions.Transforms);
342
using (var file =
Host
.OpenInputFile(ImplOptions.InputModelFile))
344
using (var rep = RepositoryReader.Open(strm,
Host
))
361
return isText ? TextLoader.Create(
Host
, new TextLoader.Options(), fileSource) :
362
isBinary ? new BinaryLoader(
Host
, new BinaryLoader.Arguments(), fileSource) :
363
isTranspose ? new TransposeLoader(
Host
, new TransposeLoader.Arguments(), fileSource) :
364
defaultLoaderFactory != null ? defaultLoaderFactory(
Host
, fileSource) :
365
TextLoader.Create(
Host
, new TextLoader.Options(), fileSource);
369
loader = loaderFactory.CreateComponent(
Host
, fileSource);
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))
387
using (var rep = RepositoryReader.Open(strm,
Host
))
390
return LegacyCompositeDataLoader.Create(
Host
, ctx, srcData, x => true);
Commands\EvaluateCommand.cs (6)
214
using (var ch =
Host
.Start("Evaluate"))
222
Host
.AssertValue(ch);
241
var evaluator = ImplOptions.Evaluator?.CreateComponent(
Host
) ??
242
EvaluateUtils.GetEvaluator(
Host
, view.Schema);
251
MetricWriter.PrintOverallMetrics(
Host
, ch, ImplOptions.SummaryFilename, overall, 1);
258
MetricWriter.SavePerInstance(
Host
, ch, ImplOptions.OutputDataFile, idv);
Commands\SaveDataCommand.cs (14)
52
using (var ch =
Host
.Start(command))
60
Host
.AssertValue(ch, "ch");
69
saver = new BinarySaver(
Host
, new BinarySaver.Arguments());
73
saver = new TransposeSaver(
Host
, new TransposeSaver.Arguments());
77
saver = new TextSaver(
Host
, new TextSaver.Arguments());
82
saver = ImplOptions.Saver.CreateComponent(
Host
);
86
using (var file =
Host
.CreateOutputFile(ImplOptions.OutputDataFile))
121
using (var ch =
Host
.Start(command))
129
Host
.AssertValue(ch);
137
data = ColumnSelectingTransformer.CreateKeep(
Host
, data, keepColumns);
142
saver = ImplOptions.Saver.CreateComponent(
Host
);
144
saver = new TextSaver(
Host
, new TextSaver.Arguments() { Dense = ImplOptions.Dense });
156
Host
.NotSensitive().Check(cols.Count > 0, "No valid columns to save");
162
data = SkipTakeFilter.Create(
Host
, args, data);
Commands\ScoreCommand.cs (13)
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.");
92
using (var ch =
Host
.Start("Score"))
100
Host
.AssertValue(ch);
112
var bindable = ScoreUtils.GetSchemaBindableMapper(
Host
, predictor, scorerFactorySettings: scorer as ICommandLineComponentFactory);
122
var mapper = bindable.Bind(
Host
, schema);
125
scorer = ScoreUtils.GetScorerComponent(
Host
, mapper);
127
loader = LegacyCompositeDataLoader.ApplyTransform(
Host
, loader, "Scorer", scorer.ToString(),
130
loader = LegacyCompositeDataLoader.Create(
Host
, loader, ImplOptions.PostTransform);
146
writer = new TextSaver(
Host
, new TextSaver.Arguments());
150
writer = new BinarySaver(
Host
, new BinarySaver.Arguments());
155
writer = ImplOptions.Saver.CreateComponent(
Host
);
203
using (var file =
Host
.CreateOutputFile(ImplOptions.OutputDataFile))
Commands\ShowSchemaCommand.cs (1)
61
using (var ch =
Host
.Start(LoadName))
Commands\TestCommand.cs (10)
66
Host
.CheckUserArg(!string.IsNullOrEmpty(ImplOptions.InputModelFile), nameof(ImplOptions.InputModelFile), "The input model file is required.");
74
using (var ch =
Host
.Start(command))
77
var settings = CmdParser.GetSettings(
Host
, ImplOptions, new Arguments());
80
SendTelemetry(
Host
);
81
using (new TimerScope(
Host
, ch))
116
IDataScorerTransform scorePipe = ScoreUtils.GetScorer(ImplOptions.Scorer, predictor, loader, features, group, customCols,
Host
, trainSchema);
119
var evaluator = ImplOptions.Evaluator?.CreateComponent(
Host
) ??
120
EvaluateUtils.GetEvaluator(
Host
, scorePipe.Schema);
128
MetricWriter.PrintOverallMetrics(
Host
, ch, ImplOptions.SummaryFilename, overall, 1);
137
MetricWriter.SavePerInstance(
Host
, ch, ImplOptions.OutputDataFile, idv);
Commands\TrainCommand.cs (16)
100
Host
.CheckNonWhiteSpace(args.OutputModelFile, nameof(args.OutputModelFile));
101
TrainUtils.CheckTrainer(
Host
, args.Trainer, args.DataFile);
114
using (var ch =
Host
.Start(command))
117
var settings = CmdParser.GetSettings(
Host
, ImplOptions, new Arguments());
121
SendTelemetry(
Host
);
123
using (new TimerScope(
Host
, ch))
138
Host
.AssertValue(ch);
139
Host
.AssertNonEmpty(cmd);
142
ITrainer trainer = _trainer.CreateComponent(
Host
);
145
if (ImplOptions.ContinueTrain && !TrainUtils.TryLoadPredictor(ch,
Host
, ImplOptions.InputModelFile, out inputPredictor))
158
TrainUtils.AddNormalizerIfNeeded(
Host
, ch, trainer, ref view, feature, ImplOptions.NormalizeFeatures);
177
validPipe = ApplyTransformUtils.ApplyAllTransformsToData(
Host
, view, validPipe);
195
testPipeUsedInTrainer = ApplyTransformUtils.ApplyAllTransformsToData(
Host
, view, testPipeUsedInTrainer);
200
var predictor = TrainUtils.Train(
Host
, ch, data, trainer, validData,
203
using (var file =
Host
.CreateOutputFile(ImplOptions.OutputModelFile))
204
TrainUtils.SaveModel(
Host
, ch, file, predictor, data, cmd);
Commands\TrainTestCommand.cs (21)
90
TrainUtils.CheckTrainer(
Host
, args.Trainer, args.DataFile);
92
throw
Host
.ExceptUserArg(nameof(args.TestFile), "Test file must be defined.");
97
using (var ch =
Host
.Start(LoadName))
100
var settings = CmdParser.GetSettings(
Host
, ImplOptions, new Arguments());
104
SendTelemetry(
Host
);
106
using (new TimerScope(
Host
, ch))
121
Host
.AssertValue(ch);
122
Host
.AssertNonEmpty(cmd);
125
ITrainer trainer = ImplOptions.Trainer.CreateComponent(
Host
);
128
if (ImplOptions.ContinueTrain && !TrainUtils.TryLoadPredictor(ch,
Host
, ImplOptions.InputModelFile, out inputPredictor))
146
TrainUtils.AddNormalizerIfNeeded(
Host
, ch, trainer, ref trainPipe, features, ImplOptions.NormalizeFeatures);
163
validPipe = ApplyTransformUtils.ApplyAllTransformsToData(
Host
, trainPipe, validPipe);
181
testPipeUsedInTrainer = ApplyTransformUtils.ApplyAllTransformsToData(
Host
, trainPipe, testPipeUsedInTrainer);
186
var predictor = TrainUtils.Train(
Host
, ch, data, trainer, validData,
191
var tempFilePath = hasOutfile ? null : Path.Combine(((IHostEnvironmentInternal)
Host
).TempFilePath, Path.GetRandomFileName());
195
TrainUtils.SaveModel(
Host
, ch, file, predictor, data, cmd);
205
IDataScorerTransform scorePipe = ScoreUtils.GetScorer(ImplOptions.Scorer, predictor, testPipe, features, group, customCols,
Host
, data.Schema);
208
var evaluator = ImplOptions.Evaluator?.CreateComponent(
Host
) ??
209
EvaluateUtils.GetEvaluator(
Host
, scorePipe.Schema);
218
MetricWriter.PrintOverallMetrics(
Host
, ch, ImplOptions.SummaryFilename, overall, 1);
227
MetricWriter.SavePerInstance(
Host
, ch, ImplOptions.OutputDataFile, idv);
Model\Pfa\SavePfaCommand.cs (12)
68
Host
.CheckValue(args, nameof(args));
82
Host
.CheckUserArg(Enum.IsDefined(typeof(Formatting), args.Formatting), nameof(args.Formatting), "Undefined value");
95
using (var ch =
Host
.Start("Run"))
103
Host
.AssertValue(end);
118
Host
.AssertValue(source);
132
Host
.CheckUserArg(ImplOptions.LoadPredictor != true, nameof(ImplOptions.LoadPredictor),
143
Host
.Assert(transforms.Count == 0 || transforms.Last.Value == end);
159
var scorePipe = ScoreUtils.GetScorer(rawPred, data,
Host
, trainSchema);
163
Host
.Assert(scorePipe.Source == end);
180
var ctx = new BoundPfaContext(
Host
, source.Schema, _inputsToDrop, allowSet: _allowSet);
183
Host
.Assert(trans.CanSavePfa);
206
using (var file =
Host
.CreateOutputFile(_outputModelPath))