Изменения
→Байесовская классификация
libraryDependencies '''+=''' "com.tsukaby" '''%%''' "naive-bayes-classifier-scala" '''%''' "0.2.0"
Пример классификации используя smile.classification.cart<ref>[https://github.com/tsukaby/naive-bayes-classifier-scala Naive bayes classifier, Scala]</ref>:
<span style="color:#3D9970>// Создание модели</span>
'''val '''bayes = '''new '''BayesClassifier[String, String]()
<span style="color:#3D9970>// Задание соотвествия категория - слово</span>
bayes.learn("technology", "github" :: "git" :: "tech" :: "technology" :: Nil)
bayes.learn("weather", "sun" :: "rain" :: "cloud" :: "weather" :: "snow" :: Nil)
bayes.learn("government", "ballot" :: "winner" :: "party" :: "money" :: "candidate" :: Nil)
<span style="color:#3D9970>// Тестовые примеры</span>
'''val '''unknownText1 = "I use git".split(" ")
'''val '''unknownText2 = "Today's weather is snow".split(" ")
'''val '''unknownText3 = "I will vote '''for '''that party".split(" ")
<span style="color:#3D9970>// Классификация</span> println(bayes.classify(unknownText1).map(_.category).getOrElse("")) <span style="color:#3D9970>// technology</span> println(bayes.classify(unknownText2).map(_.category).getOrElse("")) <span style="color:#3D9970>// weather</span> println(bayes.classify(unknownText3).map(_.category).getOrElse("")) <span style="color:#3D9970>// government</span>
===EM-алгоритм===