public PostIngestPipe(IngestOptions opt, Ingester filter_previ, ConcurrentQueue <string> msgs) { inMessages = msgs; localFilter = new Filter(opt.regexFilters, msgs); localDic = new Dictionarizer(localFilter.PieceTask, localFilter.outMessageStrings); localMark = new Markovizer(opt.gramSize, localDic.PieceTask, localDic.outSentenceBank); }
static void Main(string[] args) { //step2:创建一个管道并且加载你的数据 var pipeline = new LearningPipeline(); string dataPath = "SourceData/iris-data.txt"; var loaderData = new TextLoader <IrisData>(dataPath, separator: ","); pipeline.Add(loaderData); //step3:转换数据 //因为在模型训练的时候只能处理数字,所以在Label列中将数值分配给文本 var dictionarizer = new Dictionarizer("Label"); pipeline.Add(dictionarizer); var concatenator = new ColumnConcatenator("Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth"); pipeline.Add(concatenator); //step4:添加学习者 //添加一个学习算法到管道中,这是一种分类方案(这是什么类型的Iris) pipeline.Add(new StochasticDualCoordinateAscentClassifier()); //在步骤三转换为数字之后将Label转换回原始文本 pipeline.Add(new PredictedLabelColumnOriginalValueConverter() { PredictedLabelColumn = "PredictedLabel" }); //step5:根据数据集来训练模型 var model = pipeline.Train <IrisData, IrisPrediction>(); var prediction = model.Predict(new IrisData() { SepalLength = 10.8f, SepalWidth = 5.1f, PetalLength = 2.55f, PetalWidth = 0.3f }); Console.WriteLine($"Predicted flower type is {prediction.PredictedLabels}"); Console.Read(); }