naive
Version, currently master branch1 version
- master branchlatestDec 1, 2016
github.com/ruivieira/naivebayes
A naive Bayes classifier for Crystal based on muatik's naive-bayes-classifier
1 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
naive:
github: ruivieira/naivebayes
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- MIT
- Author
- Rui Vieira
Dependencies
This version declares no dependencies.
README
naive
Naive Bayes classifier for Crystal (based on muatik's classifier).
Installation
Add this to your application's shard.yml:
dependencies:
gsl:
github: ruivieira/naivebayes
Usage
require "naive"
tokeniser = Naive::Tokeniser.new
newsTrainer = Naive::Trainer.new(tokeniser)
newsSet = [
{"text" => "not to eat too much is not enough to lose weight", "category" => "health"},
{"text" => "Russia try to invade Ukraine", "category" => "politics"},
{"text" => "do not neglect exercise", "category" => "health"},
{"text" => "Syria is the main issue, Obama says", "category" => "politics"},
{"text" => "eat to lose weight", "category" => "health"},
{"text" => "you should not eat much", "category" => "health"},
]
newsSet.each { |news|
newsTrainer.train(news["text"], news["category"])
}
newsClassifier = Naive::Classifier.new(newsTrainer.data, tokeniser)
classification = newsClassifier.classify("Obama is")
puts classification # => {"health" => 1.6666666666666666e-10, "politics" => 0.083333333333333329}
Warning:
- Not fully test
- Pre-release (API will break)
- Not fit for production
Contributing
- Fork it ( https://github.com/ruivieira/crystal-gsl/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Dec 1, 2016
- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/ruivieira/naivebayes
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1