Documentation ¶
Index ¶
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 support this many variables") // ErrRegressionRun signals that the Run method has not been run yet. ErrRegressionRun = errors.New("regression has not run yet") )
Functions ¶
func MultiplierCross ¶
func MultiplierCross(vars ...int) featureCross
Feature cross based on the multiplication of multiple inputs.
Types ¶
type DataPoint ¶
type DataPoint struct { Observed float64 Variables []float64 Crosses []float64 Predicted float64 Error float64 }
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
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 { Data []DataPoint R2 float64 VarianceObserved float64 VariancePredicted float64 Ready bool // 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 ¶
func (r *Regression) GetCoeffs() []float64
GetCoeffs returns the calculated coefficients. The element at index 0 is the offset.
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) Train ¶
func (r *Regression) Train(d ...DataPoint)
Train the regression with some data points.