dotnet / dotnet/machinelearning
Infer T in CreateEnumerable<T> based in DataView schema
- Dominant language
- C#
- Stars
- 9.4k
- Forks
- 2k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 11
Description
## Problem
Today, when an `IDataView` is created using `TextLoader`, there's no need to create classes that define the schema.
```csharp
var cols = new []
{
new TextLoader.Column(name: "Text",dataKind:DataKind.String,index:47),
new TextLoader.Column(
name: "Categorical",
dataKind: DataKind.String,
source: new TextLoader.Range[] {
new TextLoader.Range(19),
new TextLoader.Range(20),
new TextLoader.Range(21),
new TextLoader.Range(50),
new TextLoader.Range(59),
new TextLoader.Range(71),
new TextLoader.Range(83)}),
new TextLoader.Column(name:"Label",dataKind:DataKind.String,2)
};
var dataLoader = ctx.Data.CreateTextLoader(columns:cols);
var idv = dataLoader.Load(path);
```
However, if I want to export the `IDataView` as an `IEnumerable`, I can't because I need to explicitly provide the type of `IEnumerable`. If no classes have been created, I now need to go and create a new class just to export to an `IEnumerable`.
## Proposed solution
Just like `LoadFromEnumerable` is able to infer and create an IDataView from `IEnumerable`, `CreateEnumerable` should be able to infer `T` based on the DataView schema or bind to an object at runtime using `dynamic`.
```csharp
ctx.Data.CreateEnumerable(idv,reuseRowObject:false,ignoreMissingColumns:false)
```
or
```csharp
ctx.Data.CreateEnumerable(idv,reuseRowObject:false,ignoreMissingColumns:false)
```
Contributor guide
Assessment
This issue has not been assessed yet.