SG++-Doxygen-Documentation
sgpp::datadriven::SparseGridDensityEstimator Class Reference

#include <SparseGridDensityEstimator.hpp>

Inheritance diagram for sgpp::datadriven::SparseGridDensityEstimator:
sgpp::datadriven::DensityEstimator

Public Member Functions

void cov (base::DataMatrix &cov, base::DataMatrix *bounds=nullptr) override
 Computes the covariance of the density function. More...
 
size_t getDim () override
 get number of dimensions More...
 
virtual base::GridgetGrid ()
 returns the grid More...
 
size_t getNsamples () override
 get number of samples More...
 
std::shared_ptr< base::DataVectorgetSamples (size_t dim) override
 returns the samples in the given dimension More...
 
std::shared_ptr< base::DataMatrixgetSamples () override
 returns the complete sample set More...
 
virtual base::DataVectorgetSurpluses ()
 returns the surpluses More...
 
virtual void initialize (base::DataMatrix &samples)
 Estimate a sparse grid density based on the given data set and the specified configurations. More...
 
virtual sgpp::datadriven::SparseGridDensityEstimatormarginalize (size_t idim)
 Marginalize the density in one dimension and return result. More...
 
virtual sgpp::datadriven::SparseGridDensityEstimatormargToDimX (size_t idim)
 Compute marginal density. More...
 
double mean () override
 This method computes the mean of the density function. More...
 
double pdf (base::DataVector &x) override
 This methods evaluates the sparse grid density at a single point. More...
 
void pdf (base::DataMatrix &points, base::DataVector &res) override
 Evaluation of the sparse grid density at a set of points. More...
 
 SparseGridDensityEstimator (sgpp::base::RegularGridConfiguration &gridConfig, sgpp::base::AdaptivityConfiguration &adaptivityConfig, sgpp::solver::SLESolverConfiguration &solverConfig, sgpp::datadriven::RegularizationConfiguration &regularizationConfig, CrossvalidationForRegularizationConfiguration &crossvalidationConfig, SGDEConfiguration &sgdeConfig)
 Constructor. More...
 
 SparseGridDensityEstimator (SparseGridDensityEstimatorConfiguration &learnerSGDEConfig)
 
 SparseGridDensityEstimator (base::Grid &grid, base::DataVector &alpha, base::DataMatrix &samples)
 construct learner from given grid and coefficients More...
 
 SparseGridDensityEstimator (const SparseGridDensityEstimator &learnerSGDE)
 
virtual void train (base::Grid &grid, base::DataVector &alpha, base::DataMatrix &train, double lambdaReg)
 Does the learning step on a given grid, training set and regularization parameter lambda. More...
 
double variance () override
 Computes the variance of the density function. More...
 
virtual ~SparseGridDensityEstimator ()
 
- Public Member Functions inherited from sgpp::datadriven::DensityEstimator
virtual void corrcoef (base::DataMatrix &corr, base::DataMatrix *bounds=nullptr)
 
double crossEntropy (sgpp::base::DataMatrix &samples)
 
 DensityEstimator ()
 
virtual double std_deviation ()
 
virtual ~DensityEstimator ()
 

Protected Member Functions

std::shared_ptr< datadriven::DensitySystemMatrixcomputeDensitySystemMatrix (base::Grid &grid, base::DataMatrix &train, double lambdaReg)
 generates the density system matrix More...
 
base::OperationMatrixcomputeLTwoDotProductMatrix (base::Grid &grid)
 generates the L^2 dot product matrix More...
 
base::OperationMultipleEvalcomputeMultipleEvalMatrix (base::Grid &grid, base::DataMatrix &train)
 generates the MultipleEval matrix More...
 
base::OperationMatrixcomputeRegularizationMatrix (base::Grid &grid)
 generates the regularization matrix More...
 
double computeResidual (base::Grid &grid, base::DataVector &alpha, base::DataMatrix &test, double lambdaReg)
 Compute the residual for a given test data set on a learned grid. More...
 
std::shared_ptr< base::GridcreateRegularGrid ()
 generates a regular grid More...
 
double mean (base::Grid &grid, base::DataVector &alpha)
 
double optimizeLambdaCV ()
 Does cross-validation to obtain a suitable regularization parameter. More...
 
void splitset (std::vector< std::shared_ptr< base::DataMatrix > > &strain, std::vector< std::shared_ptr< base::DataMatrix > > &stest)
 splits the complete sample set in a set of smaller training and test samples for cross-validation. More...
 
double variance (base::Grid &grid, base::DataVector &alpha)
 

Protected Attributes

sgpp::base::AdaptivityConfiguration adaptivityConfig
 
std::shared_ptr< base::DataVectoralpha
 
CrossvalidationForRegularizationConfiguration crossvalidationConfig
 
std::shared_ptr< base::Gridgrid
 
sgpp::base::RegularGridConfiguration gridConfig
 
sgpp::datadriven::RegularizationConfiguration regularizationConfig
 
std::shared_ptr< base::DataMatrixsamples
 
SGDEConfiguration sgdeConfig
 
sgpp::solver::SLESolverConfiguration solverConfig
 

Constructor & Destructor Documentation

◆ SparseGridDensityEstimator() [1/4]

sgpp::datadriven::SparseGridDensityEstimator::SparseGridDensityEstimator ( sgpp::base::RegularGridConfiguration gridConfig,
sgpp::base::AdaptivityConfiguration adaptivityConfig,
sgpp::solver::SLESolverConfiguration solverConfig,
sgpp::datadriven::RegularizationConfiguration regularizationConfig,
CrossvalidationForRegularizationConfiguration crossvalidationConfig,
SGDEConfiguration sgdeConfig 
)

Constructor.

Parameters
gridConfiggrid configuration
adaptivityConfigadaptive refinement configuration
solverConfigsolver configuration (CG)
regularizationConfigconfig for regularization operator
crossvalidationConfigconfiguration for the cross validation
sgdeConfigconfiguration for the sparse grid density estimation

Referenced by marginalize(), and margToDimX().

◆ SparseGridDensityEstimator() [2/4]

sgpp::datadriven::SparseGridDensityEstimator::SparseGridDensityEstimator ( SparseGridDensityEstimatorConfiguration learnerSGDEConfig)
explicit

◆ SparseGridDensityEstimator() [3/4]

sgpp::datadriven::SparseGridDensityEstimator::SparseGridDensityEstimator ( base::Grid grid,
base::DataVector alpha,
base::DataMatrix samples 
)

construct learner from given grid and coefficients

Parameters
grid
alpha
samples

References alpha, sgpp::base::Grid::clone(), and samples.

◆ SparseGridDensityEstimator() [4/4]

sgpp::datadriven::SparseGridDensityEstimator::SparseGridDensityEstimator ( const SparseGridDensityEstimator learnerSGDE)

◆ ~SparseGridDensityEstimator()

sgpp::datadriven::SparseGridDensityEstimator::~SparseGridDensityEstimator ( )
virtual

Member Function Documentation

◆ computeDensitySystemMatrix()

std::shared_ptr< datadriven::DensitySystemMatrix > sgpp::datadriven::SparseGridDensityEstimator::computeDensitySystemMatrix ( base::Grid grid,
base::DataMatrix train,
double  lambdaReg 
)
protected

generates the density system matrix

Parameters
gridgrid
traintrain
lambdaRegregularization parameter

References python.utils.pca_normalize_dataset::C, computeLTwoDotProductMatrix(), computeMultipleEvalMatrix(), computeRegularizationMatrix(), and sgpp::base::DataMatrix::getNrows().

Referenced by computeResidual(), and train().

◆ computeLTwoDotProductMatrix()

base::OperationMatrix * sgpp::datadriven::SparseGridDensityEstimator::computeLTwoDotProductMatrix ( base::Grid grid)
protected

generates the L^2 dot product matrix

Parameters
gridgrid

References sgpp::op_factory::createOperationLTwoDotProduct().

Referenced by computeDensitySystemMatrix().

◆ computeMultipleEvalMatrix()

◆ computeRegularizationMatrix()

◆ computeResidual()

double sgpp::datadriven::SparseGridDensityEstimator::computeResidual ( base::Grid grid,
base::DataVector alpha,
base::DataMatrix test,
double  lambdaReg 
)
protected

Compute the residual for a given test data set on a learned grid.

$|(A - lambda C) alpha - 1/n B|$

This is used as quality criterion for the estimated density.

Parameters
gridgrid
alphacoefficient vector
testtest set
lambdaRegregularization parameter
Returns

References computeDensitySystemMatrix(), sgpp::base::Grid::getSize(), and python.statsfileInfo::i.

Referenced by optimizeLambdaCV().

◆ cov()

void sgpp::datadriven::SparseGridDensityEstimator::cov ( base::DataMatrix cov,
base::DataMatrix bounds = nullptr 
)
overridevirtual

Computes the covariance of the density function.

Implements sgpp::datadriven::DensityEstimator.

References alpha, sgpp::op_factory::createOperationCovariance(), and grid.

◆ createRegularGrid()

std::shared_ptr< base::Grid > sgpp::datadriven::SparseGridDensityEstimator::createRegularGrid ( )
protected

generates a regular grid

Returns
grid

References sgpp::base::Grid::createGrid(), gridConfig, and sgpp::base::GeneralGridConfiguration::level_.

Referenced by initialize(), and optimizeLambdaCV().

◆ getDim()

size_t sgpp::datadriven::SparseGridDensityEstimator::getDim ( )
overridevirtual

◆ getGrid()

base::Grid & sgpp::datadriven::SparseGridDensityEstimator::getGrid ( )
virtual

returns the grid

References grid.

◆ getNsamples()

size_t sgpp::datadriven::SparseGridDensityEstimator::getNsamples ( )
overridevirtual

get number of samples

Implements sgpp::datadriven::DensityEstimator.

References samples.

Referenced by getSamples(), and optimizeLambdaCV().

◆ getSamples() [1/2]

std::shared_ptr< base::DataVector > sgpp::datadriven::SparseGridDensityEstimator::getSamples ( size_t  dim)
overridevirtual

returns the samples in the given dimension

Parameters
dim

Implements sgpp::datadriven::DensityEstimator.

References getNsamples(), and samples.

◆ getSamples() [2/2]

std::shared_ptr< base::DataMatrix > sgpp::datadriven::SparseGridDensityEstimator::getSamples ( )
overridevirtual

returns the complete sample set

Implements sgpp::datadriven::DensityEstimator.

References samples.

◆ getSurpluses()

base::DataVector & sgpp::datadriven::SparseGridDensityEstimator::getSurpluses ( )
virtual

returns the surpluses

References alpha.

◆ initialize()

◆ marginalize()

SparseGridDensityEstimator * sgpp::datadriven::SparseGridDensityEstimator::marginalize ( size_t  idim)
virtual

Marginalize the density in one dimension and return result.

Parameters
idimdimension which should be marginalized

References alpha, sgpp::op_factory::createOperationDensityMarginalize(), grid, samples, and SparseGridDensityEstimator().

◆ margToDimX()

SparseGridDensityEstimator * sgpp::datadriven::SparseGridDensityEstimator::margToDimX ( size_t  idim)
virtual

Compute marginal density.

Parameters
idimdimension which should be left after marginalization

References alpha, sgpp::op_factory::createOperationDensityMargTo1D(), grid, samples, and SparseGridDensityEstimator().

◆ mean() [1/2]

double sgpp::datadriven::SparseGridDensityEstimator::mean ( )
overridevirtual

◆ mean() [2/2]

◆ optimizeLambdaCV()

◆ pdf() [1/2]

double sgpp::datadriven::SparseGridDensityEstimator::pdf ( base::DataVector x)
overridevirtual

This methods evaluates the sparse grid density at a single point.

Parameters
xDataVector length equal to dimensionality

Implements sgpp::datadriven::DensityEstimator.

References alpha, sgpp::op_factory::createOperationEval(), and grid.

◆ pdf() [2/2]

void sgpp::datadriven::SparseGridDensityEstimator::pdf ( base::DataMatrix points,
base::DataVector res 
)
overridevirtual

Evaluation of the sparse grid density at a set of points.

Parameters
pointsDataMatrix (nrows = number of samples, ncols = dimensionality)
resDataVector (size = number of samples) where the results are stored

Implements sgpp::datadriven::DensityEstimator.

References alpha, sgpp::op_factory::createOperationMultipleEval(), and grid.

◆ splitset()

void sgpp::datadriven::SparseGridDensityEstimator::splitset ( std::vector< std::shared_ptr< base::DataMatrix > > &  strain,
std::vector< std::shared_ptr< base::DataMatrix > > &  stest 
)
protected

◆ train()

◆ variance() [1/2]

double sgpp::datadriven::SparseGridDensityEstimator::variance ( )
overridevirtual

Computes the variance of the density function.

Implements sgpp::datadriven::DensityEstimator.

References alpha, and grid.

◆ variance() [2/2]

double sgpp::datadriven::SparseGridDensityEstimator::variance ( base::Grid grid,
base::DataVector alpha 
)
protected

Member Data Documentation

◆ adaptivityConfig

sgpp::base::AdaptivityConfiguration sgpp::datadriven::SparseGridDensityEstimator::adaptivityConfig
protected

◆ alpha

◆ crossvalidationConfig

CrossvalidationForRegularizationConfiguration sgpp::datadriven::SparseGridDensityEstimator::crossvalidationConfig
protected

◆ grid

◆ gridConfig

sgpp::base::RegularGridConfiguration sgpp::datadriven::SparseGridDensityEstimator::gridConfig
protected

◆ regularizationConfig

sgpp::datadriven::RegularizationConfiguration sgpp::datadriven::SparseGridDensityEstimator::regularizationConfig
protected

◆ samples

std::shared_ptr<base::DataMatrix> sgpp::datadriven::SparseGridDensityEstimator::samples
protected

◆ sgdeConfig

SGDEConfiguration sgpp::datadriven::SparseGridDensityEstimator::sgdeConfig
protected

◆ solverConfig

sgpp::solver::SLESolverConfiguration sgpp::datadriven::SparseGridDensityEstimator::solverConfig
protected

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