Machinelearning: How to load data from variable?

Created on 2 Jul 2018  路  2Comments  路  Source: dotnet/machinelearning

Hi,
I want to load data from memory, so I can connect it with sql server, webservice etc.

pipeline.Add(new TextLoader(dataPath).CreateFrom<IrisData>(separator: ','));
but this is only method that I can find! It only works with file on the disk!

I want to add data from variable like:
string x = "116.76000,0.00000,116.76000,0.00000,116.76000,UP"

I hope it is possible right now?

Thanks advance!

Most helpful comment

If you're getting data from SQL or a web service and they are of IList, then the CollectionDataSource should be what you need.

There's an example in the 0.2 release blog post:

var pipeline = new LearningPipeline();
var data = new List() {
           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); 

Hope that helps!

All 2 comments

If you're getting data from SQL or a web service and they are of IList, then the CollectionDataSource should be what you need.

There's an example in the 0.2 release blog post:

var pipeline = new LearningPipeline();
var data = new List() {
           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); 

Hope that helps!

Thank you very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pgovind picture pgovind  路  3Comments

daholste picture daholste  路  4Comments

JakeRadMSFT picture JakeRadMSFT  路  3Comments

ddobric picture ddobric  路  4Comments

dev8546 picture dev8546  路  3Comments