Documentation ¶
Overview ¶
Package regression defines interfaces, structures and errors shared by other packages that implement a concrete regression algorithm.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCannotConverge is returned if gradient descent cannot converge. It usually means that the learning rate is too large. ErrCannotConverge = errors.New("cannot converge") // ErrUnsupportedGradientDescentVariant is returned if unsupported gradient descent variant was chosen. ErrUnsupportedGradientDescentVariant = errors.New("unsupported gradient descent variant") // ErrUnsupportedConvergenceType is returned if unsupported convergence type was chosen. ErrUnsupportedConvergenceType = errors.New("unsupported convergence type") // ErrInvalidTrainingSet is returned if a design matrix is invalid or doesn't have the same length as a target vector. ErrInvalidTrainingSet = errors.New("invalid training set") // ErrInvalidFeatureVector is returned if feature vector is invalid. ErrInvalidFeatureVector = errors.New("invalid feature vector") // ErrInvalidDesignMatrix is returned if a design matrix is invalid in a given context. ErrInvalidDesignMatrix = errors.New("invalid design matrix") )
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model[T TargetType] interface { // Predict returns the predicated target value for the given input. Predict([]float64) (T, error) // Coefficients returns the trained regression model's coefficients. Coefficients() []float64 // Accuracy returns calculated accuracy for trained model. Accuracy() float64 }
A Model is a trained regression model.
type Regression ¶
type Regression[T TargetType] interface { // Run runs regression against input training set. // It returns trained Model if succeeded, otherwise returns an error. Run(context.Context, TrainingSet) (Model[T], error) }
A Regression is a regression runner. It provides an abstraction for model training.
type RegressionFunc ¶
type RegressionFunc[T TargetType] func(context.Context, TrainingSet) (Model[T], error)
RegressionFunc is an adapter to allow the use of plain functions as regressions.
func (RegressionFunc[T]) Run ¶
func (f RegressionFunc[T]) Run(ctx context.Context, s TrainingSet) (Model[T], error)
Run calls f(s).
type TargetType ¶
TargetType is a constraint that permits two types (float64 or integer) for target value. Floating point numbers are used for continuous value of y, while integer corresponds to the discrete one.
type TrainingSet ¶
type TrainingSet struct { // X is a design matrix. X [][]float64 // Y is a target vector. Y []float64 }
TrainingSet represents a set of traning examples.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
gd
Package gd provides gradient descent implementation.
|
Package gd provides gradient descent implementation. |
long
Package long provides wrapper for running long operation.
|
Package long provides wrapper for running long operation. |
matrix
Package matrix contains the implementation of matrix calculus related to the regression algorithms.
|
Package matrix contains the implementation of matrix calculus related to the regression algorithms. |
ts
Package ts contains implementation of the operations related to a training set.
|
Package ts contains implementation of the operations related to a training set. |
Package linear provides linear regression model implementation.
|
Package linear provides linear regression model implementation. |
Package logistic provides linear regression model implementation.
|
Package logistic provides linear regression model implementation. |
Package options contains implementation of types and constants related to the regression options.
|
Package options contains implementation of types and constants related to the regression options. |
Package scaling contains implementation of feature scaling.
|
Package scaling contains implementation of feature scaling. |
Click to show internal directories.
Click to hide internal directories.