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

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

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