jbrukh / bayesian Goto Github PK
View Code? Open in Web Editor NEWNaive Bayesian Classification for Golang.
License: Other
Naive Bayesian Classification for Golang.
License: Other
LogScores, ProbScores, and SafeProbScores all have a return parameter that is the index of the most likely class. I think if you're ever willing to break the current api it would be a ton more useful to return the actual bayesian.Class.
It would make simple usage as below much easier.
As it stands I have to know the index of which I passed it into my classifier. That's knowledge I'd rather not have to know. It's kind of a difficult way to do it.
const (
Good bayesian.Class = "Good"
Bad bayesian.Class = "Bad"
Ugly bayesian.Class = "Ugly"
)
classifier := bayesian.NewClassifier(Good, Bad, Ugly)
_, c, _, _ := classifier.SafeProbScores(wht)
if c == Ugly {
fmt.Println("oh no")
}
Apologies in advance as my knowledge of Go is still somewhat limited, so this may be a naive question.
I want to expose the naive bayes classifying as a HTTP Web service, with both train and classify endpoints. I have no trouble with that, but I want the train endpoint to be able to accept new labels (labels that aren't currently in the classifier). Right now the labels are simply specified as consts and passed into the constructor. Can you think of the best way to add the ability to add labels at run-time?
Hi,
I found this library very useful.
I think since this has a supervised learning mechanism,
it would be good if we can add a new class for stuffs that can be learned
that can't be categorized from the existing classes.
Thanks
This is rather a question than an actual issue, but anyway.
First, did I get it right that the prior probability P(C_j)
of a class is the number of document within that class, divided by the total number of documents?
And if so, why does the getPriors()
function set the prior prob. of a class C to the number of words in documents of that class (classData.Total
) divided by the total number of words? I'd expect that for the prior prob, words don't play any role, yet.
Probably I have a problem in understanding, so please try to enlight me.
1.0 is still importing things like "gob" instead of "encoding/gob" etc. Can you make a new release? I can also help co-maintain the project is that helps.
Tools like dep
will pick up release versions for most people and they will get code that won't work for newer versions of go.
Thanks!
git tag -a 1.1 35eb93528ee -m "tag a specific older version that was built against"
git push --tags
In addition, it would be nice if current versions were tagged as well...
package main
import (
"log"
"github.com/jbrukh/bayesian"
)
const (
Arabic bayesian.Class = "Arabic"
Malay bayesian.Class = "Malay"
Yiddish bayesian.Class = "Yiddish"
)
func main() {
nbClassifier := bayesian.NewClassifier(Arabic, Malay, Yiddish)
arabicStuff := []string{"algeria", "bahrain", "comoros"}
malaysianStuff := []string{"malaysians", "bahasa"}
yiddishStuff := []string{"jewish", "jews", "israel"}
nbClassifier.Learn(arabicStuff, Arabic)
nbClassifier.Learn(malaysianStuff, Malay)
nbClassifier.Learn(yiddishStuff, Yiddish)
log.Println(nbClassifier.Learned()) // 3
log.Printf(`SEEN: %d`, nbClassifier.Seen()) // 0
}
Sorry, I didn't understand. After getting the result, how to know whether the result belongs to good or bad?
scores, likely, _ := classifier.LogScores(
[]string{"tall", "girl"},
)
probs, likely, _ := classifier.ProbScores(
[]string{"tall", "girl"},
)
likely == 1 is bad?
@jbrukh
Now it github.com/navossoc/bayesian
instead of github.com/jbrukh/bayesian
.
Was broken in PR #23
Current code panics in case the classifier is initialised with just 1 class.
However I have an edge case where there might only be a single class.
So I was thinking maybe classifier could be allowed to initialise with just 1 class.
I made changes in the code and tested for my use case. It worked. However, the unit tests fail in this case.
Is there any specific reason to keep this limitation?
What would be a good way to solve this, if any?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.