machinelearning-samples icon indicating copy to clipboard operation
machinelearning-samples copied to clipboard

Need example how to load using IDataView using IEnumerable

Open Vijay27anand opened this issue 7 years ago • 2 comments

I need an sample how to load IDataView from an IEnumerable, all examples are using a text csv file, i need to load the IDataView from a context object or a database table. Please help providing an sample.

Vijay27anand avatar Dec 14 '18 17:12 Vijay27anand

CollectionDataSource can take in an IEnumerable, here's an example of Collection Data Source in action.

public class ProductEntry
{
   [KeyType(Contiguous = true, Count = 262111, Min = 0)]
   public uint ProductID { get; set; }

   [KeyType(Contiguous = true, Count = 262111, Min = 0)]
   public uint ProductID_Copurchased { get; set; }
}

var dataMatrix = new List<OneClassMatrixElementZeroBasedForScore>();
dataMatrix.Add(new OneClassMatrixElementZeroBasedForScore() { ProductID = 0, 
                                                                                                           ProductID_Copurchased = 1, 
                                                                                                           Value = 1 });
var testdata = ComponentCreation.CreateDataView(ctx, dataMatrix);           

Does this help?

asthana86 avatar Dec 16 '18 22:12 asthana86

Closing the issue as sample code was provided by Ankit. 👍

CESARDELATORRE avatar Dec 19 '18 23:12 CESARDELATORRE