bayes

package
v0.0.0-...-9a18aee Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package bayes provides methods for creating, training and querying bayes models.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotEnoughData = errors.New("not enough data")

ErrNotEnoughData is returned from train if there isn't enough training data.

View Source
var ErrNotTrained = errors.New("model not trained")

ErrNotTrained is returned from Query if the model has not been trained.

Functions

This section is empty.

Types

type Class

type Class struct {
	// contains filtered or unexported fields
}

Class is a bayes class.

func (*Class) Name

func (c *Class) Name() string

Name is the name of the class.

type ClassErrorCount

type ClassErrorCount struct {
	Class Class

	// Number of records incorrectly classified into this class.
	Count uint32
}

ClassErrorCount is a measure of how many records were incorrectly classified into a particular Class.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides methods for interacting with bayes models.

func New

func New(client *sajari.Client) *Client

New returns a handler which provides access to functionality for building and manipulating bayes models.

func (*Client) Model

func (c *Client) Model(name string) *Model

Model returns a handle for using a bayes model.

func (*Client) TrainingSet

func (c *Client) TrainingSet(name string) *TrainingSet

TrainingSet returns a handle for using bayes training sets.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model provides methods for interacting with bayes models.

func (*Model) Classes

func (m *Model) Classes() ([]string, error)

Classes returns the list of classes in the bayes model.

func (*Model) Classify

func (m *Model) Classify(ctx context.Context, data []string) (*Class, error)

Classify classifies the data into a model class.

type TrainResults

type TrainResults struct {
	// Errors is mapping of records that were incorrectly
	// classified.
	Errors map[Class][]ClassErrorCount

	Correct, Incorrect uint32
}

TrainResults is a collection of information

func (TrainResults) Accuracy

func (r TrainResults) Accuracy() float64

Accuracy returns the total accuracy percentage of the results

type TrainingSet

type TrainingSet struct {
	// contains filtered or unexported fields
}

func (*TrainingSet) AddClass

func (t *TrainingSet) AddClass(ctx context.Context, class string) (Class, error)

AddClass adds a class to a training set and returns a reference to it

func (*TrainingSet) AddRecord

func (t *TrainingSet) AddRecord(ctx context.Context, class Class, data []string) (string, error)

AddRecord adds a record to a class and gives you the SHA1 of the data back

func (*TrainingSet) Classes

func (t *TrainingSet) Classes(ctx context.Context) ([]Class, error)

Info returns info about a training set such as class names

func (*TrainingSet) Create

func (t *TrainingSet) Create(ctx context.Context) error

Create creates a new training set.

func (*TrainingSet) Train

func (t *TrainingSet) Train(ctx context.Context, name string) (*TrainResults, error)

Train trains a the training set, creating a model which can be loaded as well as returning the result data from the training.

Jump to

Keyboard shortcuts

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