![]() |
SG++-Doxygen-Documentation
|
Base class for arbitrary machine learning models based on adaptive sparse grids. More...
#include <ModelFittingBase.hpp>
Public Member Functions | |
virtual bool | adapt ()=0 |
Improve accuracy of the model on the given training data by adaptive refinement of the grid. | |
virtual double | computeResidual (DataMatrix &validationData) const =0 |
Should compute some kind of Residual to evaluate the fit of the model. | |
virtual double | evaluate (const DataVector &sample)=0 |
Evaluate the fitted model at a single data point. | |
virtual void | evaluate (DataMatrix &samples, DataVector &results)=0 |
Evaluate the fitted model on a set of data points. | |
virtual void | fit (Dataset &dataset)=0 |
Fit the grid to the dataset by determining the weights of an initial grid. | |
virtual void | fit (Dataset &datasetP, Dataset &datasetQ)=0 |
Dataset * | getDataset () |
FitterConfiguration & | getFitterConfiguration () |
Get or set the configuration of the fitter object. | |
const FitterConfiguration & | getFitterConfiguration () const |
Get the configuration of the fitter object. | |
virtual Grid & | getGrid () |
Return the learned grid. | |
virtual std::shared_ptr< BlacsProcessGrid > | getProcessGrid () const |
virtual DataVector & | getSurpluses () |
Return the learned hierarchical surpluses. | |
ModelFittingBase () | |
Default constructor. | |
ModelFittingBase (const ModelFittingBase &rhs)=delete | |
Copy constructor - we cannot deep copy all member variables yet. | |
ModelFittingBase (ModelFittingBase &&rhs)=default | |
Move constructor. | |
ModelFittingBase & | operator= (const ModelFittingBase &rhs)=delete |
Copy assign operator - we cannot deep copy all member variables yet. | |
ModelFittingBase & | operator= (ModelFittingBase &&rhs)=default |
Move assign operator. | |
virtual void | reset ()=0 |
Resets the state of the entire model. | |
virtual void | resetTraining ()=0 |
Resets any trained representations of the model, but does not reset the entire state. | |
virtual void | update (Dataset &dataset)=0 |
Train the grid of an existing model with new samples. | |
virtual void | update (Dataset &datasetP, Dataset &datasetQ)=0 |
virtual void | updateRegularization (double lambda)=0 |
Updates the regularization parameter lambda of the underlying model. | |
virtual | ~ModelFittingBase ()=default |
virtual destructor. | |
Public Attributes | |
bool | verboseSolver |
Whether the Solver produces output or not. | |
Protected Member Functions | |
Grid * | buildGrid (const sgpp::base::GeneralGridConfiguration &gridConfig) const |
Factory member function that generates a grid from configuration. | |
Grid * | buildGrid (const sgpp::base::GeneralGridConfiguration &gridConfig, const GeometryConfiguration &geometryConfig) const |
Factory member function that generates a grid from configuration. | |
SLESolver * | buildSolver (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::unique_ptr< FitterConfiguration > | config |
Configuration object for the fitter. | |
Dataset * | dataset |
Pointer to sgpp::datadriven::Dataset. | |
Dataset * | extraDataset |
std::unique_ptr< std::set< std::set< size_t > > > | interactions |
std::unique_ptr< SLESolver > | solver |
Solver for the learning problem. | |
Base class for arbitrary machine learning models based on adaptive sparse grids.
A model tries to generalize high dimensional training data by using sparse grids. An underlying model can be trained using training data, its accuracy can be improved by using the adaptivity of sparse grids and the underlying grid(s) of a model can be retrained on other data. Once a model is trained it can be evaluated on unseen data.
sgpp::datadriven::ModelFittingBase::ModelFittingBase | ( | ) |
Default constructor.
|
delete |
Copy constructor - we cannot deep copy all member variables yet.
rhs | const reference to the scorer object to copy from. |
|
default |
Move constructor.
rhs | R-value reference to a scorer object to moved from. |
|
virtualdefault |
virtual destructor.
|
pure virtual |
Improve accuracy of the model on the given training data by adaptive refinement of the grid.
Implemented in sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityEstimation, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityRatioEstimation, and sgpp::datadriven::ModelFittingLeastSquares.
|
protected |
Factory member function that generates a grid from configuration.
gridConfig | configuration for the grid object |
References sgpp::datadriven::GridFactory::createGrid(), and interactions.
Referenced by sgpp::datadriven::ModelFittingDensityEstimationCG::fit(), sgpp::datadriven::ModelFittingDensityEstimationOnOff::fit(), sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::fit(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG::fit(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff::fit(), sgpp::datadriven::ModelFittingLeastSquares::fit(), and sgpp::datadriven::ModelFittingDensityRatioEstimation::fit().
|
protected |
Factory member function that generates a grid from configuration.
gridConfig | configuration for the grid object |
geometryConfig | configuration for the geometry parameters |
References sgpp::datadriven::GridFactory::createGrid(), sgpp::datadriven::GridFactory::getInteractions(), interactions, and sgpp::datadriven::GeometryConfiguration::stencils_.
|
protected |
Factory member function to build the solver for the least squares regression problem according to the config.
config | configuratin for the solver object |
References sgpp::solver::SLESolverConfiguration::eps_, sgpp::solver::SLESolverConfiguration::maxIterations_, and sgpp::solver::SLESolverConfiguration::type_.
Referenced by sgpp::datadriven::ModelFittingDensityRatioEstimation::ModelFittingDensityRatioEstimation(), and sgpp::datadriven::ModelFittingLeastSquares::ModelFittingLeastSquares().
|
pure virtual |
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.
validationData | Matrix for validation data |
Implemented in sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, sgpp::datadriven::ModelFittingDensityRatioEstimation, sgpp::datadriven::ModelFittingLeastSquares, and sgpp::datadriven::ModelFittingDensityEstimation.
Referenced by sgpp::datadriven::ResidualScore::measure().
|
pure virtual |
Evaluate the fitted model at a single data point.
sample | vector with the coordinates in all dimensions of that sample. |
Implemented in sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, sgpp::datadriven::ModelFittingDensityRatioEstimation, sgpp::datadriven::ModelFittingLeastSquares, and sgpp::datadriven::ModelFittingDensityEstimation.
Referenced by sgpp::datadriven::VisualizerDensityEstimation::getHeatmap2D(), sgpp::datadriven::VisualizerClassification::getHeatmap2DClassification(), sgpp::datadriven::VisualizerDensityEstimation::getHeatmap3D(), sgpp::datadriven::VisualizerClassification::getHeatmap3DClassification(), sgpp::datadriven::VisualizerDensityEstimation::getHeatmapMore4D(), sgpp::datadriven::VisualizerClassification::getHeatmapMore4DClassification(), sgpp::datadriven::VisualizerDensityEstimation::getLinearCuts1D(), sgpp::datadriven::VisualizerDensityEstimation::getLinearCuts2D(), sgpp::datadriven::VisualizerDensityEstimation::getLinearCutsMore3D(), and sgpp::datadriven::Scorer::test().
|
pure virtual |
Evaluate the fitted model on a set of data points.
samples | matrix where each row represents a sample and the columns contain the coordinates in all dimensions of that sample. |
results | vector where each row will contain the evaluation of the respective sample on the current model. |
Implemented in sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, sgpp::datadriven::ModelFittingDensityRatioEstimation, sgpp::datadriven::ModelFittingLeastSquares, and sgpp::datadriven::ModelFittingDensityEstimation.
|
pure virtual |
Fit the grid to the dataset by determining the weights of an initial grid.
dataset | the training dataset that is used to fit the model. |
Implemented in sgpp::datadriven::ModelFittingDensityRatioEstimation, sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, sgpp::datadriven::ModelFittingLeastSquares, sgpp::datadriven::ModelFittingDensityEstimation, and sgpp::datadriven::ModelFittingDensityEstimationCombi.
|
pure virtual |
Implemented in sgpp::datadriven::ModelFittingLeastSquares, sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, sgpp::datadriven::ModelFittingDensityEstimation, sgpp::datadriven::ModelFittingDensityEstimationCombi, and sgpp::datadriven::ModelFittingDensityRatioEstimation.
Dataset * sgpp::datadriven::ModelFittingBase::getDataset | ( | ) |
FitterConfiguration & sgpp::datadriven::ModelFittingBase::getFitterConfiguration | ( | ) |
Get or set the configuration of the fitter object.
References config.
const FitterConfiguration & sgpp::datadriven::ModelFittingBase::getFitterConfiguration | ( | ) | const |
Get the configuration of the fitter object.
References config.
Referenced by sgpp::datadriven::ModelFittingDensityEstimationCombi::fit(), sgpp::datadriven::VisualizerDensityEstimation::getHeatmap(), sgpp::datadriven::VisualizerDensityEstimation::getLinearCuts(), sgpp::datadriven::VisualizerClassification::runVisualization(), sgpp::datadriven::VisualizerDensityEstimation::runVisualization(), and sgpp::datadriven::Scorer::test().
|
inlinevirtual |
Return the learned grid.
Has to be rewritten to modify default behavior. Only available for single grid models. Otherwise, an error message is shown.
Reimplemented in sgpp::datadriven::ModelFittingBaseSingleGrid.
Referenced by sgpp::datadriven::ModelFittingClassification::adapt(), python.uq.analysis.asgc.ASGCKnowledge.ASGCKnowledge::getSparseGridFunction(), python.uq.learner.SimulationLearner.SimulationLearner::learnData(), python.uq.learner.SimulationLearner.SimulationLearner::learnDataWithFolding(), python.uq.learner.SimulationLearner.SimulationLearner::learnDataWithTest(), and python.uq.learner.SimulationLearner.SimulationLearner::refineGrid().
|
protected |
|
inlinevirtual |
Reimplemented in sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel.
|
inlinevirtual |
Return the learned hierarchical surpluses.
Reimplemented in sgpp::datadriven::ModelFittingBaseSingleGrid.
Referenced by sgpp::datadriven::ModelFittingClassification::adapt().
|
delete |
Copy assign operator - we cannot deep copy all member variables yet.
rhs | const reference to the scorer object to copy from. |
|
default |
Move assign operator.
rhs | R-value reference to an a scorer object to move from. |
|
protected |
Configure solver based on the desired configuration.
solver | the solver object to be modified. |
config | configuration updating the for the solver. |
References sgpp::solver::SLESolverConfiguration::eps_, sgpp::solver::SLESolverConfiguration::maxIterations_, and solver.
|
pure virtual |
Resets the state of the entire model.
Implemented in sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, sgpp::datadriven::ModelFittingDensityRatioEstimation, and sgpp::datadriven::ModelFittingLeastSquares.
Referenced by sgpp::datadriven::SparseGridMiner::setModel().
|
pure virtual |
Resets any trained representations of the model, but does not reset the entire state.
Implemented in sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, sgpp::datadriven::ModelFittingDensityRatioEstimation, sgpp::datadriven::ModelFittingLeastSquares, and sgpp::datadriven::ModelFittingDensityEstimation.
|
pure virtual |
Train the grid of an existing model with new samples.
dataset | the training dataset that is used to fit the model. |
Implemented in sgpp::datadriven::ModelFittingDensityRatioEstimation, sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, sgpp::datadriven::ModelFittingLeastSquares, and sgpp::datadriven::ModelFittingDensityEstimation.
Referenced by python.uq.refinement.RefinementStrategy.Ranking::rank(), and python.learner.LearnedKnowledge.LearnedKnowledge::setMemento().
|
pure virtual |
Implemented in sgpp::datadriven::ModelFittingLeastSquares, sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, sgpp::datadriven::ModelFittingDensityRatioEstimation, and sgpp::datadriven::ModelFittingDensityEstimation.
Referenced by python.uq.refinement.RefinementStrategy.Ranking::rank(), and python.learner.LearnedKnowledge.LearnedKnowledge::setMemento().
|
pure virtual |
Updates the regularization parameter lambda of the underlying model.
lambda | the new lambda parameter |
Implemented in sgpp::datadriven::ModelFittingClassification, sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG, sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationCG, sgpp::datadriven::ModelFittingDensityEstimationCombi, sgpp::datadriven::ModelFittingDensityEstimationOnOff, sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel, sgpp::datadriven::ModelFittingDensityRatioEstimation, sgpp::datadriven::ModelFittingLeastSquares, and sgpp::datadriven::ModelFittingDensityEstimation.
|
protected |
Configuration object for the fitter.
Referenced by sgpp::datadriven::ModelFittingClassification::adapt(), sgpp::datadriven::ModelFittingDensityEstimation::adapt(), sgpp::datadriven::ModelFittingDensityRatioEstimation::adapt(), sgpp::datadriven::ModelFittingLeastSquares::adapt(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff::adapt(), sgpp::datadriven::ModelFittingDensityEstimationOnOff::adapt(), sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::adapt(), sgpp::datadriven::ModelFittingDensityEstimationCombi::addNewModel(), sgpp::datadriven::ModelFittingDensityEstimationOnOff::computeResidual(), sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::computeResidual(), sgpp::datadriven::ModelFittingClassification::evaluate(), sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::evaluate(), sgpp::datadriven::ModelFittingDensityRatioEstimation::evaluate(), sgpp::datadriven::ModelFittingLeastSquares::evaluate(), sgpp::datadriven::ModelFittingDensityEstimationCG::fit(), sgpp::datadriven::ModelFittingDensityEstimationOnOff::fit(), sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::fit(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG::fit(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff::fit(), sgpp::datadriven::ModelFittingDensityEstimationCombi::fit(), sgpp::datadriven::ModelFittingLeastSquares::fit(), sgpp::datadriven::ModelFittingDensityRatioEstimation::fit(), sgpp::datadriven::ModelFittingDensityEstimation::getCoarseningFunctor(), getFitterConfiguration(), getFitterConfiguration(), sgpp::datadriven::ModelFittingDensityEstimation::getRefinementFunctor(), python.uq.dists.SGDEdist.SGDEdist::marginalize(), python.uq.dists.SGDEdist.SGDEdist::marginalizeToDimX(), sgpp::datadriven::ModelFittingClassification::ModelFittingClassification(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG::ModelFittingDensityDifferenceEstimationCG(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff::ModelFittingDensityDifferenceEstimationOnOff(), sgpp::datadriven::ModelFittingDensityEstimationCG::ModelFittingDensityEstimationCG(), sgpp::datadriven::ModelFittingDensityEstimationCombi::ModelFittingDensityEstimationCombi(), sgpp::datadriven::ModelFittingDensityEstimationOnOff::ModelFittingDensityEstimationOnOff(), sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::ModelFittingDensityEstimationOnOffParallel(), sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::ModelFittingDensityEstimationOnOffParallel(), sgpp::datadriven::ModelFittingDensityRatioEstimation::ModelFittingDensityRatioEstimation(), sgpp::datadriven::ModelFittingLeastSquares::ModelFittingLeastSquares(), python.uq.dists.SGDEdist.SGDEdist::toJson(), sgpp::datadriven::ModelFittingDensityEstimationCG::update(), sgpp::datadriven::ModelFittingDensityEstimationOnOff::update(), sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::update(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG::update(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff::update(), sgpp::datadriven::ModelFittingLeastSquares::update(), sgpp::datadriven::ModelFittingDensityRatioEstimation::update(), sgpp::datadriven::ModelFittingDensityEstimationOnOff::updateRegularization(), and sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::updateRegularization().
|
protected |
Pointer to sgpp::datadriven::Dataset.
The initial grid is fitted on the given data. Adaptive refinement is then performed on the very same data. The used dataset used for refinement overwritten once either fit() or update() introduce a new dataset.
Referenced by sgpp::datadriven::ModelFittingDensityEstimationCG::fit(), sgpp::datadriven::ModelFittingDensityEstimationOnOff::fit(), sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::fit(), sgpp::datadriven::ModelFittingLeastSquares::fit(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG::fit(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff::fit(), sgpp::datadriven::ModelFittingDensityEstimationCombi::fit(), sgpp::datadriven::ModelFittingDensityRatioEstimation::fit(), getDataset(), sgpp::datadriven::ModelFittingClassification::update(), sgpp::datadriven::ModelFittingDensityEstimationCG::update(), sgpp::datadriven::ModelFittingDensityEstimationCombi::update(), sgpp::datadriven::ModelFittingDensityEstimationOnOff::update(), sgpp::datadriven::ModelFittingDensityEstimationOnOffParallel::update(), sgpp::datadriven::ModelFittingLeastSquares::update(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG::update(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff::update(), and sgpp::datadriven::ModelFittingDensityRatioEstimation::update().
|
protected |
Referenced by sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG::fit(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff::fit(), sgpp::datadriven::ModelFittingDensityRatioEstimation::fit(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationCG::update(), sgpp::datadriven::ModelFittingDensityDifferenceEstimationOnOff::update(), and sgpp::datadriven::ModelFittingDensityRatioEstimation::update().
|
protected |
Referenced by buildGrid(), buildGrid(), and getInteractions().
|
protected |
Solver for the learning problem.
Referenced by python.uq.learner.Learner.Learner::copy(), python.learner.Learner.Learner::doLearningIteration(), python.learner.Learner.Learner::fromJson(), python.uq.learner.Learner.Learner::fromJson(), sgpp::datadriven::ModelFittingDensityRatioEstimation::ModelFittingDensityRatioEstimation(), sgpp::datadriven::ModelFittingLeastSquares::ModelFittingLeastSquares(), reconfigureSolver(), python.learner.Learner.Learner::setSolver(), and python.uq.learner.Learner.Learner::setSolver().
bool sgpp::datadriven::ModelFittingBase::verboseSolver |
Whether the Solver produces output or not.