liba 0.1.15
An algorithm library based on C/C++
 
Loading...
Searching...
No Matches
linear regression
Collaboration diagram for linear regression:

Data Structures

struct  a_regress_linear
 instance structure for linear regression More...
 

Typedefs

typedef struct a_regress_linear a_regress_linear
 

Functions

void a_regress_linear_init (a_regress_linear *ctx, a_float *coef_p, a_size coef_n, a_float bias)
 initialize for linear regression
 
a_float a_regress_linear_eval (a_regress_linear const *ctx, a_float const *val)
 calculate predicted value for linear regression
 
void a_regress_linear_err (a_regress_linear const *ctx, a_size n, a_float const *x, a_float const *y, a_float *err)
 calculate residuals for linear regression
 
void a_regress_linear_pdm (a_regress_linear const *ctx, a_size n, a_float const *x, a_float *pdm, a_float y_mean)
 calculate prediction deviation from mean for linear regression
 
void a_regress_linear_gd (a_regress_linear *ctx, a_float const *input, a_float error, a_float alpha)
 gradient descent for linear regression
 
void a_regress_linear_sgd (a_regress_linear *ctx, a_size n, a_float const *x, a_float const *y, a_float alpha)
 stochastic gradient descent for linear regression
 
void a_regress_linear_bgd (a_regress_linear *ctx, a_size n, a_float const *x, a_float const *err, a_float alpha)
 batch gradient descent for linear regression
 
a_float a_regress_linear_mgd (a_regress_linear *ctx, a_size n, a_float const *x, a_float const *y, a_float *err, a_float delta, a_float lrmax, a_float lrmin, a_size lrtim, a_size epoch, a_size batch)
 mini-batch gradient descent for linear regression
 
void a_regress_linear_zero (a_regress_linear *ctx)
 zeroing for linear regression
 

Detailed Description

Function Documentation

◆ a_regress_linear_bgd()

void a_regress_linear_bgd ( a_regress_linear * ctx,
a_size n,
a_float const * x,
a_float const * err,
a_float alpha )

batch gradient descent for linear regression

Parameters
[in,out]ctxpoints to an instance of linear regression
[in]nnumber of samples, x[n*coef_n], err[n]
[in]xpredictor data, specified as a numeric matrix
[in]errresiduals, specified as a numeric vector
[in]alphalearning rate for gradient descent

◆ a_regress_linear_err()

void a_regress_linear_err ( a_regress_linear const * ctx,
a_size n,
a_float const * x,
a_float const * y,
a_float * err )

calculate residuals for linear regression

Parameters
[in]ctxpoints to an instance of linear regression
[in]nnumber of samples, x[n*coef_n], y[n], err[n]
[in]xpredictor data, specified as a numeric matrix
[in]yresponse data, specified as a numeric vector
[in,out]errresiduals, specified as a numeric vector

◆ a_regress_linear_eval()

a_float a_regress_linear_eval ( a_regress_linear const * ctx,
a_float const * val )

calculate predicted value for linear regression

Parameters
[in]ctxpoints to an instance of linear regression
[in]valindependent variables
Returns
predicted value

◆ a_regress_linear_gd()

void a_regress_linear_gd ( a_regress_linear * ctx,
a_float const * input,
a_float error,
a_float alpha )

gradient descent for linear regression

Parameters
[in,out]ctxpoints to an instance of linear regression
[in]inputpredictor data, specified as a numeric vector
[in]errorresidual, specified as a numeric scalar
[in]alphalearning rate for gradient descent

◆ a_regress_linear_init()

void a_regress_linear_init ( a_regress_linear * ctx,
a_float * coef_p,
a_size coef_n,
a_float bias )

initialize for linear regression

Parameters
[in,out]ctxpoints to an instance of linear regression
[in]coef_ppoints to regression coefficients
[in]coef_nnumber of regression coefficients
[in]biasintercept

◆ a_regress_linear_mgd()

a_float a_regress_linear_mgd ( a_regress_linear * ctx,
a_size n,
a_float const * x,
a_float const * y,
a_float * err,
a_float delta,
a_float lrmax,
a_float lrmin,
a_size lrtim,
a_size epoch,
a_size batch )

mini-batch gradient descent for linear regression

Parameters
[in,out]ctxpoints to an instance of linear regression
[in]nnumber of samples, x[n*coef_n], y[n], err[n]
[in]xpredictor data, specified as a numeric matrix
[in]yresponse data, specified as a numeric vector
[in,out]errresiduals, specified as a numeric vector
[in]deltathreshold for gradient descent value
[in]lrmaxmaximum learning rate of iterations
[in]lrminminimum learning rate of iterations
[in]lrtimtotal number of learning rate steps
[in]epochmaximum number of epochs
[in]batchbatch size of data
Returns
change in loss function

◆ a_regress_linear_pdm()

void a_regress_linear_pdm ( a_regress_linear const * ctx,
a_size n,
a_float const * x,
a_float * pdm,
a_float y_mean )

calculate prediction deviation from mean for linear regression

Parameters
[in]ctxpoints to an instance of linear regression
[in]nnumber of samples, x[n*coef_n], pdm[n]
[in]xpredictor data, specified as a numeric matrix
[in,out]pdmdeviation, specified as a numeric vector
[in]y_meanmean of response data

◆ a_regress_linear_sgd()

void a_regress_linear_sgd ( a_regress_linear * ctx,
a_size n,
a_float const * x,
a_float const * y,
a_float alpha )

stochastic gradient descent for linear regression

Parameters
[in,out]ctxpoints to an instance of linear regression
[in]nnumber of samples, x[n*coef_n], y[n]
[in]xpredictor data, specified as a numeric matrix
[in]yresponse data, specified as a numeric vector
[in]alphalearning rate for gradient descent

◆ a_regress_linear_zero()

void a_regress_linear_zero ( a_regress_linear * ctx)

zeroing for linear regression

Parameters
[in,out]ctxpoints to an instance of linear regression