public Legacy.Models.TrainTestEvaluator.Output AddAsTrainTest(Var <IDataView> trainData, Var <IDataView> testData, MacroUtils.TrainerKinds trainerKind, Experiment experiment = null, bool includeTrainingMetrics = false) { experiment = experiment ?? _env.CreateExperiment(); var graphDef = ToEntryPointGraph(experiment); var subGraph = graphDef.Graph; var firstInput = new Var <IDataView> { VarName = graphDef.GetSubgraphFirstNodeDataVarName(_env) }; var finalOutput = graphDef.ModelOutput; // TrainTestMacro var trainTestInput = new Legacy.Models.TrainTestEvaluator { Nodes = subGraph, TransformModel = null, Inputs = { Data = firstInput }, Outputs = { PredictorModel = finalOutput }, TrainingData = trainData, TestingData = testData, Kind = MacroUtils.TrainerKindApiValue <Legacy.Models.MacroUtilsTrainerKinds>(trainerKind), PipelineId = UniqueId.ToString("N"), IncludeTrainingMetrics = includeTrainingMetrics }; var trainTestOutput = experiment.Add(trainTestInput); return(trainTestOutput); }
// REVIEW: We may want to allow for sweeping with CV in the future, so we will need to add new methods like this, or refactor these in that case. public Experiment CreateTrainTestExperiment(IDataView trainData, IDataView testData, MacroUtils.TrainerKinds trainerKind, bool includeTrainingMetrics, out Legacy.Models.TrainTestEvaluator.Output resultsOutput) { var graphDef = ToEntryPointGraph(); var subGraph = graphDef.Graph; var nodes = graphDef.Graph.GetNodes(); _env.CheckNonEmpty(nodes, nameof(nodes), "Empty Subgraph on TrainTest Experiment."); Var <IDataView> firstInput = new Var <IDataView> { VarName = graphDef.GetSubgraphFirstNodeDataVarName(_env) }; var finalOutput = graphDef.ModelOutput; // TrainTestMacro var trainTestInput = new Legacy.Models.TrainTestEvaluator { TransformModel = null, Nodes = subGraph, Inputs = { Data = firstInput }, Outputs = { PredictorModel = finalOutput }, PipelineId = UniqueId.ToString("N"), Kind = MacroUtils.TrainerKindApiValue <Legacy.Models.MacroUtilsTrainerKinds>(trainerKind), IncludeTrainingMetrics = includeTrainingMetrics }; var experiment = _env.CreateExperiment(); var trainTestOutput = experiment.Add(trainTestInput); experiment.Compile(); experiment.SetInput(trainTestInput.TrainingData, trainData); experiment.SetInput(trainTestInput.TestingData, testData); resultsOutput = trainTestOutput; return(experiment); }