pymlstate

package module
v0.0.0-...-4004884 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fit

func Fit(ctx *core.Context, stateName string, bucket []data.Value) (data.Value, error)

Fit trains the model. It applies tuples that bucket has in a batch manner. The return value of this function depends on the implementation of Python UDS.

func Flush

func Flush(ctx *core.Context, stateName string) (data.Value, error)

Flush pymlstate bucket. A return value is always nil.

func Predict

func Predict(ctx *core.Context, stateName string, dt data.Value) (data.Value, error)

Predict applies the model to the given data and returns estimated values. The format of the return value depends on each Python UDS.

Types

type MLParams

type MLParams struct {
	// BatchSize is number of tuples in a single batch training. Write method,
	// which is usually called by an INSERT INTOT statement via uds Sink, stores
	// tuples without training until it has tuples as many as batch_train_size.
	// This is an optional parameter and its default value is 10.
	BatchSize int `codec:"batch_train_size"`
}

MLParams is parameters pymlstate defines in addition to those pystate does. These parameters come from a WITH clause of a CREATE STATE statement.

type State

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

State is python instance specialized to multiple layer classification. The python instance and this struct must not be coppied directly by assignment statement because it doesn't increase reference count of instance.

func New

func New(baseParams *pystate.BaseParams, mlParams *MLParams, params data.Map) (*State, error)

New creates `core.SharedState` for multiple layer classification.

func (*State) Fit

func (s *State) Fit(ctx *core.Context, bucket []data.Value) (data.Value, error)

Fit receives `data.Array` type but it assumes `[]data.Map` type for passing arguments to `fit` method.

func (*State) Load

func (s *State) Load(ctx *core.Context, r io.Reader, params data.Map) error

Load loads the model of the state. pystate calls `load` method and pass to the model data by using method parameter.

func (*State) Predict

func (s *State) Predict(ctx *core.Context, dt data.Value) (data.Value, error)

Predict applies the model to the data. It returns a result returned from Python script.

func (*State) Save

func (s *State) Save(ctx *core.Context, w io.Writer, params data.Map) error

Save saves the model of the state. pystate calls `save` method and use its return value as dumped model.

func (*State) Terminate

func (s *State) Terminate(ctx *core.Context) error

Terminate terminates this state.

func (*State) Write

func (s *State) Write(ctx *core.Context, t *core.Tuple) error

Write stores a tuple to its bucket and calls "fit" function every "batch_train_size" times.

type StateCreator

type StateCreator struct {
}

StateCreator is used by BQL to create or load Multiple Layer Classification State as a UDS.

func (*StateCreator) CreateState

func (c *StateCreator) CreateState(ctx *core.Context, params data.Map) (
	core.SharedState, error)

CreateState creates `core.SharedState`. Some parameters are from pystate package. See the document of pystate.BaseParams for details. pymlstate has its own parameters, which is defined at MLParams.

func (*StateCreator) LoadState

func (c *StateCreator) LoadState(ctx *core.Context, r io.Reader, params data.Map) (
	core.SharedState, error)

LoadState is same as CREATE STATE.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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