Documentation ¶
Index ¶
- Variables
- func DataPoint(obs float64, vars []float64) *dataPoint
- func MakeDataPoints(a [][]float64, obsIndex int) []*dataPoint
- func MultiplierCross(vars ...int) featureCross
- func PowCross(i int, power float64) featureCross
- type DataPoints
- type Regression
- func (r *Regression) AddCross(cross featureCross)
- func (r *Regression) Coeff(i int) float64
- func (r *Regression) GetCoeffs() []float64
- func (r *Regression) GetObserved() string
- func (r *Regression) GetVar(i int) string
- func (r *Regression) Predict(vars []float64) (float64, error)
- func (r *Regression) Run() error
- func (r *Regression) SetObserved(name string)
- func (r *Regression) SetVar(i int, name string)
- func (r *Regression) String() string
- func (r *Regression) Train(d ...*dataPoint)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotEnoughData signals that there weren't enough datapoint to train the model. ErrNotEnoughData = errors.New("not enough data points") // ErrTooManyVars signals that there are too many variables for the number of observations being made. ErrTooManyVars = errors.New("not enough observations to to support this many variables") // ErrRegressionRun signals that the Run method has already been called on the trained dataset. ErrRegressionRun = errors.New("regression has already been run") )
Functions ¶
func MakeDataPoints ¶
MakeDataPoints makes a `[]*dataPoint` from a `[][]float64`. The expected fomat for the input is a row-major [][]float64. That is to say the first slice represents a row, and the second represents the cols. Furthermore it is expected that all the col slices are of the same length. The obsIndex parameter indicates which column should be used
func MultiplierCross ¶
func MultiplierCross(vars ...int) featureCross
Feature cross based on the multiplication of multiple inputs.
Types ¶
type DataPoints ¶
type DataPoints []*dataPoint
DataPoints is a slice of *dataPoint This type allows for easier construction of training data points.
type Regression ¶
type Regression struct { R2 float64 Varianceobserved float64 VariancePredicted float64 Formula string // contains filtered or unexported fields }
Regression is the exposed data structure for interacting with the API.
func (*Regression) AddCross ¶
func (r *Regression) AddCross(cross featureCross)
AddCross registers a feature cross to be applied to the data points.
func (*Regression) Coeff ¶
func (r *Regression) Coeff(i int) float64
Coeff returns the calculated coefficient for variable i.
func (*Regression) GetCoeffs ¶ added in v1.0.1
func (r *Regression) GetCoeffs() []float64
GetCoeffs returns the calculated coefficients. The element at index 0 is the offset.
func (*Regression) GetObserved ¶
func (r *Regression) GetObserved() string
GetObserved gets the name of the observed value.
func (*Regression) GetVar ¶
func (r *Regression) GetVar(i int) string
GetVar gets the name of variable i
func (*Regression) Predict ¶
func (r *Regression) Predict(vars []float64) (float64, error)
Predict updates the "Predicted" value for the inputed features.
func (*Regression) Run ¶
func (r *Regression) Run() error
Run determines if there is enough data present to run the regression and whether or not the training has already been completed. Once the above checks have passed feature crosses are applied if any and the model is trained using QR decomposition.
func (*Regression) SetObserved ¶
func (r *Regression) SetObserved(name string)
SetObserved sets the name of the observed value.
func (*Regression) SetVar ¶
func (r *Regression) SetVar(i int, name string)
SetVar sets the name of variable i.
func (*Regression) String ¶
func (r *Regression) String() string
String satisfies the stringer interface to display a regression as a string.
func (*Regression) Train ¶
func (r *Regression) Train(d ...*dataPoint)
Train the regression with some data points.