SG++-Doxygen-Documentation
Loading...
Searching...
No Matches
sgpp::datadriven::ModelFittingLeastSquares Class Reference

Fitter object that encapsulates the usage of sparse grid based regression with identity as regularization. More...

#include <ModelFittingLeastSquares.hpp>

Inheritance diagram for sgpp::datadriven::ModelFittingLeastSquares:
sgpp::datadriven::ModelFittingBaseSingleGrid sgpp::datadriven::ModelFittingBase

Public Member Functions

bool adapt () override
 Improve accuracy of the fit on the given training data by adaptive refinement of the grid and recalculate weights.
 
double computeResidual (DataMatrix &validationData) const override
 Should compute some kind of Residual to evaluate the fit of the model.
 
double evaluate (const DataVector &sample) override
 Evaluate the fitted regression model at a single data point - requires a trained grid.
 
void evaluate (DataMatrix &samples, DataVector &results) override
 Evaluate the fitted model on a set of data points - requires a trained grid.
 
void fit (Dataset &, Dataset &) override
 
void fit (Dataset &dataset) override
 Fit the grid to the given dataset by determining the weights of the initial grid by a least squares approach.
 
 ModelFittingLeastSquares (const FitterConfigurationLeastSquares &config)
 Constructor.
 
void reset () override
 Resets the state of the entire model.
 
void resetTraining () override
 Resets any trained representations of the model, but does not reset the entire state.
 
void update (Dataset &, Dataset &) override
 
void update (Dataset &dataset) override
 Train the grid of an existing model with new samples.
 
void updateRegularization (double lambda) override
 Updates the regularization parameter lambda of the underlying model.
 
- Public Member Functions inherited from sgpp::datadriven::ModelFittingBaseSingleGrid
GridgetGrid ()
 Get the underlying grid object for the current model.
 
DataVectorgetSurpluses ()
 Get the surpluses of the current grid.
 
 ModelFittingBaseSingleGrid ()
 Default constructor.
 
 ModelFittingBaseSingleGrid (const ModelFittingBaseSingleGrid &rhs)=delete
 Copy constructor - we cannot deep copy all member variables yet.
 
 ModelFittingBaseSingleGrid (ModelFittingBaseSingleGrid &&rhs)=default
 Move constructor.
 
ModelFittingBaseSingleGridoperator= (const ModelFittingBaseSingleGrid &rhs)=delete
 Copy assign operator - we cannot deep copy all member variables yet.
 
ModelFittingBaseSingleGridoperator= (ModelFittingBaseSingleGrid &&rhs)=default
 Move assign operator.
 
std::string storeFitter ()
 
virtual ~ModelFittingBaseSingleGrid ()=default
 virtual destructor.
 
- Public Member Functions inherited from sgpp::datadriven::ModelFittingBase
DatasetgetDataset ()
 
FitterConfigurationgetFitterConfiguration ()
 Get or set the configuration of the fitter object.
 
const FitterConfigurationgetFitterConfiguration () const
 Get the configuration of the fitter object.
 
virtual std::shared_ptr< BlacsProcessGridgetProcessGrid () const
 
 ModelFittingBase ()
 Default constructor.
 
 ModelFittingBase (const ModelFittingBase &rhs)=delete
 Copy constructor - we cannot deep copy all member variables yet.
 
 ModelFittingBase (ModelFittingBase &&rhs)=default
 Move constructor.
 
ModelFittingBaseoperator= (const ModelFittingBase &rhs)=delete
 Copy assign operator - we cannot deep copy all member variables yet.
 
ModelFittingBaseoperator= (ModelFittingBase &&rhs)=default
 Move assign operator.
 
virtual ~ModelFittingBase ()=default
 virtual destructor.
 

Additional Inherited Members

- Public Attributes inherited from sgpp::datadriven::ModelFittingBase
bool verboseSolver
 Whether the Solver produces output or not.
 
- Protected Member Functions inherited from sgpp::datadriven::ModelFittingBase
GridbuildGrid (const sgpp::base::GeneralGridConfiguration &gridConfig) const
 Factory member function that generates a grid from configuration.
 
GridbuildGrid (const sgpp::base::GeneralGridConfiguration &gridConfig, const GeometryConfiguration &geometryConfig) const
 Factory member function that generates a grid from configuration.
 
SLESolverbuildSolver (const SLESolverConfiguration &config) const
 Factory member function to build the solver for the least squares regression problem according to the config.
 
std::set< std::set< size_t > > getInteractions (const GeometryConfiguration &geometryConfig)
 
void reconfigureSolver (SLESolver &solver, const SLESolverConfiguration &config) const
 Configure solver based on the desired configuration.
 
- Protected Attributes inherited from sgpp::datadriven::ModelFittingBaseSingleGrid
DataVector alpha
 hierarchical surpluses of the grid.
 
std::unique_ptr< Gridgrid
 the sparse grid that approximates the data.
 
- Protected Attributes inherited from sgpp::datadriven::ModelFittingBase
std::unique_ptr< FitterConfigurationconfig
 Configuration object for the fitter.
 
Datasetdataset
 Pointer to sgpp::datadriven::Dataset.
 
DatasetextraDataset
 
std::unique_ptr< std::set< std::set< size_t > > > interactions
 
std::unique_ptr< SLESolversolver
 Solver for the learning problem.
 

Detailed Description

Fitter object that encapsulates the usage of sparse grid based regression with identity as regularization.

Allows usage of different grids, different solvers and different regularization techniques based on the provided configuration objects.

Constructor & Destructor Documentation

◆ ModelFittingLeastSquares()

sgpp::datadriven::ModelFittingLeastSquares::ModelFittingLeastSquares ( const FitterConfigurationLeastSquares config)
explicit

Member Function Documentation

◆ adapt()

bool sgpp::datadriven::ModelFittingLeastSquares::adapt ( )
overridevirtual

Improve accuracy of the fit on the given training data by adaptive refinement of the grid and recalculate weights.

Returns
true if refinement could be performed based on the refinement configuration, else false.

Implements sgpp::datadriven::ModelFittingBase.

References sgpp::datadriven::ModelFittingBaseSingleGrid::alpha, sgpp::datadriven::ModelFittingBase::config, sgpp::datadriven::GridFactory::getInteractions(), sgpp::datadriven::ModelFittingBaseSingleGrid::grid, sgpp::base::DataVector::resizeZero(), and sgpp::datadriven::GeometryConfiguration::stencils_.

◆ computeResidual()

double sgpp::datadriven::ModelFittingLeastSquares::computeResidual ( DataMatrix validationData) const
inlineoverridevirtual

Should compute some kind of Residual to evaluate the fit of the model.

In the case of density estimation, this is || R * alpha_lambda - b_val ||_2

This is useful for unsupervised learning models, where normal evaluation cannot be used as there are no targets.

Parameters
validationDataMatrix for validation data
Returns
the residual score

Implements sgpp::datadriven::ModelFittingBase.

◆ evaluate() [1/2]

double sgpp::datadriven::ModelFittingLeastSquares::evaluate ( const DataVector sample)
overridevirtual

Evaluate the fitted regression model at a single data point - requires a trained grid.

Parameters
samplevector with the coordinates in all dimensions of that sample.
Returns
evaluation of the trained grid.

Implements sgpp::datadriven::ModelFittingBase.

References sgpp::datadriven::ModelFittingBaseSingleGrid::alpha, sgpp::op_factory::createOperationEval(), sgpp::base::OperationEval::eval(), and sgpp::datadriven::ModelFittingBaseSingleGrid::grid.

◆ evaluate() [2/2]

void sgpp::datadriven::ModelFittingLeastSquares::evaluate ( DataMatrix samples,
DataVector results 
)
overridevirtual

Evaluate the fitted model on a set of data points - requires a trained grid.

Parameters
samplesmatrix where each row represents a sample and the columns contain the coordinates in all dimensions of that sample.
resultsvector where each row will contain the evaluation of the respective sample on the current model.

Implements sgpp::datadriven::ModelFittingBase.

References sgpp::datadriven::ModelFittingBaseSingleGrid::alpha, sgpp::datadriven::ModelFittingBase::config, sgpp::op_factory::createOperationMultipleEval(), sgpp::base::OperationMultipleEval::eval(), and sgpp::datadriven::ModelFittingBaseSingleGrid::grid.

◆ fit() [1/2]

void sgpp::datadriven::ModelFittingLeastSquares::fit ( Dataset ,
Dataset  
)
inlineoverridevirtual

◆ fit() [2/2]

void sgpp::datadriven::ModelFittingLeastSquares::fit ( Dataset dataset)
overridevirtual

Fit the grid to the given dataset by determining the weights of the initial grid by a least squares approach.

Parameters
datasetthe training dataset that is used to fit the model.

Implements sgpp::datadriven::ModelFittingBase.

References sgpp::datadriven::ModelFittingBaseSingleGrid::alpha, sgpp::datadriven::ModelFittingBase::buildGrid(), sgpp::datadriven::ModelFittingBase::config, sgpp::datadriven::ModelFittingBase::dataset, sgpp::datadriven::Dataset::getDimension(), sgpp::datadriven::ModelFittingBaseSingleGrid::grid, and reset().

Referenced by update().

◆ reset()

void sgpp::datadriven::ModelFittingLeastSquares::reset ( )
overridevirtual

Resets the state of the entire model.

Implements sgpp::datadriven::ModelFittingBase.

References sgpp::datadriven::ModelFittingBaseSingleGrid::grid.

Referenced by fit(), and update().

◆ resetTraining()

void sgpp::datadriven::ModelFittingLeastSquares::resetTraining ( )
inlineoverridevirtual

Resets any trained representations of the model, but does not reset the entire state.

Implements sgpp::datadriven::ModelFittingBase.

◆ update() [1/2]

void sgpp::datadriven::ModelFittingLeastSquares::update ( Dataset ,
Dataset  
)
inlineoverridevirtual

◆ update() [2/2]

void sgpp::datadriven::ModelFittingLeastSquares::update ( Dataset dataset)
overridevirtual

◆ updateRegularization()

void sgpp::datadriven::ModelFittingLeastSquares::updateRegularization ( double  lambda)
inlineoverridevirtual

Updates the regularization parameter lambda of the underlying model.

Parameters
lambdathe new lambda parameter

Implements sgpp::datadriven::ModelFittingBase.


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