Documentation ¶
Overview ¶
Package classificationbox provides a client for accessing Classificationbox services.
Index ¶
- type Class
- type ClassStats
- type Client
- func (c *Client) CreateModel(ctx context.Context, model Model) (Model, error)
- func (c *Client) DeleteModel(ctx context.Context, modelID string) error
- func (c *Client) GetModel(ctx context.Context, modelID string) (Model, error)
- func (c *Client) GetModelStats(ctx context.Context, modelID string) (ModelStats, error)
- func (c *Client) Info() (*boxutil.Info, error)
- func (c *Client) ListModels(ctx context.Context) ([]Model, error)
- func (c *Client) OpenState(ctx context.Context, modelID string) (io.ReadCloser, error)
- func (c *Client) PostState(ctx context.Context, r io.Reader, predictOnly bool) (Model, error)
- func (c *Client) PostStateURL(ctx context.Context, stateURL *url.URL, predictOnly bool) (Model, error)
- func (c *Client) Predict(ctx context.Context, modelID string, request PredictRequest) (PredictResponse, error)
- func (c *Client) SetClient(client *http.Client)
- func (c *Client) Teach(ctx context.Context, modelID string, example Example) error
- func (c *Client) TeachMulti(ctx context.Context, modelID string, examples []Example) error
- type Example
- type Feature
- func FeatureImageBase64(key string, data string) Feature
- func FeatureImageURL(key string, url string) Feature
- func FeatureKeyword(key string, keyword string) Feature
- func FeatureList(key string, keywords ...string) Feature
- func FeatureNumber(key string, value float64) Feature
- func FeatureText(key string, text string) Feature
- type Model
- type ModelOptions
- type ModelStats
- type PredictRequest
- type PredictResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Class ¶
type Class struct { // ID is the class being predicted. ID string `json:"id,omitempty"` // Score is a numerical value indicating how this prediction relates // to other predictions. Score float64 `json:"score,omitempty"` }
Class is a predicted choice.
type ClassStats ¶
type ClassStats struct { // Name is the name of the class. Name string // Examples is the number of examples of this class that // the model has been taught. Examples int }
ClassStats contains per-class statistics.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP client that can make requests to the box.
func (*Client) CreateModel ¶
CreateModel creates the Model in Classificationbox. If no ID is set, one will be assigned in the return Model.
func (*Client) DeleteModel ¶
DeleteModel deletes a Model by its ID.
func (*Client) GetModelStats ¶
GetModelStats gets the statistics for the specified model.
func (*Client) ListModels ¶
ListModels gets all models.
func (*Client) OpenState ¶
OpenState opens the state file for the specified model for reading. Clients must call Close.
func (*Client) PostState ¶
PostState uploads new state data and returns the Model that was contained in the state file.
func (*Client) PostStateURL ¶
func (c *Client) PostStateURL(ctx context.Context, stateURL *url.URL, predictOnly bool) (Model, error)
PostStateURL tells Classificationbox to download the state file specified by the URL and returns the Model that was contained in the state file.
func (*Client) Predict ¶
func (c *Client) Predict(ctx context.Context, modelID string, request PredictRequest) (PredictResponse, error)
Predict asks a Model to make a prediction.
type Example ¶
Example is a set of Feature properties with their associated Class which is used to teach Classificationbox models.
type Feature ¶
type Feature struct { // Key is the name of the Feature. Key string `json:"key"` // Value is the string value of this Feature. Value string `json:"value"` // Type is the type of the Feature. // Can be "number", "text", "keyword", "list", "image_url" or "image_base64".. Type string `json:"type"` }
Feature represents a single feature, to describe an input.
func FeatureImageBase64 ¶
FeatureImageBase64 makes a Feature that is a base64 encoded image.
func FeatureImageURL ¶
FeatureImageURL makes a Feature that points to a hosted image.
func FeatureKeyword ¶
FeatureKeyword makes a textual Feature that will not be tokenized. Use FeatureList to provide multiple keywords in a single Feature. Use Text for bodies of text that should be tokenized.
func FeatureList ¶
FeatureList makes a Feature made up of multiple keywords.
func FeatureNumber ¶
FeatureNumber makes a numerical Feature.
func FeatureText ¶
FeatureText makes a textual Feature that will be tokenized. Use FeatureKeyword for values that should not be tokenized.
type Model ¶
type Model struct { // ID is the ID of the model. ID string `json:"id,omitempty"` // Name is the human readable name of the Model. Name string `json:"name"` // Options are optional Model settings to adjust the behaviour // of this Model within Classificationbox. Options *ModelOptions `json:"options,omitempty"` // Classes are the classes that this model can learn. Classes []string `json:"classes,omitempty"` }
Model represents a single model inside Classificationbox.
type ModelOptions ¶
type ModelOptions struct { // Ngrams describes the n-grams for text analysis. Ngrams int `json:"ngrams,omitempty"` // Skipgrams describes the skip-grams for the text analysis. Skipgrams int `json:"skipgrams,omitempty"` }
ModelOptions describes the behaviours of a Model.
type ModelStats ¶
type ModelStats struct { // Predictions is the number of predictions this model has made. Predictions int // Examples is the total number of examples this model has // been taught. Examples int // Classes is a list of statistics per class. Classes []ClassStats }
ModelStats are the statistics for a Model.
type PredictRequest ¶
type PredictRequest struct { // Limit sets the maximum number of classes that will be returned // in a prediction. Limit int `json:"limit"` // Inputs is a list of Feature objects that will be used when // making the prediction. Inputs []Feature `json:"inputs,omitempty"` }
PredictRequest contains information about the prediction that Classificationbox will make.
type PredictResponse ¶
type PredictResponse struct { // Classes contains the predictions. Classes []Class `json:"classes,omitempty"` }
PredictResponse contains prediction choices.