Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jbrukh/bayesian
Naive Bayesian Classification for Golang.
https://github.com/jbrukh/bayesian
Last synced: about 1 month ago
JSON representation
Naive Bayesian Classification for Golang.
- Host: GitHub
- URL: https://github.com/jbrukh/bayesian
- Owner: jbrukh
- License: other
- Created: 2011-11-23T04:17:00.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-11-17T14:32:45.000Z (7 months ago)
- Last Synced: 2024-02-02T07:09:42.125Z (4 months ago)
- Language: Go
- Homepage:
- Size: 71.3 KB
- Stars: 781
- Watchers: 34
- Forks: 127
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- AI - bayesian - Naive Bayesian Classification for Golang. **[Deprecated]** (Go / [Tools](#tools-1))
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- awesome-cobol - bayesian - Naive Bayesian Classification for Cobollang. (Machine Learning / Middlewares)
- awesome-go-extra - bayesian - 11-23T04:17:00Z|2020-07-24T17:41:07Z| (Machine Learning / Advanced Console UIs)
- awesome-go-zh - bayesian
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. **[Deprecated]** (Go / [Tools](#tools-1))
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- awesome-go - bayesian - | - | - | (Machine Learning / Advanced Console UIs)
- awesome-go-cn - bayesian
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- fucking-awesome-go - :octocat: bayesian - Naive Bayesian Classification for Golang. :star: 316 :fork_and_knife: 43 (Machine Learning / Advanced Console UIs)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. **[Deprecated]** (Go)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-go-projects - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Standard CLI)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-go-with-framework - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- awesome-go-cn - bayesian
- zero-alloc-awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-golang-ai - bayesian
- awesome-machine-learnings - bayesian - Naive Bayesian Classification for Golang. **[Deprecated]** (Go / [Tools](#tools-1))
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (<span id="机器学习-machine-learning">机器学习 Machine Learning</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go. - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-machine-learning-library - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. **[Deprecated]** (Go / [Tools](#tools-1))
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-go-stars - bayesian(stars: 784) - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- awesome-go-cn - bayesian - 贝叶斯分类器 (机器学习 / 高级控制台界面)
- awesome-go-with-stars - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. **[Deprecated]** (Go / [Tools](#tools-1))
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. **[Deprecated]** (Go / Tools)
- repo-1316-awesome-go-cn - bayesian
- repo-1211-awesome-go-cn - bayesian
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-Char - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-reader - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- Go-awesome - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- go-awesome-cn-star - bayesian
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. **[Deprecated]** (Go / Tools)
- awesome-advanced-metering-infrastructure - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-go-handwritten - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-go - bayesian - 貝葉斯分類器 (機器學習 / 高級控制台界面)
- awesome-machine-master - bayesian - Naive Bayesian Classification for Golang. (Go)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. - ★ 578 (Machine Learning)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-go2 - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. - :arrow_down:35 - :star:367 (Machine Learning / Advanced Console UIs)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Advanced Console UIs)
- awesome-machine-learning - bayesian - Naive Bayesian Classification for Golang. (Go / Speech Recognition)
- awesome-go-cn - bayesian
- awesome-go-zh - bayesian
- awesome-go-cn - bayesian
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- awesome-go - bayesian - Naive Bayesian Classification for Golang. (Machine Learning / Search and Analytic Databases)
- awesome-go-cn - bayesian
- awesome-machine-learning-cn - 官网
README
# Naive Bayesian Classification
Perform naive Bayesian classification into an arbitrary number of classes on sets of strings. `bayesian` also supports term frequency-inverse document frequency calculations ([TF-IDF](https://www.wikiwand.com/en/Tf%E2%80%93idf)).
Copyright (c) 2011-2017. Jake Brukhman. ([email protected]).
All rights reserved. See the LICENSE file for BSD-style license.------------
## Background
This is meant to be an low-entry barrier Go library for basic Bayesian classification. See code comments for a refresher on naive Bayesian classifiers, and please take some time to understand underflow edge cases as this otherwise may result in innacurate classifications.
------------
## Installation
Using the go command:
```shell
go get github.com/jbrukh/bayesian
go install !$
```------------
## Documentation
See the GoPkgDoc documentation [here](https://godoc.org/github.com/jbrukh/bayesian).
------------
## Features
- Conditional probability and "log-likelihood"-like scoring.
- Underflow detection.
- Simple persistence of classifiers.
- Statistics.
- TF-IDF support.------------
## Example 1 (Simple Classification)
To use the classifier, first you must create some classes
and train it:```go
import "github.com/jbrukh/bayesian"const (
Good bayesian.Class = "Good"
Bad bayesian.Class = "Bad"
)classifier := bayesian.NewClassifier(Good, Bad)
goodStuff := []string{"tall", "rich", "handsome"}
badStuff := []string{"poor", "smelly", "ugly"}
classifier.Learn(goodStuff, Good)
classifier.Learn(badStuff, Bad)
```Then you can ascertain the scores of each class and
the most likely class your data belongs to:```go
scores, likely, _ := classifier.LogScores(
[]string{"tall", "girl"},
)
```Magnitude of the score indicates likelihood. Alternatively (but
with some risk of float underflow), you can obtain actual probabilities:```go
probs, likely, _ := classifier.ProbScores(
[]string{"tall", "girl"},
)
```## Example 2 (TF-IDF Support)
To use the TF-IDF classifier, first you must create some classes
and train it and you need to call ConvertTermsFreqToTfIdf() AFTER training
and before calling classification methods such as `LogScores`, `SafeProbScores`, and `ProbScores`)```go
import "github.com/jbrukh/bayesian"const (
Good bayesian.Class = "Good"
Bad bayesian.Class = "Bad"
)// Create a classifier with TF-IDF support.
classifier := bayesian.NewClassifierTfIdf(Good, Bad)goodStuff := []string{"tall", "rich", "handsome"}
badStuff := []string{"poor", "smelly", "ugly"}classifier.Learn(goodStuff, Good)
classifier.Learn(badStuff, Bad)// Required
classifier.ConvertTermsFreqToTfIdf()
```Then you can ascertain the scores of each class and
the most likely class your data belongs to:```go
scores, likely, _ := classifier.LogScores(
[]string{"tall", "girl"},
)
```Magnitude of the score indicates likelihood. Alternatively (but
with some risk of float underflow), you can obtain actual probabilities:```go
probs, likely, _ := classifier.ProbScores(
[]string{"tall", "girl"},
)
```Use wisely.