Skip to content

Instantly share code, notes, and snippets.

@mdfarragher
Created July 23, 2020 17:47
Show Gist options
  • Save mdfarragher/99696298eb7207c34feaf3145d372b0b to your computer and use it in GitHub Desktop.
Save mdfarragher/99696298eb7207c34feaf3145d372b0b to your computer and use it in GitHub Desktop.
// build a training pipeline
let pipeline =
EstimatorChain()
// step 1: map the number column to a key value and store in the label column
.Append(context.Transforms.Conversion.MapValueToKey("Label", "Number", keyOrdinality = ValueToKeyMappingEstimator.KeyOrdinality.ByValue))
// step 2: concatenate all feature columns
.Append(context.Transforms.Concatenate("Features", "PixelValues"))
// step 3: cache data to speed up training
.AppendCacheCheckpoint(context)
// step 4: train the model with SDCA
.Append(context.MulticlassClassification.Trainers.SdcaMaximumEntropy())
// step 5: map the label key value back to a number
.Append(context.Transforms.Conversion.MapKeyToValue("Number", "Label"))
// train the model
let model = trainData |> pipeline.Fit
// the rest of the code goes here....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment