Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create data process pipeline
- // First we have to change label value into ML.NET KeyType
- var dataProcessPipeline = context.Transforms.Conversion.MapValueToKey("Label")
- // Then, we have to normalize text
- .Append(context.Transforms.Text.NormalizeText("Sentence", "NormalizedSentence"))
- // Featurize the given text with n-grams
- .Append(context.Transforms.Text.FeaturizeText("NormalizedSentence", "Features"))
- // Give the naive bayes algorithm
- .Append(context.MulticlassClassification.Trainers.NaiveBayes())
- // Convert back the label value to it's origin
- .Append(context.Transforms.Conversion.MapKeyToValue("PredictedLabel"));
Add Comment
Please, Sign In to add comment