SG++-Doxygen-Documentation
Loading...
Searching...
No Matches
sgpp::datadriven::ModelFittingDensityEstimation Class Referenceabstract

Abstract super class to encapsulate density estimation models such as using offline/-online splitting or conjugate gradients in order to solve the system. More...

#include <ModelFittingDensityEstimation.hpp>

Inheritance diagram for sgpp::datadriven::ModelFittingDensityEstimation:
sgpp::datadriven::ModelFittingBaseSingleGrid sgpp::datadriven::ModelFittingBase sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff sgpp::datadriven::ModelFittingDensityEstimationCG sgpp::datadriven::ModelFittingDensityEstimationCombi sgpp::datadriven::ModelFittingDensityEstimationOnOff sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel

Public Member Functions

bool adapt () override
 Improve accuracy of the fit on the given training data by adaptive refinement or coarsening of the grid and recalculate weights.
 
virtual bool adapt (size_t newNoPoints, std::vector< size_t > &deletedGridPoints)=0
 Performs refinement and coarsening given the new grid size and the points to coarsened.
 
double computeResidual (DataMatrix &validationData) const override=0
 Computes a residual to evaluate the fit of the model.
 
double evaluate (const DataVector &sample) override=0
 Evaluate the fitted model at a single data point.
 
void evaluate (DataMatrix &samples, DataVector &results) override=0
 Evaluate the fitted model on a set of data points.
 
virtual void fit (DataMatrix &dataset)=0
 Fit the grid to the given dataset by determining the surpluses of the initial grid by the SGDE approach.
 
virtual void fit (DataMatrix &datasetP, DataMatrix &datasetQ)=0
 
void fit (Dataset &dataset) override=0
 Fit the grid to the dataset by determining the weights of an initial grid.
 
void fit (Dataset &datasetP, Dataset &datasetQ) override=0
 
 ModelFittingDensityEstimation ()
 Default constructor.
 
void resetTraining () override=0
 Resets any trained representations of the model, but does not reset the entire state.
 
virtual void update (DataMatrix &samples)=0
 Updates the model based on new data samples (streaming, batch learning).
 
virtual void update (DataMatrix &samplesP, DataMatrix &samplesQ)=0
 
void update (Dataset &dataset) override=0
 Train the grid of an existing model with new samples.
 
void update (Dataset &datasetP, Dataset &datasetQ) override=0
 
void updateRegularization (double lambda) override=0
 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 void reset ()=0
 Resets the state of the entire model.
 
virtual ~ModelFittingBase ()=default
 virtual destructor.
 

Protected Member Functions

std::unique_ptr< sgpp::base::CoarseningFunctorgetCoarseningFunctor ()
 Returns the refinement functor suitable for the model settings.
 
std::unique_ptr< sgpp::base::RefinementFunctorgetRefinementFunctor ()
 Returns the refinement functor suitable for the model settings.
 
virtual bool isRefinable ()=0
 Function that indicates whether a model is refinable at all (certain on/off settings do not allow for refinement)
 
- 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

size_t initialGridSize
 Initial number of grid points.
 
size_t refinementsPerformed
 Count the amount of refinement operations performed on the current dataset.
 
- 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.
 

Additional Inherited Members

- Public Attributes inherited from sgpp::datadriven::ModelFittingBase
bool verboseSolver
 Whether the Solver produces output or not.
 

Detailed Description

Abstract super class to encapsulate density estimation models such as using offline/-online splitting or conjugate gradients in order to solve the system.

Constructor & Destructor Documentation

◆ ModelFittingDensityEstimation()

sgpp::datadriven::ModelFittingDensityEstimation::ModelFittingDensityEstimation ( )

Default constructor.

Member Function Documentation

◆ adapt() [1/2]

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

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

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

Implements sgpp::datadriven::ModelFittingBase.

Reimplemented in sgpp::datadriven::ModelFittingDensityEstimationCombi.

References adapt(), sgpp::datadriven::ModelFittingBase::config, getCoarseningFunctor(), sgpp::datadriven::GridFactory::getInteractions(), getRefinementFunctor(), sgpp::datadriven::ModelFittingBaseSingleGrid::grid, initialGridSize, isRefinable(), refinementsPerformed, and sgpp::datadriven::GeometryConfiguration::stencils_.

Referenced by adapt().

◆ adapt() [2/2]

virtual bool sgpp::datadriven::ModelFittingDensityEstimation::adapt ( size_t  newNoPoints,
std::vector< size_t > &  deletedGridPoints 
)
pure virtual

Performs refinement and coarsening given the new grid size and the points to coarsened.

Parameters
newNoPointsthe grid size after refinement and coarsening
deletedGridPointsa list of indexes for grid points that will be removed
Returns
if the grid was refined (true)

Implemented in sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, and sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel.

◆ computeResidual()

double sgpp::datadriven::ModelFittingDensityEstimation::computeResidual ( DataMatrix validationData) const
overridepure virtual

Computes a residual to evaluate the fit of the model.

This is useful for density estimation, because other Scores cannot be used as there are no targets.

Parameters
validationDataMatrix for validation data

Implements sgpp::datadriven::ModelFittingBase.

Implemented in sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, and sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel.

◆ evaluate() [1/2]

double sgpp::datadriven::ModelFittingDensityEstimation::evaluate ( const DataVector sample)
overridepure virtual

◆ evaluate() [2/2]

void sgpp::datadriven::ModelFittingDensityEstimation::evaluate ( DataMatrix samples,
DataVector results 
)
overridepure virtual

Evaluate the fitted model on a set of data points.

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.

Implemented in sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, and sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel.

◆ fit() [1/4]

virtual void sgpp::datadriven::ModelFittingDensityEstimation::fit ( DataMatrix dataset)
pure virtual

Fit the grid to the given dataset by determining the surpluses of the initial grid by the SGDE approach.

Requires only data samples and no targets (since those are irrelevant for the density estimation whatsoever)

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

Implemented in sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, and sgpp::datadriven::ModelFittingDensityEstimationCombi.

◆ fit() [2/4]

◆ fit() [3/4]

void sgpp::datadriven::ModelFittingDensityEstimation::fit ( Dataset dataset)
overridepure virtual

◆ fit() [4/4]

◆ getCoarseningFunctor()

std::unique_ptr< CoarseningFunctor > sgpp::datadriven::ModelFittingDensityEstimation::getCoarseningFunctor ( )
protected

Returns the refinement functor suitable for the model settings.

Returns
pointer to a coarsening functor that suits the model settings

References adaptivityConfig, sgpp::datadriven::ModelFittingBaseSingleGrid::alpha, sgpp::base::AdaptivityConfiguration::coarseningFunctorType_, and sgpp::datadriven::ModelFittingBase::config.

Referenced by adapt().

◆ getRefinementFunctor()

std::unique_ptr< RefinementFunctor > sgpp::datadriven::ModelFittingDensityEstimation::getRefinementFunctor ( )
protected

Returns the refinement functor suitable for the model settings.

Returns
pointer to a refinement functor that suits the model settings

References sgpp::datadriven::ModelFittingBaseSingleGrid::alpha, sgpp::datadriven::ModelFittingBase::config, and sgpp::base::AdaptivityConfiguration::refinementFunctorType_.

Referenced by adapt().

◆ isRefinable()

virtual bool sgpp::datadriven::ModelFittingDensityEstimation::isRefinable ( )
protectedpure virtual

Function that indicates whether a model is refinable at all (certain on/off settings do not allow for refinement)

Returns
whether the model is refinable

Implemented in sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, and sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel.

Referenced by adapt().

◆ resetTraining()

void sgpp::datadriven::ModelFittingDensityEstimation::resetTraining ( )
overridepure virtual

◆ update() [1/4]

virtual void sgpp::datadriven::ModelFittingDensityEstimation::update ( DataMatrix samples)
pure virtual

◆ update() [2/4]

◆ update() [3/4]

◆ update() [4/4]

◆ updateRegularization()

void sgpp::datadriven::ModelFittingDensityEstimation::updateRegularization ( double  lambda)
overridepure virtual

Member Data Documentation

◆ initialGridSize

size_t sgpp::datadriven::ModelFittingDensityEstimation::initialGridSize
protected

Initial number of grid points.

Referenced by adapt().

◆ refinementsPerformed


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