Skip to content

Instantly share code, notes, and snippets.

@elbruno
Created November 26, 2018 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbruno/f0ebe0b3a5159a607aa6ac6308b027f6 to your computer and use it in GitHub Desktop.
Save elbruno/f0ebe0b3a5159a607aa6ac6308b027f6 to your computer and use it in GitHub Desktop.
MLNet070PeekData
var mlContext = new MLContext(seed: 0);
_textLoader = mlContext.Data.TextReader(new TextLoader.Arguments()
{
Separator = ",",
HasHeader = true,
Column = new[]
{
new TextLoader.Column("Name", DataKind.Text, 0),
new TextLoader.Column("Age", DataKind.Num, 1),
new TextLoader.Column("Gender", DataKind.Text, 2),
new TextLoader.Column("Label", DataKind.Text, 3),
}
});
// split data 80/20
var dvTrain = _textLoader.Read(TrainDataPath);
// Train
var dataProcessPipeline = mlContext.Transforms.Categorical.MapValueToKey("Label", "LabelKeys")
.Append(mlContext.Transforms.Text.FeaturizeText("Gender", "GenderFeaturized"))
.Append(mlContext.Transforms.Concatenate("Features", "Age", "GenderFeaturized"));
ConsoleHelper.PeekDataViewInConsole<AgeRange>(mlContext, dvTrain, dataProcessPipeline);
ConsoleHelper.PeekVectorColumnDataInConsole(mlContext, "Features", dvTrain, dataProcessPipeline, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment