netmsi-patricke / bayes

Naive bayes classifier in Scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bayes

A naive Bayes classifier in Scala

Training the classifier

import bayes._

Bayes.train("animals", "dogs go woof woof")
Bayes.train("sports", "I like playing basketball")

Classifying text

Once we've trained our classifer we can use it to classify documents

Bayes.classify("I love to play basketball").getOrElse("Unknown")
// res6: String = "sports"

Bayes.classify("When my dog barks he goes woof woof").getOrElse("Unknown")
// res8: String = animals

About

Naive bayes classifier in Scala