Skip to content

tsukaby/naive-bayes-classifier-scala

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Naive bayes classifier library. Implemented by Scala.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages