Sha256: 42f96717f37c2b7bb51ba40143b75a2f294dca21ac10a34fb21e315eccd7a9eb

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

# NBClass

This gem provides a naive bayes classifier for models with N features.
Simply put given examples of pre-defined categories the classifier learns how
to classify new unknown examples.

## Usage

Classifier can be used in three steps:

1. Provide category names and its respective training set

2. Train classifier with provided categories

3. Classify models

For instance the example below shows how to classify words in categories test_a and test_b.
Taking in consideration the number of occurrences of each word in both categories besides
the frequency of the category the classifier returns the most probable category for the
given collection of features.

```ruby
require 'nb_class/classifier'

# 1 - Providing examples
classifier = NBClass::Classifier.new
classifier.not_spam << "Hi Joe, how are you?"
classifier.spam << "Buy products you don't need"

# 2 - Train classifier
classifier.train

# 3 - Classify new examples
classifier.classify("Hi James, are you going?") # => not_spam
classifier.classify("Buy not needed product") # => spam
```

## Planed Future Features

1. Load category examples from external files to reduce code size
2. Load pre-trained data from file to decrease classifier initialization time
3. Optimize algorithms to use pre-calculated values

## 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nb_class-0.0.1 README.md