shark::LinearRegression Class Reference

Linear Regression. More...

#include <shark/Algorithms/Trainers/LinearRegression.h>

+ Inheritance diagram for shark::LinearRegression:

Public Member Functions

SHARK_EXPORT_SYMBOL LinearRegression (double regularization=0.0)
 
std::string name () const
 From INameable: return the class name. More...
 
double regularization () const
 
void setRegularization (double regularization)
 
RealVector parameterVector () const
 Return the parameter vector. More...
 
void setParameterVector (const RealVector &param)
 Set the parameter vector. More...
 
size_t numberOfParameters () const
 Return the number of parameters. More...
 
SHARK_EXPORT_SYMBOL void train (LinearModel<> &model, LabeledData< RealVector, RealVector > const &dataset)
 
- Public Member Functions inherited from shark::AbstractTrainer< LinearModel<> >
virtual void train (ModelType &model, DatasetType const &dataset)=0
 Core of the Trainer interface. More...
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
- Public Member Functions inherited from shark::ISerializable
virtual ~ISerializable ()
 Virtual d'tor. More...
 
virtual void read (InArchive &archive)
 Read the component from the supplied archive. More...
 
virtual void write (OutArchive &archive) const
 Write the component to the supplied archive. More...
 
void load (InArchive &archive, unsigned int version)
 Versioned loading of components, calls read(...). More...
 
void save (OutArchive &archive, unsigned int version) const
 Versioned storing of components, calls write(...). More...
 
 BOOST_SERIALIZATION_SPLIT_MEMBER ()
 
- Public Member Functions inherited from shark::IParameterizable<>
virtual ~IParameterizable ()
 

Protected Attributes

double m_regularization
 

Additional Inherited Members

- Public Types inherited from shark::AbstractTrainer< LinearModel<> >
typedef LinearModel<> ModelType
 
typedef ModelType::InputType InputType
 
typedef typename LinearModel<> ::OutputType LabelType
 
typedef LabeledData< InputType, LabelTypeDatasetType
 
- Public Types inherited from shark::IParameterizable<>
typedef RealVector ParameterVectorType
 

Detailed Description

Linear Regression.

Linear Regression builds an affine linear model \( f(x) = A x + b \) minimizing the squared error from a dataset of pairs of vectors (x, y). That is, the error \( \sum_i (f(x_i) - y_i)^2 \) is minimized. The solution to this problem is found analytically.

Definition at line 61 of file LinearRegression.h.

Constructor & Destructor Documentation

◆ LinearRegression()

SHARK_EXPORT_SYMBOL shark::LinearRegression::LinearRegression ( double  regularization = 0.0)

Member Function Documentation

◆ name()

std::string shark::LinearRegression::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 67 of file LinearRegression.h.

◆ numberOfParameters()

size_t shark::LinearRegression::numberOfParameters ( ) const
inlinevirtual

Return the number of parameters.

Reimplemented from shark::IParameterizable<>.

Definition at line 87 of file LinearRegression.h.

References SHARK_EXPORT_SYMBOL, and train().

◆ parameterVector()

RealVector shark::LinearRegression::parameterVector ( ) const
inlinevirtual

Return the parameter vector.

Reimplemented from shark::IParameterizable<>.

Definition at line 78 of file LinearRegression.h.

References m_regularization.

◆ regularization()

double shark::LinearRegression::regularization ( ) const
inline

Definition at line 70 of file LinearRegression.h.

References m_regularization.

Referenced by setRegularization().

◆ setParameterVector()

void shark::LinearRegression::setParameterVector ( const RealVector &  newParameters)
inlinevirtual

Set the parameter vector.

Reimplemented from shark::IParameterizable<>.

Definition at line 83 of file LinearRegression.h.

References m_regularization, and SIZE_CHECK.

◆ setRegularization()

void shark::LinearRegression::setRegularization ( double  regularization)
inline

Definition at line 73 of file LinearRegression.h.

References m_regularization, RANGE_CHECK, and regularization().

◆ train()

SHARK_EXPORT_SYMBOL void shark::LinearRegression::train ( LinearModel<> &  model,
LabeledData< RealVector, RealVector > const &  dataset 
)

Referenced by main(), and numberOfParameters().

Member Data Documentation

◆ m_regularization

double shark::LinearRegression::m_regularization
protected

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