Skip to content

ajph/nbclassifier-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

nbclassifier-go

A Naive Bayes classifier in Golang

Usage

package main

import (
	"fmt"

	"github.com/ajph/nbclassifier-go"
)

func main() {
	m := nbclassifier.New()

	m.NewClass("banana")
	m.Learn("banana", "sweet", "yellow", "long")

	m.NewClass("orange")
	m.Learn("orange", "sweet", "orange", "round")

	m.NewClass("apple")
	m.Learn("apple", "sweet", "green", "red", "round")

	//m.SaveToFile("./test.json") 

	/*
		// or load from existing file
		m, err := nbclassifier.LoadFromFile("./test.json")
		if err != nil {
			panic(err)
		} 
	*/

	w, unsure, _ := m.Classify("round", "sweet")

	fmt.Println(w.Id, unsure)
}

Todo

  • Documentation
  • Tests

About

A Naive Bayes Classifier in Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages