Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MAE ¶
func MAE(yPred dataframe.FloatAccess, yTrue dataframe.FloatAccess) float64
MAE returns the mean-absolute-error between two views on float vectors. mae = MEAN((|yPred - yTrue|)
func MSE ¶
func MSE(yPred dataframe.FloatAccess, yTrue dataframe.FloatAccess) float64
MSE returns the mean-squared-error between two views on float vectors. mse = MEAN((yPred - yTrue)^2)
Types ¶
type LinRegTrainParams ¶
type LinRegTrainParams struct { // Number of times the entire dataset iterated over. // The dataset is shuffled before each epoch. Epochs int // Learning rate per row (not per batch) used to update the weights. LR float64 // Size of the batch across which the gradients will be accumulated. BatchSize int // Weights *= (1 - decay) after each iteration. It plays a regularization role WeightDecay float64 // Gradient momentum. Gradients are initialized with PrevGradients * Momentum Momentum float64 // Allows the algorithm to make copies of the data to minimize cache-misses. LowMemory bool // Prints out information like training time and loss value. Verbose bool }
LinRegTrainParams contain hyper-parameters and other training options. Epochs, LR and BatchSize will be set to default values if they are left to 0.
type LinearRegressor ¶
type LinearRegressor struct { // json serializable TargetScaler *preprocessing.Scaler Weights []float64 Features []string }
LinearRegressor is a model that predicts a numerical target with a linear combination of the input features. LinearRegressor is serializable with json.
func NewLinearRegressor ¶
func NewLinearRegressor() *LinearRegressor
func (*LinearRegressor) Fit ¶
func (reg *LinearRegressor) Fit(df *dataframe.DataFrame, targetColumn string, params LinRegTrainParams) error
Fit trains a linear regressor on a dataframe that contains both the features and the numerical target, identified by the "targetColumn" argument. As of now, it always returns nil but it could return an error in future versions. You need not shuffle the dataset prior to calling this function.
func (*LinearRegressor) Predict ¶
func (reg *LinearRegressor) Predict(df *dataframe.DataFrame, resultColumn string) (*dataframe.DataFrame, error)
Predict predicts the target and stores the result in a new dataframe in a new float column identified by "resultColumn" argument. The new dataframe is a view on the original dataframe, so they share most data. As of now, it always returns nil alongside the result dataframe, but it could return an error in future versions. If resultColumn already exists, the previous data will be overwritten but it will not change the data in the original dataframe.