ML.Net 数据加载器(内存)[duplicate]

我找到的ML.Net示例都使用TextLoader通过csv或类似方式加载数据。

如何在不使用TextLoader的情况下将数据加载到训练器中,

我正在将大量数据流式传输到一个List中

var pipeline = new LearningPipeline{    new Microsoft.ML.Data.TextLoader(_datapath).CreateFrom<Match>(useHeader: true, separator: ','),    …

是否有接受T[]的实现?持续将csv文件写入磁盘似乎是很多不必要的IO,从持续的角度来看,特别是如果训练函数锁定了文件。意味着每个活跃的训练实例需要多个文件。


回答:

使用现有的LearningPipeline API,可以使用CollectionDataSource来训练已经在内存中的数据:

var pipeline = new LearningPipeline();var data = new List<IrisData>() {    new IrisData { SepalLength = 1f, SepalWidth = 1f, PetalLength=0.3f, PetalWidth=5.1f, Label=1},    new IrisData { SepalLength = 1f, SepalWidth = 1f, PetalLength=0.3f, PetalWidth=5.1f, Label=1},    new IrisData { SepalLength = 1.2f, SepalWidth = 0.5f, PetalLength=0.3f, PetalWidth=5.1f, Label=0}};var collection = CollectionDataSource.Create(data);pipeline.Add(collection);pipeline.Add(new ColumnConcatenator(outputColumn: "Features",    "SepalLength", "SepalWidth", "PetalLength", "PetalWidth"));pipeline.Add(new StochasticDualCoordinateAscentClassifier());var model = pipeline.Train<IrisData, IrisPrediction>();

示例来自这里

随着即将推出的新的ML.NET API,这将发生变化,并将提供新的示例来展示如何做到这一点。

注:我是ML.NET团队的一员。

Related Posts

为什么我们在K-means聚类方法中使用kmeans.fit函数?

我在一个视频中使用K-means聚类技术,但我不明白为…

如何获取Keras中ImageDataGenerator的.flow_from_directory函数扫描的类名?

我想制作一个用户友好的GUI图像分类器,用户只需指向数…

如何查看每个词的tf-idf得分

我试图了解文档中每个词的tf-idf得分。然而,它只返…

如何修复 ‘ValueError: Found input variables with inconsistent numbers of samples: [32979, 21602]’?

我在制作一个用于情感分析的逻辑回归模型时遇到了这个问题…

如何向神经网络输入两个不同大小的输入?

我想向神经网络输入两个数据集。第一个数据集(元素)具有…

逻辑回归与机器学习有何关联

我们正在开会讨论聘请一位我们信任的顾问来做机器学习。一…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注