Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
static void Main(string[] args)
var dataPath = "AgeRangeData.csv";
var env = new LocalEnvironment();
var reader = TextLoader.CreateReader(env, ctx => (
Name: ctx.LoadText(0),
Age: ctx.LoadFloat(1),
Gender: ctx.LoadText(2),
Label: ctx.LoadText(3)),
separator: ',', hasHeader: true);
var trainData = reader.Read(new MultiFileSource(dataPath));
var classification = new MulticlassClassificationContext(env);
var learningPipeline = reader.MakeNewEstimator()
.Append(r => (
Predictions: classification.Trainers.Sdca
(label: r.Label.ToKey(),
features: r.Age.AsVector())));
// create temp view of data
var data = reader.Read(new MultiFileSource(dataPath));
var tempData = learningPipeline.Fit(data).Transform(data);
var tempRows = tempData.AsDynamic
.AsEnumerable<AgeRange>(env, reuseRowObject: false).ToArray();
learningPipeline.Append(r => r.Predictions.predictedLabel.ToValue());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.