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