No commit activity in last 3 years
No release in over 3 years
Naive Bayes classifier
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
>= 0
 Project Readme

Bayes::Classifier

Bayes::Classifier allows you to classify strings with naive Bayes classifier.

Installation

Just add the following line to your Gemfile:

gem 'bayes_classifier'

Then run 'bundle install'.

Usage

# 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