GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - lytics/multibayes: Multiclass Naive Bayesian Classification

BranchesTags
Open more actions menu

Latest commit

 

History

59 Commits
59 Commits

Folders and files

NameName
Last commit message
Last commit date
.travis.yml
.travis.yml
 
 
README.md
README.md
 
 
bayes.go
bayes.go
 
 
bayes_test.go
bayes_test.go
 
 
doc.go
doc.go
 
 
encoding.go
encoding.go
 
 
encoding_test.go
encoding_test.go
 
 
example_test.go
example_test.go
 
 
sparse.go
sparse.go
 
 
sparse_test.go
sparse_test.go
 
 
stopbytes.go
stopbytes.go
 
 
testutil.go
testutil.go
 
 
tokenize.go
tokenize.go
 
 
tokenize_test.go
tokenize_test.go
 
 

Repository files navigation

Multibayes

Build Status GoDoc

Multiclass naive Bayesian document classification.

Often in document classification, a document may have more than one relevant classification -- a question on stackoverflow might have tags "go", "map", and "interface".

While multinomial Bayesian classification offers a one-of-many classification, multibayes offers tools for many-of-many classification. The multibayes library strives to offer efficient storage and calculation of multiple Bayesian posterior classification probabilities.

Usage

A new classifier is created with the NewClassifier function, and can be trained by adding documents and classes by calling the Add method:

classifier.Add("A new document", []string{"class1", "class2"})

Posterior probabilities for a new document are calculated by calling the Posterior method:

classifier.Posterior("Another new document")

A posterior class probability is returned for each class observed in the training set, which the user can use to determine class assignment. A user can then assign classifications according to his or her own heuristics -- for example, by using all classes that yield a posterior probability greater than 0.8

Example

documents := []struct {
	Text    string
	Classes []string
}{
	{
		Text:    "My dog has fleas.",
		Classes: []string{"vet"},
	},
	{
		Text:    "My cat has ebola.",
		Classes: []string{"vet", "cdc"},
	},
	{
		Text:    "Aaron has ebola.",
		Classes: []string{"cdc"},
	},
}

classifier := NewClassifier()
classifier.MinClassSize = 0

// train the classifier
for _, document := range documents {
	classifier.Add(document.Text, document.Classes)
}

// predict new classes
probs := classifier.Posterior("Aaron's dog has fleas.")
fmt.Printf("Posterior Probabilities: %+v\n", probs)

// Posterior Probabilities: map[vet:0.8571 cdc:0.2727]

About

Multiclass Naive Bayesian Classification

Resources

Readme
Activity
Custom properties

Stars

77 stars

Watchers

26 watching

Forks

9 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.