SG++-Doxygen-Documentation
|
#include <LearnerSGDE.hpp>
Public Member Functions | |
void | cov (base::DataMatrix &cov, base::DataMatrix *bounds=nullptr) override |
WARNING: Not yet implemented. More... | |
virtual double | getAccuracy (base::DataMatrix &testDataset, const base::DataVector &referenceLabels, const double threshold) |
Computes the classification accuracy. More... | |
virtual double | getAccuracy (const base::DataVector &referenceLabels, const double threshold, const base::DataVector &predictedLabels) |
Computes the classification accuracy. More... | |
size_t | getDim () override |
get number of dimensions More... | |
virtual double | getError (base::DataMatrix &data, const base::DataVector &labels, const double threshold, std::string errorType) |
Error evaluation required for convergence-based refinement. 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... | |
std::shared_ptr< base::Grid > | getSharedGrid () |
std::shared_ptr< base::DataVector > | getSharedSurpluses () |
virtual base::DataVector * | getSurpluses () |
returns the surpluses More... | |
void | initialize (base::DataMatrix &samples) override |
Create grid and perform cross-validation if enabled. More... | |
LearnerSGDE (sgpp::base::RegularGridConfiguration &gridConfig, sgpp::base::AdaptivityConfiguration &adaptivityConfig, sgpp::solver::SLESolverConfiguration &solverConfig, sgpp::datadriven::RegularizationConfiguration ®ularizationConfig, CrossvalidationConfiguration &crossvalidationConfig) | |
Constructor. More... | |
LearnerSGDE (LearnerSGDEConfiguration &learnerSGDEConfig) | |
LearnerSGDE (const LearnerSGDE &learnerSGDE) | |
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... | |
virtual void | predict (base::DataMatrix &testDataset, base::DataVector &predictedLabels) |
Predicts class labels based on the trained model. More... | |
virtual void | storeResults (base::DataMatrix &testDataset) |
Stores classified data, grids and density function evaluations to csv files. More... | |
virtual void | train (base::Grid &grid, base::DataVector &alpha, base::DataMatrix &trainData, double lambdaReg) |
Does the learning step (i.e. More... | |
virtual void | train () |
Learns the data. More... | |
virtual void | trainOnline (base::DataVector &labels, base::DataMatrix &testData, base::DataVector &testLabels, base::DataMatrix *validData, base::DataVector *validLabels, base::DataVector &classLabels, size_t maxDataPasses, std::string refType, std::string refMonitor, size_t refPeriod, double accDeclineThreshold, size_t accDeclineBufferSize, size_t minRefInterval, bool usePrior) |
Performs the sparse grid density estimation via online learning. More... | |
double | variance () override |
Computes the variance of the density function. More... | |
virtual | ~LearnerSGDE () |
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 () |
Public Attributes | |
base::DataVector | avgErrors |
double | error |
Protected Member Functions | |
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 |
std::map< int, std::shared_ptr< base::DataVector > > | alphas |
std::map< int, size_t > | appearances |
sgpp::datadriven::CrossvalidationConfiguration | crossvalidationConfig |
std::shared_ptr< base::Grid > | grid |
sgpp::base::RegularGridConfiguration | gridConfig |
std::map< int, std::shared_ptr< base::Grid > > | grids |
double | lambdaReg |
std::map< int, double > | priors |
sgpp::datadriven::RegularizationConfiguration | regularizationConfig |
sgpp::solver::SLESolverConfiguration | solverConfig |
std::shared_ptr< base::DataMatrix > | trainData |
std::shared_ptr< base::DataVector > | trainLabels |
bool | usePrior |
sgpp::datadriven::LearnerSGDE::LearnerSGDE | ( | sgpp::base::RegularGridConfiguration & | gridConfig, |
sgpp::base::AdaptivityConfiguration & | adaptivityConfig, | ||
sgpp::solver::SLESolverConfiguration & | solverConfig, | ||
sgpp::datadriven::RegularizationConfiguration & | regularizationConfig, | ||
CrossvalidationConfiguration & | crossvalidationConfig | ||
) |
Constructor.
gridConfig | grid configuration |
adaptivityConfig | adaptive refinement configuration |
solverConfig | solver configuration (CG) |
regularizationConfig | config for regularization operator |
crossvalidationConfig | configuration for the cross validation |
|
explicit |
sgpp::datadriven::LearnerSGDE::LearnerSGDE | ( | const LearnerSGDE & | learnerSGDE | ) |
References adaptivityConfig, alpha, crossvalidationConfig, error, grid, gridConfig, lambdaReg, regularizationConfig, solverConfig, trainData, and usePrior.
|
virtual |
|
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 computeResidual(), train(), and trainOnline().
|
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 parameters |
References python.utils.pca_normalize_dataset::C, computeRegularizationMatrix(), sgpp::base::Grid::getSize(), and python.statsfileInfo::i.
Referenced by optimizeLambdaCV().
|
overridevirtual |
WARNING: Not yet implemented.
Implements sgpp::datadriven::DensityEstimator.
References alpha, sgpp::op_factory::createOperationCovariance(), and grid.
|
protected |
generates a regular grid
References sgpp::base::Grid::createLinearBoundaryGrid(), sgpp::base::Grid::createLinearGrid(), sgpp::base::GeneralGridConfiguration::dim_, sgpp::base::GeneralGridConfiguration::filename_, gridConfig, sgpp::base::GeneralGridConfiguration::level_, sgpp::base::Linear, sgpp::base::LinearBoundary, sgpp::base::LinearL0Boundary, sgpp::base::GeneralGridConfiguration::type_, and sgpp::base::Grid::unserialize().
Referenced by initialize(), and optimizeLambdaCV().
|
virtual |
Computes the classification accuracy.
testDataset | The data for which class labels should be predicted |
referenceLabels | The corresponding actual class labels |
threshold | The decision threshold (e.g. for class labels -1, 1 -> threshold = 0) |
References sgpp::base::DataMatrix::getNrows(), and predict().
Referenced by getError(), and trainOnline().
|
virtual |
Computes the classification accuracy.
referenceLabels | The actual class labels |
threshold | The decision threshold (e.g. for class labels -1, 1 -> threshold = 0) |
predictedLabels | The predicted class labels |
References sgpp::base::DataVector::get(), sgpp::base::DataVector::getSize(), and python.statsfileInfo::i.
|
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 |
Error evaluation required for convergence-based refinement.
data | The data points to measure the error on |
labels | The corresponding class labels |
threshold | The decision threshold (e.g. for class labels -1, 1 -> threshold = 0) |
errorType | The error type (only "Acc" possible, i.e. classification error based on accuracy) |
References getAccuracy().
Referenced by trainOnline().
|
virtual |
returns the grid
References grid.
|
overridevirtual |
get number of samples
Implements sgpp::datadriven::DensityEstimator.
References trainData.
Referenced by getSamples(), and optimizeLambdaCV().
|
overridevirtual |
returns the samples in the given dimension
dim |
Implements sgpp::datadriven::DensityEstimator.
References getNsamples(), and trainData.
|
overridevirtual |
returns the complete sample set
Implements sgpp::datadriven::DensityEstimator.
References trainData.
std::shared_ptr< base::Grid > sgpp::datadriven::LearnerSGDE::getSharedGrid | ( | ) |
References grid.
Referenced by sgpp::datadriven::RosenblattTransformation::initialize().
std::shared_ptr< base::DataVector > sgpp::datadriven::LearnerSGDE::getSharedSurpluses | ( | ) |
References alpha.
Referenced by sgpp::datadriven::RosenblattTransformation::initialize().
|
virtual |
returns the surpluses
References alpha.
|
overridevirtual |
Create grid and perform cross-validation if enabled.
samples | DataMatrix (nrows = number of samples, ncols = dimensionality) |
Implements sgpp::datadriven::DensityEstimator.
References alpha, createRegularGrid(), crossvalidationConfig, sgpp::base::GeneralGridConfiguration::dim_, sgpp::datadriven::CrossvalidationConfiguration::enable_, sgpp::base::DataMatrix::getNcols(), grid, gridConfig, sgpp::datadriven::CrossvalidationConfiguration::lambda_, lambdaReg, optimizeLambdaCV(), parabolasimple::samples, and trainData.
Referenced by sgpp::datadriven::RosenblattTransformation::initialize().
|
overridevirtual |
This method computes the mean of the density function.
Implements sgpp::datadriven::DensityEstimator.
Referenced by python.uq.analysis.mc.MCAnalysis.MCAnalysis::computeMoments(), python.uq.analysis.asgc.ASGCAnalysis.ASGCAnalysis::computeMoments(), and variance().
|
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::CrossvalidationConfiguration::kfold_, sgpp::datadriven::CrossvalidationConfiguration::lambdaEnd_, sgpp::datadriven::CrossvalidationConfiguration::lambdaStart_, sgpp::datadriven::CrossvalidationConfiguration::lambdaSteps_, sgpp::datadriven::CrossvalidationConfiguration::logScale_, sgpp::base::DataVector::max(), sgpp::base::DataVector::min(), sgpp::base::DataVector::resizeZero(), sgpp::datadriven::CrossvalidationConfiguration::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 sgpp::base::OperationEval::eval().
|
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(), sgpp::base::OperationMultipleEval::eval(), and grid.
|
virtual |
Predicts class labels based on the trained model.
testDataset | The data for which class labels should be predicted |
predictedLabels | The predicted class labels |
References alphas, sgpp::op_factory::createOperationEval(), chess::dim, g, sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), sgpp::base::DataMatrix::getRow(), grids, python.statsfileInfo::i, priors, sgpp::base::DataVector::set(), and usePrior.
Referenced by getAccuracy(), and storeResults().
|
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::CrossvalidationConfiguration::kfold_, friedman::p, chess::r, create_scripts::s, sgpp::datadriven::CrossvalidationConfiguration::seed_, sgpp::datadriven::CrossvalidationConfiguration::shuffle_, sgpp::datadriven::CrossvalidationConfiguration::silent_, and analyse_erg::tmp.
Referenced by optimizeLambdaCV().
|
virtual |
Stores classified data, grids and density function evaluations to csv files.
testDataset | The data for which class labels should be predicted |
References alphas, sgpp::base::DataMatrix::appendRow(), sgpp::base::HashGridStorage::begin(), sgpp::op_factory::createOperationEval(), sgpp::base::HashGridStorage::end(), g, sgpp::base::DataVector::get(), sgpp::base::HashGridStorage::getCoordinates(), sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), sgpp::base::DataMatrix::getRow(), sgpp::base::DataVector::getSize(), grid, grids, python.statsfileInfo::i, python.utils.statsfile2gnuplot::j, predict(), and sgpp::base::DataVector::set().
|
virtual |
Does the learning step (i.e.
computes pdf) on a given grid, training set and regularization parameter lambda
grid | grid |
alpha | coefficient vector |
trainData | sample set |
lambdaReg | regularization parameter |
References adaptivityConfig, python.utils.pca_normalize_dataset::C, computeRegularizationMatrix(), sgpp::op_factory::createOperationEval(), crossvalidationConfig, chess::dim, sgpp::solver::SLESolverConfiguration::eps_, sgpp::datadriven::DensitySystemMatrix::generateb(), sgpp::base::DataVector::get(), 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::CrossvalidationConfiguration::silent_, sgpp::solver::ConjugateGradients::solve(), solverConfig, sgpp::solver::SLESolverConfiguration::threshold_, and sgpp::base::AdaptivityConfiguration::threshold_.
Referenced by sgpp::datadriven::RosenblattTransformation::initialize().
|
virtual |
Learns the data.
References alpha, grid, lambdaReg, and trainData.
Referenced by optimizeLambdaCV().
|
virtual |
Performs the sparse grid density estimation via online learning.
labels | The training labels |
testData | The test data |
testLabels | The corresponding test labels |
validData | The validation data |
validLabels | The corresponding validation labels |
classLabels | The ocurring class labels (e.g. -1,1) |
maxDataPasses | The number of passes over the whole training data |
refType | The refinement indicator (surplus, zero-crossings or data-based) |
refMonitor | The refinement strategy (periodic or convergence-based) |
refPeriod | The refinement interval (if periodic refinement is chosen) |
accDeclineThreshold | The convergence threshold (if convergence-based refinement is chosen) |
accDeclineBufferSize | The number of accuracy measurements which are used to check convergence (if convergence-based refinement is chosen) |
minRefInterval | The minimum number of data points (or data batches) which have to be processed before next refinement can be scheduled (if convergence-based refinement is chosen) |
usePrior | Specifies whether prior probabilities should be used to predict class labels |
References adaptivityConfig, alpha, alphas, appearances, sgpp::base::DataVector::append(), avgErrors, python.utils.pca_normalize_dataset::C, computeRegularizationMatrix(), sgpp::base::Grid::createLinearGrid(), sgpp::base::Grid::createModLinearGrid(), sgpp::op_factory::createOperationEval(), chess::dim, sgpp::base::GeneralGridConfiguration::dim_, sgpp::solver::SLESolverConfiguration::eps_, error, g, sgpp::datadriven::DensitySystemMatrix::generateb(), getAccuracy(), getError(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::DataVector::getSize(), sgpp::base::HashGridPoint::getStandardCoordinates(), grid, gridConfig, grids, python.utils.sg_projections::gridStorage, python.statsfileInfo::i, python.utils.statsfile2gnuplot::j, lambdaReg, sgpp::base::GeneralGridConfiguration::level_, sgpp::base::Linear, sgpp::solver::SLESolverConfiguration::maxIterations_, sgpp::base::ModLinear, sgpp::base::AdaptivityConfiguration::noPoints_, sgpp::base::AdaptivityConfiguration::numRefinements_, friedman::p, sgpp::datadriven::MultiGridRefinementFunctor::preComputeEvaluations(), priors, sgpp::datadriven::RefinementMonitor::pushToBuffer(), sgpp::datadriven::RefinementMonitor::refinementsNecessary(), sgpp::datadriven::MultiGridRefinementFunctor::setGridIndex(), sgpp::solver::ConjugateGradients::solve(), solverConfig, sgpp::solver::SLESolverConfiguration::threshold_, sgpp::base::AdaptivityConfiguration::threshold_, trainData, trainLabels, sgpp::base::GeneralGridConfiguration::type_, and usePrior.
|
overridevirtual |
Computes the variance of the density function.
Implements sgpp::datadriven::DensityEstimator.
|
protected |
|
protected |
Referenced by LearnerSGDE(), train(), and trainOnline().
|
protected |
|
protected |
Referenced by predict(), storeResults(), and trainOnline().
|
protected |
Referenced by trainOnline().
base::DataVector sgpp::datadriven::LearnerSGDE::avgErrors |
Referenced by trainOnline().
|
protected |
Referenced by initialize(), LearnerSGDE(), optimizeLambdaCV(), splitset(), and train().
double sgpp::datadriven::LearnerSGDE::error |
Referenced by LearnerSGDE(), and trainOnline().
|
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(), getSharedGrid(), initialize(), python.uq.learner.Regressor.Regressor::learnData(), python.uq.learner.Regressor.Regressor::learnDataWithFolding(), python.uq.learner.Regressor.Regressor::learnDataWithTest(), LearnerSGDE(), 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(), storeResults(), train(), trainOnline(), python.learner.Classifier.Classifier::updateResults(), python.learner.Regressor.Regressor::updateResults(), python.uq.learner.Regressor.Regressor::updateResults(), and variance().
|
protected |
Referenced by createRegularGrid(), getDim(), initialize(), LearnerSGDE(), and trainOnline().
|
protected |
Referenced by predict(), storeResults(), and trainOnline().
|
protected |
Referenced by initialize(), LearnerSGDE(), train(), and trainOnline().
|
protected |
Referenced by predict(), and trainOnline().
|
protected |
Referenced by computeRegularizationMatrix(), and LearnerSGDE().
|
protected |
Referenced by LearnerSGDE(), train(), and trainOnline().
|
protected |
|
protected |
Referenced by trainOnline().
|
protected |
Referenced by LearnerSGDE(), predict(), and trainOnline().