Skip to content
Naive bayes classifier library. Implemented by Scala.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
src
.gitignore
.travis.yml
LICENSE
README.md
build.sbt

README.md

naive-bayes-classifier-scala

Naive bayes classifier library. Implemented by Scala.

This is porting from ptnplanet/Java-Naive-Bayes-Classifier

Build Status Maven Central Scaladoc

Getting Started

libraryDependencies ++= Seq(
  "com.tsukaby" %% "naive-bayes-classifier-scala" % "0.2.0"
)

This library has been published in the Maven central.

How to use

// Create instance
val bayes = new BayesClassifier[String, String]()

// Learning
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)

val unknownText1 = "I use git".split(" ")
val unknownText2 = "Today's weather is snow".split(" ")
val unknownText3 = "I will vote for that party".split(" ")

// Classify
println(bayes.classify(unknownText1).map(_.category).getOrElse("")) // technology
println(bayes.classify(unknownText2).map(_.category).getOrElse("")) // weather
println(bayes.classify(unknownText3).map(_.category).getOrElse("")) // government

Contribution

I'm seeking your PR!!! I'm easy.

For example.

  • Bug fix
  • Refactoring the code.
  • Add new features and others.
  • Fix my odd English texts.

License

Copyright 2015 - 2017 tsukaby.com
MIT License
You can’t perform that action at this time.