Skip to content

Be able to create a reader by just specifying an schema class instead of all the columns #1515

@CESARDELATORRE

Description

@CESARDELATORRE

In current version (v0.6 and v0.7) when creating a TextLoader we need to provide all the columns explicetely like the following:

_loader = mlContext.Data.TextReader(new TextLoader.Arguments()
{
Separator = ",",
HasHeader = true,
Column = new[]
{
new TextLoader.Column("Season", DataKind.R4, 2),
new TextLoader.Column("Year", DataKind.R4, 3),
new TextLoader.Column("Month", DataKind.R4, 4),
new TextLoader.Column("Hour", DataKind.R4, 5),
new TextLoader.Column("Holiday", DataKind.R4, 6),
new TextLoader.Column("Weekday", DataKind.R4, 7),
new TextLoader.Column("WorkingDay", DataKind.R4, 8),
new TextLoader.Column("Weather", DataKind.R4, 9),
new TextLoader.Column("Temperature", DataKind.R4, 10),
new TextLoader.Column("NormalizedTemperature", DataKind.R4, 11),
new TextLoader.Column("Humidity", DataKind.R4, 12),
new TextLoader.Column("Windspeed", DataKind.R4, 13),
new TextLoader.Column("Count", DataKind.R4, 16)
}
}

Since you usually also have a schema class for the observations, like the following:

public class DemandObservation
{
    public float Season;
    public float Year;
    public float Month;
    public float Hour;
    public float Holiday;
    public float Weekday;
    public float WorkingDay;
    public float Weather;
    public float Temperature;
    public float NormalizedTemperature;
    public float Humidity;
    public float Windspeed;
    public float Count;   // This is the observed count, to be used a "label" to predict
}

It would be very convenient to be able to create a TextReader by just providing the class, like this:

mlContext.Data.TextReader(DemandObservation);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions