Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

naive_bayes_rb

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

naive_bayes_rb

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

NaiveBayesRb

A very simple Ruby implementation of Naive Bayes classification model.

Design Considerations

  1. the interface closely resembles the python scikit-learn interface.
  2. enable model serialization and persistence, so that the model can be reused and even distributed and shared. With the default MarshalSerializer, it also allows custom serializer to be plugged in.

Usage

basics

nb = NaiveBayesRb::NaiveBayes.new
train = [[1, 20], [2, 21], [3, 22], [4, 23]] 
target = [1, 0, 1, 0] 
test = [[0, 0], [4, 24]]
predictions = nb.fit(train, target).predict(test) #=> [1, 0] 
@nb.accuracy(prediction, [1, 1]) #=> 50

Model Persistence

NaiveBayesRb::NaiveBayes.serializer =       
nb = NaiveBayesRb::NaiveBayes.new
nb.fit(train, target).save('model.pb')

Loading Persisted Model

NaiveBayesRb::NaiveBayes.serializer =       
nb = NaiveBayesRb::NaiveBayes.load('model.pb')

Installation

Add this line to your application's Gemfile:

gem 'naive_bayes_rb'

And then execute:

$ bundle

Or install it yourself as:

$ gem install naive_bayes_rb

Thanks

I followed the tutorials from this blog.

FAQs

Package last updated on 06 Mar 2018

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc