mlearning

package
v0.0.0-...-0dfd57a Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package mlearning provides a few abstracted machine learning algorithms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Class

type Class string

type Feature

type Feature string

type FeatureCollection

type FeatureCollection interface {
	Features() []Feature
}

type Iterator

type Iterator interface {
	Next() bool
	Features() []Feature
	Class() Class
	Predicted(c Class)
}

type Model

type Model struct {
	Weights map[Feature]map[Class]Weight
	Classes []Class

	I          int
	Totals     map[Feature]map[Class]Weight
	Timestamps map[Feature]map[Class]int
}

func NewModel

func NewModel() *Model

type Perceptron

type Perceptron struct {
	*Model
}

func NewPerceptron

func NewPerceptron() *Perceptron

func (*Perceptron) Predict

func (p *Perceptron) Predict(features []Feature) (Class, Weight)

func (*Perceptron) PredictAll

func (p *Perceptron) PredictAll(features []Feature) []Prediction

func (*Perceptron) Test

func (p *Perceptron) Test(fs Iterator) (int, int)

func (*Perceptron) Train

func (p *Perceptron) Train(fs Iterator) (int, int)

func (*Perceptron) Update

func (p *Perceptron) Update(truth Class, guess Class, features []Feature)

func (*Perceptron) UpdateFeature

func (p *Perceptron) UpdateFeature(c Class, f Feature, w Weight)

type Prediction

type Prediction struct {
	Class  Class
	Weight Weight
}

type SimpleIterator

type SimpleIterator struct {
	Index          int
	FeatureSlice   []FeatureCollection
	ClassSlice     []Class
	PredictedSlice []Class
}

func (*SimpleIterator) Class

func (i *SimpleIterator) Class() Class

func (*SimpleIterator) Features

func (i *SimpleIterator) Features() []Feature

func (*SimpleIterator) Next

func (i *SimpleIterator) Next() bool

func (*SimpleIterator) Predicted

func (i *SimpleIterator) Predicted(c Class)

func (*SimpleIterator) Reset

func (i *SimpleIterator) Reset(shuffle bool)

type Weight

type Weight float64

Jump to

Keyboard shortcuts

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