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 ¶
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") // ErrUnsupportedConverganceType is returned if unsupported convergance type was chosen. ErrUnsupportedConverganceType = errors.New("unsupported convergance type") // ErrInvalidTrainingSet is returned if features vectors included in the set are not consistent. ErrInvalidTrainingSet = errors.New("invalid training set") // ErrInvalidFeatureVector is returned if feature vector is invalid. ErrInvalidFeatureVector = errors.New("invalid feature vector") )
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model[T TargetType] interface { // Predict returns the predicated target value for the given input. Predict(x []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 succeded, otherwise returns an error. Run(s TrainingSet) (Model[T], error) }
A Regression is a regression runner. It provides an abstraction for model training.
type RegressionFunc ¶
type RegressionFunc[T TargetType] func(s 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(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 continous value of y, while integer corresponds to the discrete one.
type TrainingExample ¶
TrainingExample represents a single (features, target) example.
type TrainingSet ¶
type TrainingSet struct {
// contains filtered or unexported fields
}
TrainingSet represents set of traning examples.
func NewTrainingSet ¶
func NewTrainingSet(exs []TrainingExample) (*TrainingSet, error)
NewTrainingSet creates a new training set if examples are consistent. It doesn't check for correctness of values. If examples are not consistent, returns an error.
func (*TrainingSet) AddDummyFeatures ¶
func (s *TrainingSet) AddDummyFeatures()
AddDummyFeatures puts dummy feature (equals 1) for each training example being a part of the training set.
func (*TrainingSet) Examples ¶
func (s *TrainingSet) Examples() []TrainingExample
Examples returns all training examples from training set.
func (*TrainingSet) GetDesignMatrix ¶
func (s *TrainingSet) GetDesignMatrix() [][]float64
GetDesignMatrix returns the design matrix from the training set.
func (*TrainingSet) GetTargetVector ¶
func (s *TrainingSet) GetTargetVector() []float64
GetTargetVector returns the target vector from the training set.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
gd
Package gd provides gradient descent implementation.
|
Package gd provides gradient descent implementation. |
|
Package linear provides linear regression model implementation.
|
Package linear provides linear regression model implementation. |
|
Package options defines training options for specific regression variants.
|
Package options defines training options for specific regression variants. |