GoLearn
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.
twitter: @golearn_ml
Install
See here for installation instructions.
Getting Started
Data are loaded in as Instances. You can then perform matrix like operations on them, and pass them to estimators.
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.
package main
import (
"fmt"
"github.com/sjwhitworth/golearn/base"
"github.com/sjwhitworth/golearn/evaluation"
"github.com/sjwhitworth/golearn/knn"
)
func main() {
rawData, err := base.ParseCSVToInstances("datasets/iris.csv", false)
if err != nil {
panic(err)
}
fmt.Println(rawData)
cls := knn.NewKnnClassifier("euclidean", 2)
trainData, testData := base.InstancesTrainTestSplit(rawData, 0.50)
cls.Fit(trainData)
predictions := cls.Predict(testData)
fmt.Println(predictions)
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))
}
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
Overall accuracy: 0.9545
Examples
GoLearn comes with practical examples. Dive in and see what is going on.
cd $GOPATH/src/github.com/sjwhitworth/golearn/examples/knnclassifier
go run knnclassifier_iris.go
cd $GOPATH/src/github.com/sjwhitworth/golearn/examples/instances
go run instances.go
cd $GOPATH/src/github.com/sjwhitworth/golearn/examples/trees
go run trees.go
Join the team
Please send me a mail at stephenjameswhitworth@gmail.com