<commit_before># NaiveBayes

This gem provides a naive bayes classifier for models with N features.

## 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 'naive_bayes/classifier'

classifier = NaiveBayes::Classifier.new
classifier.add_category(name: :test_a, training_set: [ 'green', 'green', 'green', 'green', 'blue' ])
classifier.add_category(name: :test_b, training_set: [ 'blue',  'blue',  'blue',  'blue',  'green' ])
classifier.train

classifier.classify(['green','blue','blue','blue') # => test_b
classifier.classify(['green', 'blue', 'green') # => test_a
```

## 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`)<commit_msg>README explains the steps to configure the classifier<commit_after># NaiveBayes

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 'naive_bayes/classifier'

# 1 - Providing examples
classifier = NaiveBayes::Classifier.new
classifier.add_category(
  name: :not_spam,
  training_set: [ 'Hi', 'Joe', 'how', 'are', 'you' ])
classifier.add_category(
  name: :spam,
  training_set: [ 'Buy',  'products',  'you',  'do',  'not', '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
```

## 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`)
{'fraction_non_alphanumeric': 0.10357537781054184, 'fraction_numerical': 0.006266126059712496, 'mean_word_length': 4.912854030501089, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6282348', 'n_tokens_mistral': 828, 'n_tokens_neox': 774, 'n_words': 331}