a guest Jan 23rd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Create data process pipeline
  2. // First we have to change label value into ML.NET KeyType
  3. var dataProcessPipeline = context.Transforms.Conversion.MapValueToKey("Label")
  4.     // Then, we have to normalize text
  5.     .Append(context.Transforms.Text.NormalizeText("Sentence", "NormalizedSentence"))
  6.     // Featurize the given text with n-grams
  7.     .Append(context.Transforms.Text.FeaturizeText("NormalizedSentence", "Features"))
  8.     // Give the naive bayes algorithm
  9.     .Append(context.MulticlassClassification.Trainers.NaiveBayes())
  10.     // Convert back the label value to it's origin
  11.     .Append(context.Transforms.Conversion.MapKeyToValue("PredictedLabel"));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand