Documentation ¶
Overview ¶
Package bayes provides methods for creating, training and querying bayes models.
Index ¶
- Variables
- type Class
- type ClassErrorCount
- type Client
- type Model
- type TrainResults
- type TrainingSet
- func (t *TrainingSet) AddClass(ctx context.Context, class string) (Class, error)
- func (t *TrainingSet) AddRecord(ctx context.Context, class Class, data []string) (string, error)
- func (t *TrainingSet) Classes(ctx context.Context) ([]Class, error)
- func (t *TrainingSet) Create(ctx context.Context) error
- func (t *TrainingSet) Train(ctx context.Context, name string) (*TrainResults, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNotEnoughData = errors.New("not enough data")
ErrNotEnoughData is returned from train if there isn't enough training data.
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.
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) 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.
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 ¶
AddClass adds a class to a training set and returns a reference to it
func (*TrainingSet) AddRecord ¶
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.