public LearningPipelineDebugProxy(LearningPipeline pipeline) { if (pipeline == null) { throw new ArgumentNullException(nameof(pipeline)); } _pipeline = new LearningPipeline(); // use a ConcurrencyFactor of 1 so other threads don't need to run in the debugger _environment = new MLContext(conc: 1); foreach (ILearningPipelineItem item in pipeline) { _pipeline.Add(item); if (item is ILearningPipelineLoader loaderItem) { // add a take filter to any loaders, so it returns in a reasonable // amount of time _pipeline.Add(new RowTakeFilter() { Count = MaxLoaderRows }); } } }
public void TestEP_Q_KMeansEntryPointAPI_04() { var iris = FileHelper.GetTestFile("iris.txt"); var pipeline = new Legacy.LearningPipeline(); pipeline.Add(new Legacy.Data.TextLoader(iris).CreateFrom <IrisObservation>(separator: '\t', useHeader: true)); pipeline.Add(new Legacy.Transforms.ColumnConcatenator("Features", "Sepal_length", "Sepal_width")); pipeline.Add(new Legacy.Trainers.KMeansPlusPlusClusterer()); var model = pipeline.Train <IrisObservation, IrisPrediction>(); var obs = new IrisObservation() { Sepal_length = 3.3f, Sepal_width = 1.6f, Petal_length = 0.2f, Petal_width = 5.1f, }; var predictions = model.Predict(obs); Assert.IsTrue(predictions.PredictedLabel != 0); }