https://github.com/darthsim/bayes_classifier
Naive Bayes classifier
https://github.com/darthsim/bayes_classifier
Last synced: 11 months ago
JSON representation
Naive Bayes classifier
- Host: GitHub
- URL: https://github.com/darthsim/bayes_classifier
- Owner: DarthSim
- License: mit
- Created: 2013-09-22T00:02:46.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-09-22T01:13:32.000Z (over 12 years ago)
- Last Synced: 2025-06-26T12:06:44.328Z (12 months ago)
- Language: Ruby
- Homepage: https://github.com/DarthSim/bayes_classifier
- Size: 156 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Bayes::Classifier
Bayes::Classifier allows you to classify strings with naive Bayes classifier.
## Installation
Just add the following line to your `Gemfile`:
```ruby
gem 'bayes_classifier'
```
Then run 'bundle install'.
## Usage
```ruby
# Create new classifier
classifier = Bayes::Classifier.new
# Train classifier with a string
classifier.train :category1, "lorem ipsum dolor sit amet"
# Train classifier with array of strings
classifier.train_with_array :category2, ["the first string", "the second string", "the third string"]
# Train classifier with textfile
classifier.train_with_file :category3, "data/category3.txt"
# Train classifier with CSV file (first column - string, second column - category)
classifier.train_with_csv "data/training.csv"
# Apply weighting to the top words of category
classifier.apply_weighting :category3, 10
# Remove empty categories
classifier.pop_unused
# Classify string
classifier.classify "the string"
# Reset categories
classifier.flush
# Remove all categories
classifier.flush_all
```
## Contributing
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create new Pull Request