https://github.com/n3integration/classifier
A general purpose text classifier
https://github.com/n3integration/classifier
classification k-nearest-neighbors machine-learning naive-bayes
Last synced: 3 months ago
JSON representation
A general purpose text classifier
- Host: GitHub
- URL: https://github.com/n3integration/classifier
- Owner: n3integration
- License: apache-2.0
- Created: 2016-09-03T18:55:57.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-02-09T00:41:00.000Z (over 3 years ago)
- Last Synced: 2026-01-14T12:31:42.126Z (5 months ago)
- Topics: classification, k-nearest-neighbors, machine-learning, naive-bayes
- Language: Go
- Homepage:
- Size: 63.5 KB
- Stars: 43
- Watchers: 1
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# classifier
General purpose text classifier (naïve bayes, k-nearest neighbors)
[](https://codecov.io/gh/n3integration/classifier)
[](https://goreportcard.com/report/github.com/n3integration/classifier)
[](http://godoc.org/github.com/n3integration/classifier)
## Installation
```bash
go get github.com/n3integration/classifier
```
## Usage
### Classification
There are two methods of classifying text data: `io.Reader` or `string`. To classify strings, use the `TrainString`
or `ClassifyString` functions. To classify larger sources, use the `Train` and `Classify` functions that
take an `io.Reader` as input.
```go
package main
import (
"fmt"
"github.com/n3integration/classifier/naive"
)
func main() {
classifier := naive.New()
classifier.TrainString("The quick brown fox jumped over the lazy dog", "ham")
classifier.TrainString("Earn a degree online", "ham")
classifier.TrainString("Earn cash quick online", "spam")
if classification, err := classifier.ClassifyString("Earn your masters degree online"); err == nil {
fmt.Println("Classification => ", classification) // ham
} else {
fmt.Println("error: ", err)
}
}
```
## Contributing
- Fork the repository
- Create a local feature branch
- Run `gofmt`
- Bump the `VERSION` file using [semantic versioning](https://semver.org/)
- Submit a pull request
## License
Copyright 2023 n3integration@gmail.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.