Skip to content

Comdex/olive

Repository files navigation

Olive

License GoDoc Version Wercker Coverage

Online algorithms for machine learning implemented in Golang.

Installation

For installation, execute the following command:

$ go get github.com/mitsuse/olive

Requirements

Olive uses the following libraries:

Features

Algorithms

Olive provides learning algorithms as follow:

  • Perceptron

Classifier

Olive provides an implementation of multi-class linear classifier.

Creation

Call classifier.New with the size of classes and the dimensions of features.

classSize, dimensions := 4, 8

c := classifier.New(classSize, dimensions)

Classification

Classify an instance by applying (*Classifier).Classify to its feature matrix. The feature matrix is typed as Matrix of mitsuse/matrix-go.

features := dense.New(classSize, dimensions)(
    0, 0, 1, 1, 0.5, 0.1, -2, 3, 0,
)

class := c.Classify(features)

Learn a classifier

Learner such as perceptron can update classifier by using the given training data.

classSize, dimensions := 2, 6
iterations := 3

feature := dense.New(1, dimensions)

// training data (pairs of a feature vector and its class).
instances := []*olive.Instance{
    olive.NewInstance(feature(1, 1, 1, 0, 0, 0), 0),
    olive.NewInstance(feature(1, 1, 0, 0, 0, 0), 0),
    olive.NewInstance(feature(0, 0, 0, 1, 1, 1), 1),
    olive.NewInstance(feature(0, 0, 0, 0, 1, 1), 1),
}

// Initialize a learner
learner := perceptron.New(iterations)

// Update the given classifier with the training data and return an updated classifier.
c := learner.Learn(classifier.New(classSize, dimensions), instances)

License

Please read LICENSE.txt.

About

Online algorithms for machine learning implemented in Golang.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages