golearn

package module
v0.0.0-...-93838e3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2014 License: MIT Imports: 0 Imported by: 0

README

GoLearn


GoDoc Build Status

Support via Gittip

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.

// 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.
data, err := base.ParseCSVToInstances("datasets/iris_headers.csv", true)

// Print a pleasant summary of your data.
fmt.Println(data)

// Split your dataframe into a training set, and a test set, with an 80/20 proportion.
trainTest := base.InstancesTrainTestSplit(rawData, 0.8)
trainData := trainTest[0]
testData := trainTest[1]

// Instantiate a new KNN classifier. Euclidean distance, with 2 neighbours.
cls := knn.NewKnnClassifier("euclidean", 2)

// Fit it on your training data.
cls.Fit(trainData)

// Get your predictions against test instances.
predictions := cls.Predict(testData)

// Print a confusion matrix with precision and recall metrics.
confusionMat, _ := evaluation.GetConfusionMatrix(testData, predictions)
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 stephen dot whitworth at hailocab dot com.

Documentation

Overview

Package golearn is a machine learning library for Go.

Directories

Path Synopsis
Package base provides base interfaces for GoLearn objects to implement.
Package base provides base interfaces for GoLearn objects to implement.
edf
examples
Package knn implements a K Nearest Neighbors object, capable of both classification and regression.
Package knn implements a K Nearest Neighbors object, capable of both classification and regression.
Package linear_models implements linear and logistic regression models.
Package linear_models implements linear and logistic regression models.
metrics
pairwise
Package pairwise implements utilities to evaluate pairwise distances or inner product (via kernel).
Package pairwise implements utilities to evaluate pairwise distances or inner product (via kernel).
Package neural contains Neural Network functions.
Package neural contains Neural Network functions.
Package optimisation provides a number of optimisation functions.
Package optimisation provides a number of optimisation functions.
Package utilities implements a host of helpful miscellaneous functions to the library.
Package utilities implements a host of helpful miscellaneous functions to the library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL