Skip to content

Easy-to-use Go implementation of the multinomial Naive Bayes classifier for multilabel text classification.

License

Notifications You must be signed in to change notification settings

haydenhigg/bengal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bengal

Easy-to-use Go implementations of two Naive Bayes classifiers for multilabel text classification.

install

In your project:

$ go get -u github.com/haydenhigg/bengal/v2

Then, import it as:

import "github.com/haydenhigg/bengal/v2"

use

modeling

  • TrainMultinomial(input, output [][]string) NaiveBayesModel: Creates a multinomial model from tokenized inputs.
  • (model *NaiveBayesModel) PredictMultinomial(x []string) []string: Predicts the labels of a tokenized input.
  • TrainBernoulli(input, output [][]string) NaiveBayesModel: Creates a Bernoulli model from tokenized inputs.
  • (model *NaiveBayesModel) PredictBernoulli(x []string) []string: Predicts the labels of a tokenized input.

example

package main

import (
  "fmt"
  "bengal"
)

func main() {
  inputs := [][]string{
    []string{"...", ...},
    []string{"...", ...},
    ...,
  }

  outputs := [][]string{
    []string{"label1-1", "label2-1"},
    []string{"label1-2", "label2-2"},
    ...,
  }
  
  model := bengal.NewBernoulli(inputs, outputs)
  
  fmt.Println(model.PredictBernoulli([]string {"...", ...}))
}

notes

  • It is recommended to stem all input examples using something like this before training or predicting.

About

Easy-to-use Go implementation of the multinomial Naive Bayes classifier for multilabel text classification.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages