1
0
mirror of https://github.com/sjwhitworth/golearn.git synced 2025-04-26 13:49:14 +08:00
golearn/README.md

107 lines
3.1 KiB
Markdown
Raw Normal View History

2013-12-26 17:07:24 +00:00
GoLearn
2013-12-26 13:06:55 +00:00
=======
2014-05-04 09:31:31 +01:00
<img src="http://talks.golang.org/2013/advconc/gopherhat.jpg" width=125><br>
[![GoDoc](https://godoc.org/github.com/sjwhitworth/golearn?status.png)](https://godoc.org/github.com/sjwhitworth/golearn)
[![Build Status](https://travis-ci.org/sjwhitworth/golearn.png?branch=master)](https://travis-ci.org/sjwhitworth/golearn)<br>
2014-05-01 08:24:22 +01:00
2014-08-10 23:03:01 +01:00
[![Support via Gittip](https://rawgithub.com/twolfson/gittip-badge/0.2.0/dist/gittip.png)](https://www.gittip.com/sjwhitworth/)
2014-08-10 23:00:40 +01:00
2014-05-17 21:17:57 +01:00
GoLearn is a 'batteries included' machine learning library for Go. **Simplicity**, paired with customisability, is the goal.
We are in active development, and would love comments from users out in the wild. Drop us a line on Twitter.
2014-01-04 11:12:06 +00:00
2014-05-03 18:38:20 +01:00
twitter: [@golearn_ml](http://www.twitter.com/golearn_ml)
2014-05-01 11:59:24 +08:00
Install
=======
2014-07-20 08:58:59 -07:00
See [here](https://github.com/sjwhitworth/golearn/wiki/Installation) for installation instructions.
2014-05-01 11:59:24 +08:00
2014-05-17 21:17:57 +01:00
Getting Started
2014-05-01 11:59:24 +08:00
=======
2014-05-17 21:19:31 +01:00
Data are loaded in as Instances. You can then perform matrix like operations on them, and pass them to estimators.
2014-05-17 21:20:34 +01:00
GoLearn implements the scikit-learn interface of Fit/Predict, so you can easily swap out estimators for trial and error.
GoLearn also includes helper functions for data, like cross validation, and train and test splitting.
2014-05-17 21:19:18 +01:00
```go
2014-12-21 19:09:43 -08:00
package main
import (
"fmt"
"github.com/sjwhitworth/golearn/base"
"github.com/sjwhitworth/golearn/evaluation"
"github.com/sjwhitworth/golearn/knn"
)
func main() {
// Load in a dataset, with headers. Header attributes will be stored.
// Think of instances as a Data Frame structure in R or Pandas.
// You can also create instances from scratch.
rawData, err := base.ParseCSVToInstances("datasets/iris.csv", false)
2014-12-21 19:09:43 -08:00
if err != nil {
panic(err)
}
// Print a pleasant summary of your data.
fmt.Println(rawData)
//Initialises a new KNN classifier
cls := knn.NewKnnClassifier("euclidean", 2)
//Do a training-test split
trainData, testData := base.InstancesTrainTestSplit(rawData, 0.50)
cls.Fit(trainData)
//Calculates the Euclidean distance and returns the most popular label
predictions, err := cls.Predict(testData)
if err != nil {
panic(err)
}
2014-12-21 19:09:43 -08:00
// Prints precision/recall metrics
confusionMat, err := evaluation.GetConfusionMatrix(testData, predictions)
if err != nil {
panic(fmt.Sprintf("Unable to get confusion matrix: %s", err.Error()))
}
fmt.Println(evaluation.GetSummary(confusionMat))
}
2014-05-17 21:17:57 +01:00
```
```
Iris-virginica 28 2 56 0.9333 0.9333 0.9333
Iris-setosa 29 0 59 1.0000 1.0000 1.0000
Iris-versicolor 27 2 57 0.9310 0.9310 0.9310
2014-05-17 21:17:57 +01:00
Overall accuracy: 0.9545
```
Examples
========
GoLearn comes with practical examples. Dive in and see what is going on.
```bash
cd $GOPATH/src/github.com/sjwhitworth/golearn/examples/knnclassifier
2014-05-01 11:59:24 +08:00
go run knnclassifier_iris.go
```
```bash
cd $GOPATH/src/github.com/sjwhitworth/golearn/examples/instances
2014-05-17 21:17:57 +01:00
go run instances.go
2014-05-01 11:59:24 +08:00
```
```bash
cd $GOPATH/src/github.com/sjwhitworth/golearn/examples/trees
go run trees.go
```
2014-05-01 11:59:24 +08:00
2017-04-07 09:34:49 +08:00
Docs
====
2017-04-07 09:54:52 +08:00
* [English](https://github.com/sjwhitworth/golearn/wiki)
* [中文文档](doc/zh/Home.md)
2017-04-07 09:34:49 +08:00
2014-04-30 08:22:58 +01:00
Join the team
2014-04-28 08:11:40 +01:00
=============
2015-05-06 07:39:21 +01:00
Please send me a mail at stephenjameswhitworth@gmail.com