Documentation ¶
Index ¶
- Constants
- func Argmax(a mat.Vector) (int, int)
- func LinearDecisionFunction(x *mat.Dense, coef *mat.Dense, intercept *mat.VecDense) *mat.Dense
- func NewClassifierHandler(model *LinearClassifier) http.HandlerFunc
- func NewRegressorHandler(model *LinearRegressor) http.HandlerFunc
- func Softmax(x *mat.Dense) *mat.Dense
- func VecToArrayFloat64(v mat.Vector) []float64
- type Classifier
- type ClassifierResponse
- type LinearClassifier
- type LinearModel
- type LinearRegressor
- type Model
- type ModelError
- type ModelQuery
- type ProbabilisticClassifier
- type Regressor
- type RegressorResponse
- type Validator
Constants ¶
const (
// ErrorThreshold is used in tests as the default error expected between predicted and expected values.
ErrorThreshold = 0.00001
)
Variables ¶
This section is empty.
Functions ¶
func LinearDecisionFunction ¶
LinearDecisionFunction computes the decision function over the provided model and feature/s.
func NewClassifierHandler ¶
func NewClassifierHandler(model *LinearClassifier) http.HandlerFunc
NewClassifierHandler creates a handler for LinearClassifiers
func NewRegressorHandler ¶
func NewRegressorHandler(model *LinearRegressor) http.HandlerFunc
NewRegressorHandler creates a handler for LinearRegressors
func VecToArrayFloat64 ¶
VecToArrayFloat64 converts a vector into an array of floats.
Types ¶
type Classifier ¶
type ClassifierResponse ¶
type ClassifierResponse struct {
Response []int `json:"response"`
}
ModelResponse is the default response format from model queries.
type LinearClassifier ¶
type LinearClassifier struct {
// contains filtered or unexported fields
}
LinearClassifier model
func LoadClassifier ¶
func LoadClassifier(fileName string) (model *LinearClassifier)
func NewLinearClassifier ¶
func NewLinearClassifier(coef []float64, intercept []float64, nVars int) *LinearClassifier
NewLinearClassifier initializes a new Linear LinearClassifier model
func (*LinearClassifier) Predict ¶
func (m *LinearClassifier) Predict(x []float64) (c []int, err error)
// Predict the class for a single observation
func (*LinearClassifier) PredictProba ¶
func (m *LinearClassifier) PredictProba(x []float64) (p []float64, err error)
Predict the probability of classes for a single observation
type LinearModel ¶
func Load ¶
func Load(fileName string) (modelType string, model *LinearModel)
Load loads a linear model from a HDF5 file.
func NewLinearModel ¶
func NewLinearModel(coef []float64, intercept []float64, nVars int) *LinearModel
func (*LinearModel) DecisionFunction ¶
func (m *LinearModel) DecisionFunction(x []float64) (h *mat.Dense, err error)
func (*LinearModel) Validate ¶
func (m *LinearModel) Validate(x []float64) error
type LinearRegressor ¶
type LinearRegressor struct {
// contains filtered or unexported fields
}
LinearRegressor
func LoadRegressor ¶
func LoadRegressor(fileName string) (model *LinearRegressor)
func NewLinearRegressor ¶
func NewLinearRegressor(theta []float64, intercept []float64, nVars int) *LinearRegressor
NewLinearRegressor creates a new Linear Regression model.
type ModelError ¶
type ModelQuery ¶
type ModelQuery struct {
Features []float64 `json:"features"`
}
ModelResponse is the default query format for model requests.
type ProbabilisticClassifier ¶
type RegressorResponse ¶
type RegressorResponse struct {
Response []float64 `json:"response"`
}
ModelResponse is the default response format from model queries.