SG++-Doxygen-Documentation
|
#include <SparseGridDensityEstimator.hpp>
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::Grid & | getGrid () |
returns the grid More... | |
size_t | getNsamples () override |
get number of samples More... | |
std::shared_ptr< base::DataVector > | getSamples (size_t dim) override |
returns the samples in the given dimension More... | |
std::shared_ptr< base::DataMatrix > | getSamples () override |
returns the complete sample set More... | |
virtual base::DataVector & | getSurpluses () |
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::SparseGridDensityEstimator * | marginalize (size_t idim) |
Marginalize the density in one dimension and return result. More... | |
virtual sgpp::datadriven::SparseGridDensityEstimator * | margToDimX (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 ®ularizationConfig, 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::DensitySystemMatrix > | computeDensitySystemMatrix (base::Grid &grid, base::DataMatrix &train, double lambdaReg) |
generates the density system matrix More... | |
base::OperationMatrix * | computeLTwoDotProductMatrix (base::Grid &grid) |
generates the L^2 dot product matrix More... | |
base::OperationMultipleEval * | computeMultipleEvalMatrix (base::Grid &grid, base::DataMatrix &train) |
generates the MultipleEval matrix More... | |
base::OperationMatrix * | computeRegularizationMatrix (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::Grid > | createRegularGrid () |
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::DataVector > | alpha |
CrossvalidationForRegularizationConfiguration | crossvalidationConfig |
std::shared_ptr< base::Grid > | grid |
sgpp::base::RegularGridConfiguration | gridConfig |
sgpp::datadriven::RegularizationConfiguration | regularizationConfig |
std::shared_ptr< base::DataMatrix > | samples |
SGDEConfiguration | sgdeConfig |
sgpp::solver::SLESolverConfiguration | solverConfig |
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.
gridConfig | grid configuration |
adaptivityConfig | adaptive refinement configuration |
solverConfig | solver configuration (CG) |
regularizationConfig | config for regularization operator |
crossvalidationConfig | configuration for the cross validation |
sgdeConfig | configuration for the sparse grid density estimation |
Referenced by marginalize(), and margToDimX().
|
explicit |
sgpp::datadriven::SparseGridDensityEstimator::SparseGridDensityEstimator | ( | base::Grid & | grid, |
base::DataVector & | alpha, | ||
base::DataMatrix & | samples | ||
) |
construct learner from given grid and coefficients
grid | |
alpha | |
samples |
References alpha, sgpp::base::Grid::clone(), and samples.
sgpp::datadriven::SparseGridDensityEstimator::SparseGridDensityEstimator | ( | const SparseGridDensityEstimator & | learnerSGDE | ) |
References adaptivityConfig, alpha, crossvalidationConfig, grid, gridConfig, regularizationConfig, samples, sgdeConfig, and solverConfig.
|
virtual |
|
protected |
generates the density system matrix
grid | grid |
train | train |
lambdaReg | regularization parameter |
References python.utils.pca_normalize_dataset::C, computeLTwoDotProductMatrix(), computeMultipleEvalMatrix(), computeRegularizationMatrix(), and sgpp::base::DataMatrix::getNrows().
Referenced by computeResidual(), and train().
|
protected |
generates the L^2 dot product matrix
grid | grid |
References sgpp::op_factory::createOperationLTwoDotProduct().
Referenced by computeDensitySystemMatrix().
|
protected |
generates the MultipleEval matrix
grid | grid |
train | training data |
References sgpp::base::Bspline, sgpp::base::BsplineBoundary, sgpp::base::BsplineClenshawCurtis, sgpp::op_factory::createOperationMultipleEval(), sgpp::op_factory::createOperationMultipleEvalNaive(), sgpp::base::Grid::getType(), sgpp::base::ModBspline, sgpp::base::ModBsplineClenshawCurtis, sgpp::base::ModPolyClenshawCurtis, sgpp::base::PolyClenshawCurtis, and sgpp::base::PolyClenshawCurtisBoundary.
Referenced by computeDensitySystemMatrix().
|
protected |
generates the regularization matrix
grid | grid |
References python.utils.pca_normalize_dataset::C, sgpp::op_factory::createOperationIdentity(), sgpp::op_factory::createOperationLaplace(), sgpp::datadriven::Identity, sgpp::datadriven::Laplace, regularizationConfig, and sgpp::datadriven::RegularizationConfiguration::type_.
Referenced by computeDensitySystemMatrix().
|
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.
grid | grid |
alpha | coefficient vector |
test | test set |
lambdaReg | regularization parameter |
References computeDensitySystemMatrix(), sgpp::base::Grid::getSize(), and python.statsfileInfo::i.
Referenced by optimizeLambdaCV().
|
overridevirtual |
Computes the covariance of the density function.
Implements sgpp::datadriven::DensityEstimator.
References alpha, sgpp::op_factory::createOperationCovariance(), and grid.
|
protected |
generates a regular grid
References sgpp::base::Grid::createGrid(), gridConfig, and sgpp::base::GeneralGridConfiguration::level_.
Referenced by initialize(), and optimizeLambdaCV().
|
overridevirtual |
get number of dimensions
Implements sgpp::datadriven::DensityEstimator.
References sgpp::base::GeneralGridConfiguration::dim_, and gridConfig.
Referenced by python.uq.dists.SGDEdist.SGDEdist::__str__(), and python.uq.dists.KDEDist.KDEDist::getBandwidths().
|
virtual |
returns the grid
References grid.
|
overridevirtual |
get number of samples
Implements sgpp::datadriven::DensityEstimator.
References samples.
Referenced by getSamples(), and optimizeLambdaCV().
|
overridevirtual |
returns the samples in the given dimension
dim |
Implements sgpp::datadriven::DensityEstimator.
References getNsamples(), and samples.
|
overridevirtual |
|
virtual |
returns the surpluses
References alpha.
|
virtual |
Estimate a sparse grid density based on the given data set and the specified configurations.
samples | DataMatrix (nrows = number of samples, ncols = dimensionality) |
Implements sgpp::datadriven::DensityEstimator.
References alpha, sgpp::op_factory::createOperationMakePositive(), sgpp::op_factory::createOperationQuadrature(), createRegularGrid(), crossvalidationConfig, sgpp::base::GeneralGridConfiguration::dim_, sgpp::base::OperationQuadrature::doQuadrature(), sgpp::datadriven::CrossvalidationForRegularizationConfiguration::enable_, sgpp::base::DataMatrix::getNcols(), grid, gridConfig, sgpp::datadriven::CrossvalidationForRegularizationConfiguration::lambda_, sgpp::datadriven::OperationMakePositive::makePositive(), sgpp::datadriven::SGDEConfiguration::makePositive_, sgpp::datadriven::SGDEConfiguration::makePositive_candidateSearchAlgorithm_, sgpp::datadriven::SGDEConfiguration::makePositive_generateConsistentGrid_, sgpp::datadriven::SGDEConfiguration::makePositive_interpolationAlgorithm_, sgpp::datadriven::SGDEConfiguration::makePositive_verbose_, optimizeLambdaCV(), samples, sgdeConfig, train(), and sgpp::datadriven::SGDEConfiguration::unitIntegrand_.
|
virtual |
Marginalize the density in one dimension and return result.
idim | dimension which should be marginalized |
References alpha, sgpp::op_factory::createOperationDensityMarginalize(), grid, samples, and SparseGridDensityEstimator().
|
virtual |
Compute marginal density.
idim | dimension which should be left after marginalization |
References alpha, sgpp::op_factory::createOperationDensityMargTo1D(), grid, samples, and SparseGridDensityEstimator().
|
overridevirtual |
This method computes the mean of the density function.
Implements sgpp::datadriven::DensityEstimator.
Referenced by python.uq.analysis.mc.MCAnalysis.MCAnalysis::computeMoments(), and python.uq.analysis.asgc.ASGCAnalysis.ASGCAnalysis::computeMoments().
|
protected |
|
protected |
Does cross-validation to obtain a suitable regularization parameter.
References alpha, computeResidual(), createRegularGrid(), crossvalidationConfig, getNsamples(), grid, python.statsfileInfo::i, python.utils.statsfile2gnuplot::j, sgpp::datadriven::CrossvalidationForRegularizationConfiguration::kfold_, sgpp::datadriven::CrossvalidationForRegularizationConfiguration::lambdaEnd_, sgpp::datadriven::CrossvalidationForRegularizationConfiguration::lambdaStart_, sgpp::datadriven::CrossvalidationForRegularizationConfiguration::lambdaSteps_, sgpp::datadriven::CrossvalidationForRegularizationConfiguration::logScale_, sgpp::base::DataVector::max(), sgpp::base::DataVector::min(), sgpp::base::DataVector::resizeZero(), sgpp::datadriven::CrossvalidationForRegularizationConfiguration::silent_, splitset(), and train().
Referenced by initialize().
|
overridevirtual |
This methods evaluates the sparse grid density at a single point.
x | DataVector length equal to dimensionality |
Implements sgpp::datadriven::DensityEstimator.
References alpha, sgpp::op_factory::createOperationEval(), and grid.
|
overridevirtual |
Evaluation of the sparse grid density at a set of points.
points | DataMatrix (nrows = number of samples, ncols = dimensionality) |
res | DataVector (size = number of samples) where the results are stored |
Implements sgpp::datadriven::DensityEstimator.
References alpha, sgpp::op_factory::createOperationMultipleEval(), and grid.
|
protected |
splits the complete sample set in a set of smaller training and test samples for cross-validation.
strain | vector containing the training samples for cv |
stest | vector containing the test samples for cv |
References crossvalidationConfig, python.statsfileInfo::i, python.utils.statsfile2gnuplot::j, sgpp::datadriven::CrossvalidationForRegularizationConfiguration::kfold_, friedman::p, chess::r, create_scripts::s, sgpp::datadriven::CrossvalidationForRegularizationConfiguration::seed_, sgpp::datadriven::CrossvalidationForRegularizationConfiguration::shuffle_, sgpp::datadriven::CrossvalidationForRegularizationConfiguration::silent_, and analyse_erg::tmp.
Referenced by optimizeLambdaCV().
|
virtual |
Does the learning step on a given grid, training set and regularization parameter lambda.
grid | grid |
alpha | coefficient vector |
train | sample set |
lambdaReg | regularization parameter |
References adaptivityConfig, computeDensitySystemMatrix(), sgpp::op_factory::createOperationEval(), crossvalidationConfig, chess::dim, sgpp::solver::SLESolverConfiguration::eps_, sgpp::base::Grid::getGenerator(), sgpp::base::DataMatrix::getNcols(), sgpp::base::HashGridStorage::getPoint(), sgpp::solver::SGSolver::getResiduum(), sgpp::base::DataVector::getSize(), sgpp::base::Grid::getSize(), sgpp::base::HashGridPoint::getStandardCoordinates(), sgpp::base::Grid::getStorage(), python.utils.sg_projections::gridStorage, python.statsfileInfo::i, sgpp::solver::SLESolverConfiguration::maxIterations_, sgpp::base::AdaptivityConfiguration::noPoints_, sgpp::base::AdaptivityConfiguration::numRefinements_, friedman::p, sgpp::base::GridGenerator::refine(), sgpp::base::DataVector::setAll(), sgpp::datadriven::CrossvalidationForRegularizationConfiguration::silent_, sgpp::solver::ConjugateGradients::solve(), solverConfig, sgpp::solver::SLESolverConfiguration::threshold_, sgpp::base::AdaptivityConfiguration::threshold_, and sgpp::solver::SLESolverConfiguration::verbose_.
Referenced by initialize(), and optimizeLambdaCV().
|
overridevirtual |
Computes the variance of the density function.
Implements sgpp::datadriven::DensityEstimator.
|
protected |
|
protected |
Referenced by SparseGridDensityEstimator(), and train().
|
protected |
|
protected |
Referenced by initialize(), optimizeLambdaCV(), SparseGridDensityEstimator(), splitset(), and train().
|
protected |
Referenced by cov(), python.uq.learner.Interpolant.Interpolant::doLearningIteration(), python.learner.Classifier.Classifier::evalError(), python.uq.learner.Interpolant.Interpolant::evalError(), python.uq.learner.SimulationLearner.SimulationLearner::getCollocationNodes(), python.uq.learner.SimulationLearner.SimulationLearner::getGrid(), getGrid(), python.uq.learner.SimulationLearner.SimulationLearner::getLearner(), initialize(), python.uq.learner.Regressor.Regressor::learnData(), python.uq.learner.Regressor.Regressor::learnDataWithFolding(), python.uq.learner.Regressor.Regressor::learnDataWithTest(), marginalize(), margToDimX(), mean(), optimizeLambdaCV(), pdf(), python.learner.Classifier.Classifier::refineGrid(), python.learner.Regressor.Regressor::refineGrid(), python.uq.learner.Regressor.Regressor::refineGrid(), python.uq.learner.SimulationLearner.SimulationLearner::refineGrid(), SparseGridDensityEstimator(), python.learner.Classifier.Classifier::updateResults(), python.learner.Regressor.Regressor::updateResults(), python.uq.learner.Regressor.Regressor::updateResults(), and variance().
|
protected |
Referenced by createRegularGrid(), getDim(), initialize(), and SparseGridDensityEstimator().
|
protected |
Referenced by computeRegularizationMatrix(), and SparseGridDensityEstimator().
|
protected |
Referenced by getNsamples(), getSamples(), initialize(), marginalize(), margToDimX(), and SparseGridDensityEstimator().
|
protected |
Referenced by initialize(), and SparseGridDensityEstimator().
|
protected |
Referenced by SparseGridDensityEstimator(), and train().