PlusML
Loading...
Searching...
No Matches
Public Member Functions | List of all members
plusml::LinearRegression Class Reference

Basic linear regression class. More...

#include <linear_regression.h>

Public Member Functions

 LinearRegression (uint64_t features, bool bias_enabled=true)
 Constructor for LinearRegression class.
 
uint64_t Features () const
 Get number of features in each sample for the model.
 
Eigen::MatrixXf Parameters () const
 Get current parameters of the model.
 
void SetParameters (const Eigen::MatrixXf &parameters)
 Set desired parameters for the model.
 
void FitSGD (const Eigen::MatrixXf &samples, const Eigen::MatrixXf &targets, const LossGradient &grad, float learning_rate, uint64_t batch_size, uint64_t epochs)
 Fit model using stochastic gradient descent with given hyperparameters.
 
Eigen::MatrixXf Predict (Eigen::MatrixXf samples)
 Get predictions for a given matrix of samples.
 

Detailed Description

Basic linear regression class.

Constructor & Destructor Documentation

◆ LinearRegression()

plusml::LinearRegression::LinearRegression ( uint64_t features,
bool bias_enabled = true )
explicit

Constructor for LinearRegression class.

Parameters
featuresNumber of features in each sample
bias_enabledSpecifies whether to use bias or not

Initializes model's parameters to zero

Member Function Documentation

◆ Features()

uint64_t plusml::LinearRegression::Features ( ) const

Get number of features in each sample for the model.

Returns
Number of features in each sample for the model

◆ FitSGD()

void plusml::LinearRegression::FitSGD ( const Eigen::MatrixXf & samples,
const Eigen::MatrixXf & targets,
const LossGradient & grad,
float learning_rate,
uint64_t batch_size,
uint64_t epochs )

Fit model using stochastic gradient descent with given hyperparameters.

Parameters
samplesMatrix of samples (MxN where M is number of samples and N is number of features in each sample)
targetsMatrix of targets (Mx1 where M is number of samples)
gradClass representing a gradient calculation technique (a derived from the LossGradient base class)
learning_rateLearning rate for SGD
batch_sizeBatch size for SGD
epochsNumber of epochs for SGD

◆ Parameters()

Eigen::MatrixXf plusml::LinearRegression::Parameters ( ) const

Get current parameters of the model.

Returns
Parameters matrix

◆ Predict()

Eigen::MatrixXf plusml::LinearRegression::Predict ( Eigen::MatrixXf samples)

Get predictions for a given matrix of samples.

Parameters
samplesMatrix of samples (MxN where M is number of samples and N is number of features in each sample)
Returns
Matrix of predicted values (Mx1 where M is number of samples)

◆ SetParameters()

void plusml::LinearRegression::SetParameters ( const Eigen::MatrixXf & parameters)

Set desired parameters for the model.

Parameters
parametersMatrix representing parameters to set

The documentation for this class was generated from the following files: