Socket
Book a DemoInstallSign in
Socket

bayes_naive_jdp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bayes_naive_jdp

0.0.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

BayesNaiveJdp

This is a very simple Naive Bayesian classifier, build just for fun.

I decided to use it as an example while learning to package ruby code.

The algorithm used here is not original, but an adaptation from Burak Kanber's Machine Learning in Javascript series.

Installation

Add this line to your application's Gemfile:

gem 'bayes_naive_jdp'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bayes_naive_jdp

Usage

#	create an instance of the Classifier
classifier = BayesNaiveJdp::Classifier.new

#	Train the Classifier using many samples from each valid category
#	documents are strings, categories are strings, symbols, or integers
classifier.train(document_a_1, category_a)
classifier.train(document_a_2, category_a)
classifier.train(document_a_3, category_a)
..
classifier.train(document_b_1, category_b)
classifier.train(document_b_2, category_b)
classifier.train(document_b_3, category_b)
..

#	use the classifier to categorize an unknown document
results = classifier.classify(mystery_document)
category = results[:winner][:classification]
confidence = results[:winner][:confidence]

#	also, results[:all_scores] is a hash 
#	with categories as indices and confidence levels as values

FAQs

Package last updated on 18 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.