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

Abstract super class to encapsulate density estimation models working with multiple Grids. More...

#include <ModelFittingDensityEstimationCombi.hpp>

Inheritance diagram for sgpp::datadriven::ModelFittingDensityEstimationCombi:
sgpp::datadriven::ModelFittingDensityEstimation sgpp::datadriven::ModelFittingBaseSingleGrid sgpp::datadriven::ModelFittingBase

Public Member Functions

bool adapt () override
 Refines the component with the biggest error.
 
bool adapt (size_t newNoPoints, std::vector< size_t > &deletedGridPoints) override
 Currently not implemented for this class due to missing strategy for dimensional adaptive refinement.
 
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 density at a single data point - requires a trained grid.
 
void evaluate (DataMatrix &samples, DataVector &results) override
 Evaluate the fitted density on a set of data points - requires a trained grid.
 
void fit (DataMatrix &newDataset) override
 Fit the grids to the given dataset by determining the surpluses of the initial grid by the SGDE approach.
 
void fit (DataMatrix &newDatasetP, DataMatrix &newDatasetQ) override
 
void fit (Dataset &newDataset) override
 Fit the grids to the given dataset by determining the weights of the initial grid by the SGDE approach.
 
void fit (Dataset &newDatasetP, Dataset &newDatasetQ) override
 
 ModelFittingDensityEstimationCombi ()
 Default constructor.
 
 ModelFittingDensityEstimationCombi (const FitterConfigurationDensityEstimation &config)
 Constructor from a configuration object generated by the datamining pipeline.
 
 ModelFittingDensityEstimationCombi (const FitterConfigurationDensityEstimation &config, std::shared_ptr< DBMatObjectStore > objectStore)
 Construct from a configuration object generated from the datamining pipeline and a object store to obtain and store already decomposed offline objects.
 
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 (DataMatrix &samples) override
 Updates the model based on new data samples (streaming, batch learning).
 
void update (DataMatrix &samplesP, DataMatrix &samplesQ) override
 
void update (Dataset &dataset) override
 Train the grid of an existing model with new samples.
 
void update (Dataset &datasetP, Dataset &datasetQ) override
 
void updateRegularization (double lambda) override
 Updates the regularization parameter lambda of the underlying model.
 
- Public Member Functions inherited from sgpp::datadriven::ModelFittingDensityEstimation
 ModelFittingDensityEstimation ()
 Default constructor.
 
- 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.
 

Protected Member Functions

void addNewModel (const std::pair< std::vector< size_t >, int > combiconfig)
 
std::unique_ptr< ModelFittingDensityEstimationcreateNewModel (sgpp::datadriven::FitterConfigurationDensityEstimation &densityEstimationConfig)
 Creates a density estimation model that fits the model settings.
 
bool isRefinable () override
 Function that indicates whether a model is refinable at all (certain on/off settings do not allow for refinement)
 
void removeModel (size_t indexRev)
 
- Protected Member Functions inherited from sgpp::datadriven::ModelFittingDensityEstimation
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.
 
- 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

std::vector< std::pair< std::vector< size_t >, int > > componentConfigs
 Contains all level vector and weights of the current component grid set.
 
std::vector< std::unique_ptr< ModelFittingDensityEstimation > > components
 Contains the component grids witch form the sparse grids.
 
std::vector< bool > fitted
 Contains the status of the component grids.
 
bool hasObjectStore
 True if the instance has an object store.
 
std::shared_ptr< DBMatObjectStoreobjectStore
 The object store passed to component objects.
 
CombiScheme scheme
 Delivers the initial level vectors and weighs and manages refinements.
 
- Protected Attributes inherited from sgpp::datadriven::ModelFittingDensityEstimation
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 working with multiple Grids.

Constructor & Destructor Documentation

◆ ModelFittingDensityEstimationCombi() [1/3]

sgpp::datadriven::ModelFittingDensityEstimationCombi::ModelFittingDensityEstimationCombi ( )

Default constructor.

◆ ModelFittingDensityEstimationCombi() [2/3]

sgpp::datadriven::ModelFittingDensityEstimationCombi::ModelFittingDensityEstimationCombi ( const FitterConfigurationDensityEstimation config)
explicit

Constructor from a configuration object generated by the datamining pipeline.

Parameters
configconfiguration object generated by the datamining pipeline

References components, sgpp::datadriven::ModelFittingBase::config, fitted, hasObjectStore, objectStore, and sgpp::datadriven::DBMatOfflinePermutable::PermutableDecompositions.

◆ ModelFittingDensityEstimationCombi() [3/3]

sgpp::datadriven::ModelFittingDensityEstimationCombi::ModelFittingDensityEstimationCombi ( const FitterConfigurationDensityEstimation config,
std::shared_ptr< DBMatObjectStore objectStore 
)
explicit

Construct from a configuration object generated from the datamining pipeline and a object store to obtain and store already decomposed offline objects.

Parameters
configConfiguration object generated by the datamining pipeline.
objectStoreOffline object store.

References hasObjectStore, and objectStore.

Member Function Documentation

◆ adapt() [1/2]

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

◆ adapt() [2/2]

bool sgpp::datadriven::ModelFittingDensityEstimationCombi::adapt ( size_t  newNoPoints,
std::vector< size_t > &  deletedGridPoints 
)
overridevirtual

Currently not implemented for this class due to missing strategy for dimensional adaptive refinement.

Throws an application_exception.

Implements sgpp::datadriven::ModelFittingDensityEstimation.

◆ addNewModel()

void sgpp::datadriven::ModelFittingDensityEstimationCombi::addNewModel ( const std::pair< std::vector< size_t >, int >  combiconfig)
protected

◆ computeResidual()

double sgpp::datadriven::ModelFittingDensityEstimationCombi::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::ModelFittingDensityEstimation.

◆ createNewModel()

std::unique_ptr< ModelFittingDensityEstimation > sgpp::datadriven::ModelFittingDensityEstimationCombi::createNewModel ( sgpp::datadriven::FitterConfigurationDensityEstimation densityEstimationConfig)
protected

Creates a density estimation model that fits the model settings.

Parameters
densityEstimationConfigconfiguration for the density estimation
Returns
a new density estimation model

References sgpp::datadriven::CG, sgpp::datadriven::Decomposition, sgpp::datadriven::FitterConfiguration::getDensityEstimationConfig(), hasObjectStore, objectStore, and sgpp::datadriven::DensityEstimationConfiguration::type_.

Referenced by addNewModel(), and fit().

◆ evaluate() [1/2]

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

Evaluate the fitted density 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::ModelFittingDensityEstimation.

References componentConfigs, components, and fitted.

◆ evaluate() [2/2]

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

Evaluate the fitted density 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::ModelFittingDensityEstimation.

References sgpp::base::DataVector::add(), componentConfigs, components, fitted, and sgpp::base::DataVector::setAll().

◆ fit() [1/4]

◆ fit() [2/4]

void sgpp::datadriven::ModelFittingDensityEstimationCombi::fit ( DataMatrix newDatasetP,
DataMatrix newDatasetQ 
)
inlineoverridevirtual

◆ fit() [3/4]

void sgpp::datadriven::ModelFittingDensityEstimationCombi::fit ( Dataset newDataset)
overridevirtual

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

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

Implements sgpp::datadriven::ModelFittingDensityEstimation.

References sgpp::datadriven::ModelFittingBase::dataset, fit(), and sgpp::datadriven::Dataset::getData().

Referenced by fit(), update(), and update().

◆ fit() [4/4]

void sgpp::datadriven::ModelFittingDensityEstimationCombi::fit ( Dataset newDatasetP,
Dataset newDatasetQ 
)
inlineoverridevirtual

◆ isRefinable()

bool sgpp::datadriven::ModelFittingDensityEstimationCombi::isRefinable ( )
overrideprotectedvirtual

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

Implements sgpp::datadriven::ModelFittingDensityEstimation.

◆ removeModel()

void sgpp::datadriven::ModelFittingDensityEstimationCombi::removeModel ( size_t  indexRev)
protected
Parameters
indexRevthe reverse index (distance from the end of the vector) of the component that must be removed

References componentConfigs, components, and fitted.

Referenced by adapt().

◆ reset()

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

◆ resetTraining()

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

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

Implements sgpp::datadriven::ModelFittingDensityEstimation.

◆ update() [1/4]

void sgpp::datadriven::ModelFittingDensityEstimationCombi::update ( DataMatrix samples)
overridevirtual

Updates the model based on new data samples (streaming, batch learning).

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

Parameters
samplesthe new data samples

Implements sgpp::datadriven::ModelFittingDensityEstimation.

References components, fit(), fitted, and sgpp::datadriven::ModelFittingDensityEstimation::refinementsPerformed.

Referenced by python.uq.refinement.RefinementStrategy.Ranking::rank(), and python.learner.LearnedKnowledge.LearnedKnowledge::setMemento().

◆ update() [2/4]

void sgpp::datadriven::ModelFittingDensityEstimationCombi::update ( DataMatrix samplesP,
DataMatrix samplesQ 
)
inlineoverridevirtual

◆ update() [3/4]

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

◆ update() [4/4]

void sgpp::datadriven::ModelFittingDensityEstimationCombi::update ( Dataset datasetP,
Dataset datasetQ 
)
inlineoverridevirtual

◆ updateRegularization()

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

Updates the regularization parameter lambda of the underlying model.

Parameters
lambdathe new lambda parameter

Implements sgpp::datadriven::ModelFittingDensityEstimation.

Member Data Documentation

◆ componentConfigs

std::vector<std::pair<std::vector<size_t>, int> > sgpp::datadriven::ModelFittingDensityEstimationCombi::componentConfigs
protected

Contains all level vector and weights of the current component grid set.

Referenced by adapt(), addNewModel(), evaluate(), evaluate(), fit(), and removeModel().

◆ components

std::vector<std::unique_ptr<ModelFittingDensityEstimation> > sgpp::datadriven::ModelFittingDensityEstimationCombi::components
protected

Contains the component grids witch form the sparse grids.

Referenced by adapt(), addNewModel(), evaluate(), evaluate(), fit(), ModelFittingDensityEstimationCombi(), removeModel(), reset(), update(), and update().

◆ fitted

std::vector<bool> sgpp::datadriven::ModelFittingDensityEstimationCombi::fitted
protected

Contains the status of the component grids.

true: fitted false: unfitted

Referenced by addNewModel(), evaluate(), evaluate(), fit(), ModelFittingDensityEstimationCombi(), removeModel(), update(), and update().

◆ hasObjectStore

bool sgpp::datadriven::ModelFittingDensityEstimationCombi::hasObjectStore
protected

True if the instance has an object store.

Referenced by createNewModel(), ModelFittingDensityEstimationCombi(), and ModelFittingDensityEstimationCombi().

◆ objectStore

std::shared_ptr<DBMatObjectStore> sgpp::datadriven::ModelFittingDensityEstimationCombi::objectStore
protected

The object store passed to component objects.

Referenced by createNewModel(), ModelFittingDensityEstimationCombi(), and ModelFittingDensityEstimationCombi().

◆ scheme

CombiScheme sgpp::datadriven::ModelFittingDensityEstimationCombi::scheme
protected

Delivers the initial level vectors and weighs and manages refinements.

Referenced by adapt(), and fit().


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