SG++-Doxygen-Documentation
|
Abstract class that implements a regression/classification learner based on spatial adaptive Sparse Grids. More...
#include <LearnerBase.hpp>
Public Member Functions | |
void | dumpFunction (std::string tFilename, size_t resolution) |
simple dump of sparse grid function into file, e.g. More... | |
void | dumpGrid (std::string tFilename) |
simple dump of grid points into file, e.g. More... | |
virtual double | getAccuracy (sgpp::base::DataMatrix &testDataset, const sgpp::base::DataVector &classesReference, const double threshold=0.0) |
compute the accuracy for given testDataset. More... | |
virtual double | getAccuracy (const sgpp::base::DataVector &classesComputed, const sgpp::base::DataVector &classesReference, const double threshold=0.0) |
compute the accuracy for given testDataset. More... | |
sgpp::base::DataVector & | getAlpha () |
virtual ClassificatorQuality | getCassificatorQuality (sgpp::base::DataMatrix &testDataset, const sgpp::base::DataVector &classesReference, const double threshold=0.0) |
compute the quality for given testDataset, classification ONLY! test is automatically called in order to determine the regression values of the current learner More... | |
virtual ClassificatorQuality | getCassificatorQuality (const sgpp::base::DataVector &classesComputed, const sgpp::base::DataVector &classesReference, const double threshold=0.0) |
compute the quality for given testDataset, classification ONLY! More... | |
sgpp::base::Grid & | getGrid () |
bool | getIsRegression () const |
determines the current mode More... | |
bool | getIsVerbose () const |
determines the current verbose mode of learner More... | |
std::vector< std::pair< size_t, double > > | getRefinementExecTimes () |
LearnerBase (const bool isRegression, const bool isVerbose=true) | |
Constructor. More... | |
LearnerBase (const LearnerBase ©Me) | |
Copy-Constructor. More... | |
virtual void | multTranspose (sgpp::base::DataMatrix &dataset, sgpp::base::DataVector &multiplier, sgpp::base::DataVector &result) |
virtual void | predict (sgpp::base::DataMatrix &testDataset, sgpp::base::DataVector &classesComputed) |
executes a Regression test for a given dataset and returns the result More... | |
void | setIsVerbose (const bool isVerbose) |
sets the current verbose mode of learner More... | |
void | setReuseCoefficients (bool reuseCoefficients) |
void | setSolverVerbose (bool solverVerbose) |
void | store (std::string tGridFilename, std::string tAlphaFilename) |
store the grid and its current coefficients into files for further usage. More... | |
virtual LearnerTiming | train (sgpp::base::DataMatrix &trainDataset, sgpp::base::DataVector &classes, const sgpp::base::RegularGridConfiguration &GridConfig, const sgpp::solver::SLESolverConfiguration &SolverConfigRefine, const sgpp::solver::SLESolverConfiguration &SolverConfigFinal, const sgpp::base::AdaptivityConfiguration &AdaptConfig, bool testAccDuringAdapt, const double lambdaRegularization, sgpp::base::DataMatrix *testDataset=nullptr, sgpp::base::DataVector *testClasses=nullptr) |
Learning a dataset with spatially adaptive sparse grids. More... | |
LearnerTiming | train (sgpp::base::DataMatrix &trainDataset, sgpp::base::DataVector &classes, const sgpp::base::RegularGridConfiguration &GridConfig, const sgpp::solver::SLESolverConfiguration &SolverConfig, const double lambdaRegularization) |
Learning a dataset with regular sparse grids. More... | |
virtual | ~LearnerBase () |
Destructor. More... | |
Protected Member Functions | |
virtual std::unique_ptr< sgpp::datadriven::DMSystemMatrixBase > | createDMSystem (sgpp::base::DataMatrix &trainDataset, double lambda)=0 |
abstract method that constructs the corresponding system of linear equations Derived classes MUST overwrite this functions! More... | |
virtual void | InitializeGrid (const sgpp::base::RegularGridConfiguration &GridConfig) |
Initialize the grid and its coefficients. More... | |
virtual void | postProcessing (const sgpp::base::DataMatrix &trainDataset, const sgpp::solver::SLESolverType &solver, const size_t numNeededIterations) |
Hook-Method for post-processing after each refinement learning. More... | |
virtual void | preProcessing () |
Hook-Method for pre-processing before starting learning. More... | |
Protected Attributes | |
std::unique_ptr< sgpp::base::DataVector > | alpha |
the grid's coefficients More... | |
size_t | currentRefinementStep |
the current refinment step during training More... | |
double | execTime |
execution time More... | |
std::vector< std::pair< size_t, double > > | ExecTimeOnStep |
double | GByte |
number of transferred Gbytes More... | |
double | GFlop |
number of executed Floating Point operations More... | |
std::unique_ptr< sgpp::base::Grid > | grid |
sparse grid object More... | |
bool | isRegression |
is regression selected More... | |
bool | isTrained |
is the grid trained More... | |
bool | isVerbose |
is verbose output enabled More... | |
bool | reuseCoefficients |
shall the coefficients be reused between refinement steps More... | |
bool | solverVerbose |
sets the verbose option for the solver More... | |
double | stepExecTime |
execution time for current refinement to calculate the GFlops at the current timestep only otherwise accumulated GFlops (all refinement steps) are calculated More... | |
double | stepGByte |
number of transferred Gbytes in the current refinement step More... | |
double | stepGFlop |
number of executed Floating Point operations in the current refinement step More... | |
Abstract class that implements a regression/classification learner based on spatial adaptive Sparse Grids.
Furthermore this class is intended to provide a framework for adavanded regression and classification methods by allowing to override basic routines like train and test.
|
explicit |
Constructor.
isRegression | flag for regression |
isVerbose | flag for verbose output |
sgpp::datadriven::LearnerBase::LearnerBase | ( | const LearnerBase & | copyMe | ) |
Copy-Constructor.
copyMe | LearnerBase that should be duplicated |
References alpha, currentRefinementStep, execTime, GByte, GFlop, grid, isRegression, isTrained, isVerbose, reuseCoefficients, solverVerbose, stepExecTime, stepGByte, stepGFlop, and sgpp::base::Grid::unserialize().
|
virtual |
Destructor.
|
protectedpure virtual |
abstract method that constructs the corresponding system of linear equations Derived classes MUST overwrite this functions!
trainDataset | training dataset |
lambda | lambda regularization parameter |
Implemented in sgpp::datadriven::LearnerLeastSquaresIdentity, and sgpp::datadriven::Learner.
Referenced by train().
void sgpp::datadriven::LearnerBase::dumpFunction | ( | std::string | tFilename, |
size_t | resolution | ||
) |
simple dump of sparse grid function into file, e.g.
used to plot with gnuplot.
only executed if grid is trained and number of dimensions <= 2.
tFilename | filename to store the dump to |
resolution | resolution of function plot |
References alpha, grid, isTrained, and sgpp::base::GridPrinter::printGrid().
void sgpp::datadriven::LearnerBase::dumpGrid | ( | std::string | tFilename | ) |
simple dump of grid points into file, e.g.
used to plot with gnuplot
only executed if grid is trained
tFilename | filename to store the dump to |
References alpha, grid, isTrained, and sgpp::base::GridPrinter::printSparseGrid().
|
virtual |
compute the accuracy for given testDataset.
test is automatically called in order to determine the regression values of the current learner
In case if classification (isRegression == false) this routine returns the learner's accuracy In case of regressions (isRegression == true) this routine returns the learner's MSE
testDataset | dataset to be tested |
classesReference | reference labels of the test dataset |
threshold | threshold used for classification, ignored when performing regressions |
References sgpp::base::DataMatrix::getNrows(), and predict().
Referenced by train().
|
virtual |
compute the accuracy for given testDataset.
In case if classification (isRegression == false) this routine returns the learner's accuracy In case of regressions (isRegression == true) this routine returns the learner's MSE
classesComputed | regression results of the test dataset |
classesReference | reference labels of the test dataset |
threshold | threshold used for classification, ignored when performing regressions |
References sgpp::base::DataVector::get(), sgpp::base::DataVector::getSize(), python.statsfileInfo::i, isRegression, sgpp::base::DataVector::sqr(), sgpp::base::DataVector::sub(), sgpp::base::DataVector::sum(), and analyse_erg::tmp.
sgpp::base::DataVector & sgpp::datadriven::LearnerBase::getAlpha | ( | ) |
References alpha.
|
virtual |
compute the quality for given testDataset, classification ONLY! test is automatically called in order to determine the regression values of the current learner
testDataset | dataset to be tested |
classesReference | reference labels of the test dataset |
threshold | threshold used for classification, ignored when performing regressions |
References sgpp::base::DataMatrix::getNrows(), and predict().
|
virtual |
compute the quality for given testDataset, classification ONLY!
classesComputed | regression results of the test dataset |
classesReference | reference labels of the test dataset |
threshold | threshold used for classification, ignored when performing regressions |
References sgpp::datadriven::ClassificatorQuality::falseNegative_, sgpp::datadriven::ClassificatorQuality::falsePositive_, sgpp::base::DataVector::get(), sgpp::base::DataVector::getSize(), python.statsfileInfo::i, isRegression, sgpp::datadriven::ClassificatorQuality::trueNegative_, and sgpp::datadriven::ClassificatorQuality::truePositive_.
sgpp::base::Grid & sgpp::datadriven::LearnerBase::getGrid | ( | ) |
References grid.
bool sgpp::datadriven::LearnerBase::getIsRegression | ( | ) | const |
determines the current mode
References isRegression.
bool sgpp::datadriven::LearnerBase::getIsVerbose | ( | ) | const |
determines the current verbose mode of learner
References isVerbose.
std::vector< std::pair< size_t, double > > sgpp::datadriven::LearnerBase::getRefinementExecTimes | ( | ) |
References ExecTimeOnStep.
|
protectedvirtual |
Initialize the grid and its coefficients.
GridConfig | structure which describes the regular start grid |
References alpha, sgpp::base::GeneralGridConfiguration::dim_, grid, sgpp::base::GeneralGridConfiguration::level_, sgpp::base::Linear, sgpp::base::LinearBoundary, sgpp::base::ModLinear, and sgpp::base::GeneralGridConfiguration::type_.
Referenced by sgpp::datadriven::LearnerLeastSquaresIdentity::testRegular(), and train().
|
virtual |
Reimplemented in sgpp::datadriven::LearnerLeastSquaresIdentity.
References sgpp::op_factory::createOperationMultipleEval(), grid, and sgpp::base::OperationMultipleEval::multTranspose().
Referenced by train().
|
protectedvirtual |
Hook-Method for post-processing after each refinement learning.
can be overwritten by derived classes
trainDataset | matrix with training data |
solver | solver |
numNeededIterations | number of required iterations |
Reimplemented in sgpp::datadriven::LearnerLeastSquaresIdentity.
References execTime, and isVerbose.
Referenced by train().
|
virtual |
executes a Regression test for a given dataset and returns the result
testDataset | dataset that is evaluated with the current learner |
classesComputed | result of the evaluation of the data set |
Reimplemented in sgpp::datadriven::LearnerLeastSquaresIdentity.
References alpha, sgpp::op_factory::createOperationMultipleEval(), sgpp::base::DataMatrix::getNrows(), grid, and sgpp::base::OperationMultipleEval::mult().
Referenced by getAccuracy(), getCassificatorQuality(), and train().
|
protectedvirtual |
Hook-Method for pre-processing before starting learning.
can be overwritten by derived classes
Referenced by train().
void sgpp::datadriven::LearnerBase::setIsVerbose | ( | const bool | isVerbose | ) |
sets the current verbose mode of learner
isVerbose | the current learner's verbose output |
References isVerbose.
void sgpp::datadriven::LearnerBase::setReuseCoefficients | ( | bool | reuseCoefficients | ) |
References reuseCoefficients.
void sgpp::datadriven::LearnerBase::setSolverVerbose | ( | bool | solverVerbose | ) |
References solverVerbose.
void sgpp::datadriven::LearnerBase::store | ( | std::string | tGridFilename, |
std::string | tAlphaFilename | ||
) |
store the grid and its current coefficients into files for further usage.
tGridFilename | filename of grid file |
tAlphaFilename | filename of coefficient file |
|
virtual |
Learning a dataset with spatially adaptive sparse grids.
trainDataset | the training dataset |
classes | classes corresponding to the training dataset |
GridConfig | configuration of the regular start grid |
SolverConfigRefine | configuration of the SLE solver during the adaptive refinements of the grid |
SolverConfigFinal | configuration of the final SLE solving step on the refined grid |
AdaptConfig | configuration of the adaptivity strategy |
testAccDuringAdapt | set to true if the training accuracy should be determined in evert refinement step |
lambdaRegularization | regularization parameter lambda |
testDataset | the test dataset (for accuracy output, nullptr if no output is wished) |
testClasses | classes corresponding to the testing dataset (for accuracy output, nullptr if no output is wished) |
References alpha, chess::b, sgpp::solver::BiCGSTAB, sgpp::solver::CG, sgpp::base::DataVector::componentwise_mult(), createDMSystem(), currentRefinementStep, sgpp::solver::SLESolverConfiguration::eps_, sgpp::base::AdaptivityConfiguration::errorBasedRefinement, execTime, GByte, sgpp::datadriven::LearnerTiming::GByte_, sgpp::datadriven::DMSystemMatrixBase::generateb(), getAccuracy(), sgpp::base::DataMatrix::getNrows(), sgpp::solver::SGSolver::getNumberIterations(), sgpp::solver::SGSolver::getResiduum(), sgpp::base::DataVector::getSize(), sgpp::datadriven::DMSystemMatrixBase::getTimers(), GFlop, sgpp::datadriven::LearnerTiming::GFlop_, grid, python.statsfileInfo::i, InitializeGrid(), isRegression, isTrained, isVerbose, sgpp::solver::SLESolverConfiguration::maxIterations_, multTranspose(), sgpp::base::AdaptivityConfiguration::noPoints_, sgpp::base::AdaptivityConfiguration::numRefinements_, postProcessing(), predict(), sgpp::datadriven::DMSystemMatrixBase::prepareGrid(), preProcessing(), reuseCoefficients, sgpp::solver::SGSolver::setEpsilon(), sgpp::solver::SGSolver::setMaxIterations(), sgpp::solver::SLESolver::solve(), solverVerbose, sgpp::base::DataVector::sqr(), sgpp::base::SGppStopwatch::start(), stepExecTime, sgpp::base::SGppStopwatch::stop(), sgpp::base::DataVector::sub(), sgpp::base::AdaptivityConfiguration::threshold_, sgpp::datadriven::LearnerTiming::timeComplete_, sgpp::datadriven::LearnerTiming::timeMultComplete_, sgpp::datadriven::LearnerTiming::timeMultCompute_, sgpp::datadriven::LearnerTiming::timeMultTransComplete_, sgpp::datadriven::LearnerTiming::timeMultTransCompute_, sgpp::datadriven::LearnerTiming::timeRegularization_, and sgpp::solver::SLESolverConfiguration::type_.
Referenced by train().
LearnerTiming sgpp::datadriven::LearnerBase::train | ( | sgpp::base::DataMatrix & | trainDataset, |
sgpp::base::DataVector & | classes, | ||
const sgpp::base::RegularGridConfiguration & | GridConfig, | ||
const sgpp::solver::SLESolverConfiguration & | SolverConfig, | ||
const double | lambdaRegularization | ||
) |
Learning a dataset with regular sparse grids.
trainDataset | the training dataset |
classes | classes corresponding to the training dataset |
GridConfig | configuration of the regular grid |
SolverConfig | configuration of the SLE solver |
lambdaRegularization | regularization parameter lambda |
References sgpp::base::AdaptivityConfiguration::maxLevelType_, sgpp::base::AdaptivityConfiguration::noPoints_, sgpp::base::AdaptivityConfiguration::numRefinements_, sgpp::base::AdaptivityConfiguration::percent_, sgpp::base::AdaptivityConfiguration::threshold_, and train().
|
protected |
the grid's coefficients
Referenced by dumpFunction(), dumpGrid(), getAlpha(), InitializeGrid(), LearnerBase(), sgpp::datadriven::LearnerLeastSquaresIdentity::predict(), predict(), python.learner.Classifier.Classifier::refineGrid(), sgpp::datadriven::LearnerLeastSquaresIdentity::testRegular(), and train().
|
protected |
the current refinment step during training
Referenced by LearnerBase(), and train().
|
protected |
execution time
Referenced by LearnerBase(), sgpp::datadriven::LearnerLeastSquaresIdentity::postProcessing(), postProcessing(), sgpp::datadriven::LearnerLeastSquaresIdentity::testRegular(), and train().
|
protected |
Referenced by getRefinementExecTimes().
|
protected |
number of transferred Gbytes
Referenced by LearnerBase(), sgpp::datadriven::LearnerLeastSquaresIdentity::postProcessing(), and train().
|
protected |
number of executed Floating Point operations
Referenced by LearnerBase(), sgpp::datadriven::LearnerLeastSquaresIdentity::postProcessing(), and train().
|
protected |
sparse grid object
Referenced by sgpp::datadriven::Learner::createDMSystem(), sgpp::datadriven::LearnerLeastSquaresIdentity::createDMSystem(), python.uq.learner.Interpolant.Interpolant::doLearningIteration(), dumpFunction(), dumpGrid(), 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(), InitializeGrid(), python.uq.learner.Regressor.Regressor::learnData(), python.uq.learner.Regressor.Regressor::learnDataWithFolding(), python.uq.learner.Regressor.Regressor::learnDataWithTest(), LearnerBase(), sgpp::datadriven::LearnerLeastSquaresIdentity::multTranspose(), multTranspose(), sgpp::datadriven::LearnerLeastSquaresIdentity::postProcessing(), sgpp::datadriven::LearnerLeastSquaresIdentity::predict(), predict(), python.learner.Classifier.Classifier::refineGrid(), python.learner.Regressor.Regressor::refineGrid(), python.uq.learner.Regressor.Regressor::refineGrid(), python.uq.learner.SimulationLearner.SimulationLearner::refineGrid(), sgpp::datadriven::LearnerLeastSquaresIdentity::testRegular(), train(), python.learner.Classifier.Classifier::updateResults(), python.learner.Regressor.Regressor::updateResults(), and python.uq.learner.Regressor.Regressor::updateResults().
|
protected |
is regression selected
Referenced by getAccuracy(), getCassificatorQuality(), getIsRegression(), LearnerBase(), and train().
|
protected |
is the grid trained
Referenced by dumpFunction(), dumpGrid(), LearnerBase(), and train().
|
protected |
is verbose output enabled
Referenced by getIsVerbose(), LearnerBase(), sgpp::datadriven::LearnerLeastSquaresIdentity::postProcessing(), postProcessing(), setIsVerbose(), and train().
|
protected |
shall the coefficients be reused between refinement steps
Referenced by LearnerBase(), sgpp::datadriven::LearnerLeastSquaresIdentity::postProcessing(), setReuseCoefficients(), and train().
|
protected |
sets the verbose option for the solver
Referenced by LearnerBase(), setSolverVerbose(), and train().
|
protected |
execution time for current refinement to calculate the GFlops at the current timestep only otherwise accumulated GFlops (all refinement steps) are calculated
Referenced by LearnerBase(), and train().
|
protected |
number of transferred Gbytes in the current refinement step
Referenced by LearnerBase().
|
protected |
number of executed Floating Point operations in the current refinement step
Referenced by LearnerBase().