Skip to content

Consider providing a source generator to generate ModelInput/Output class? #6156

Open
@LittleLittleCloud

Description

@LittleLittleCloud

schema should contain all required information to generate both input/output class

Usage

  • add model.zip as AdditionalFiles and set IsMLNetModel to true
    image

  • mlnet generate both input and output class for project

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.ML;
using Microsoft.ML.Data;

namespace MLNetSourceGenerator.CodeGen
{

public class TitanicInput
{
[ColumnName(@"PassengerId")]
public float PassengerId {get; set;}

[ColumnName(@"Survived")]
public float Survived {get; set;}

[ColumnName(@"Pclass")]
public float Pclass {get; set;}

[ColumnName(@"Name")]
public string Name {get; set;}

[ColumnName(@"Sex")]
public string Sex {get; set;}

[ColumnName(@"Age")]
public float Age {get; set;}

[ColumnName(@"SibSp")]
public float SibSp {get; set;}

[ColumnName(@"Parch")]
public float Parch {get; set;}

[ColumnName(@"Ticket")]
public string Ticket {get; set;}

[ColumnName(@"Fare")]
public float Fare {get; set;}

[ColumnName(@"Cabin")]
public string Cabin {get; set;}

[ColumnName(@"Embarked")]
public string Embarked {get; set;}

}


public class TitanicOutput
{
[ColumnName(@"PassengerId")]
public float PassengerId {get; set;}

[ColumnName(@"Survived")]
public uint Survived {get; set;}

[ColumnName(@"Pclass")]
public float Pclass {get; set;}

[ColumnName(@"Name")]
public float[] Name {get; set;}

[ColumnName(@"Sex")]
public float[] Sex {get; set;}

[ColumnName(@"Age")]
public float Age {get; set;}

[ColumnName(@"SibSp")]
public float SibSp {get; set;}

[ColumnName(@"Parch")]
public float Parch {get; set;}

[ColumnName(@"Ticket")]
public float[] Ticket {get; set;}

[ColumnName(@"Fare")]
public float Fare {get; set;}

[ColumnName(@"Cabin")]
public float[] Cabin {get; set;}

[ColumnName(@"Embarked")]
public float[] Embarked {get; set;}

[ColumnName(@"Features")]
public float[] Features {get; set;}

[ColumnName(@"PredictedLabel")]
public float PredictedLabel {get; set;}

[ColumnName(@"Score")]
public float[] Score {get; set;}

}

}

Example

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Priority of the issue for triage purpose: Needs to be fixed at some point.enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions