SG++-Doxygen-Documentation
|
Abstract class that implements a regression/classification learner based on spatial adaptive Sparse Grids. More...
#include <LearnerBaseSP.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::DataMatrixSP &testDataset, const sgpp::base::DataVectorSP &classesReference, const float threshold=0.0) |
compute the accuracy for given testDataset. More... | |
virtual double | getAccuracy (const sgpp::base::DataVectorSP &classesComputed, const sgpp::base::DataVectorSP &classesReference, const float threshold=0.0) |
compute the accuracy for given testDataset. More... | |
virtual ClassificatorQuality | getCassificatorQuality (sgpp::base::DataMatrixSP &testDataset, const sgpp::base::DataVectorSP &classesReference, const float 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::DataVectorSP &classesComputed, const sgpp::base::DataVectorSP &classesReference, const float threshold=0.0) |
compute the quality for given testDataset, classification ONLY! More... | |
bool | getIsRegression () const |
determines the current mode More... | |
bool | getIsVerbose () const |
determines the current verbose mode of learner More... | |
LearnerBaseSP (const bool isRegression, const bool isVerbose=true) | |
Constructor. More... | |
LearnerBaseSP (std::string tGridFilename, std::string tAlphaFilename, const bool isRegression, const bool isVerbose=true) | |
Constructor. More... | |
LearnerBaseSP (const LearnerBaseSP ©Me) | |
Copy-Constructor. More... | |
virtual sgpp::base::DataVectorSP | predict (sgpp::base::DataMatrixSP &testDataset) |
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 | 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::DataMatrixSP &testDataset, sgpp::base::DataVectorSP &classes, const sgpp::base::RegularGridConfiguration &GridConfig, const sgpp::solver::SLESolverSPConfiguration &SolverConfigRefine, const sgpp::solver::SLESolverSPConfiguration &SolverConfigFinal, const sgpp::base::AdaptivityConfiguration &AdaptConfig, bool testAccDuringAdapt, const float lambdaRegularization) |
Learning a dataset with spatially adaptive sparse grids. More... | |
LearnerTiming | train (sgpp::base::DataMatrixSP &testDataset, sgpp::base::DataVectorSP &classes, const sgpp::base::RegularGridConfiguration &GridConfig, const sgpp::solver::SLESolverSPConfiguration &SolverConfig, const float lambdaRegularization) |
Learning a dataset with regular sparse grids. More... | |
virtual | ~LearnerBaseSP () |
Destructor. More... | |
Protected Member Functions | |
virtual sgpp::datadriven::DMSystemMatrixBaseSP * | createDMSystem (sgpp::base::DataMatrixSP &trainDataset, float lambdaRegularization)=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::DataMatrixSP &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 | |
sgpp::base::DataVectorSP * | alpha_ |
the grid's coefficients More... | |
double | execTime_ |
execution time More... | |
double | GByte_ |
number of transferred Gbytes More... | |
double | GFlop_ |
number of executed Floating Point operations More... | |
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... | |
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.
This versions supports single precision datatypes.
|
explicit |
Constructor.
isRegression | flag for regression |
isVerbose | flag for verbose output |
sgpp::datadriven::LearnerBaseSP::LearnerBaseSP | ( | std::string | tGridFilename, |
std::string | tAlphaFilename, | ||
const bool | isRegression, | ||
const bool | isVerbose = true |
||
) |
Constructor.
tGridFilename | path to file that contains a serialized grid |
tAlphaFilename | path to file that contains the grid's coefficients |
isRegression | set to true if a regression task should be executed |
isVerbose | set to true in order to allow console output |
sgpp::datadriven::LearnerBaseSP::LearnerBaseSP | ( | const LearnerBaseSP & | copyMe | ) |
Copy-Constructor.
copyMe | LearnerBase that should be duplicated |
References alpha_, grid_, isRegression_, sgpp::base::Grid::serialize(), and sgpp::base::Grid::unserialize().
|
virtual |
|
protectedpure virtual |
abstract method that constructs the corresponding system of linear equations Derived classes MUST overwrite this functions!
trainDataset | training dataset |
lambdaRegularization | lambda regularization parameter |
Referenced by train().
void sgpp::datadriven::LearnerBaseSP::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_, sgpp::base::PrecisionConverter::convertDataVectorSPToDataVector(), sgpp::base::Grid::getDimension(), sgpp::base::DataVectorSP::getSize(), grid_, and sgpp::base::GridPrinter::printGrid().
void sgpp::datadriven::LearnerBaseSP::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_, sgpp::base::PrecisionConverter::convertDataVectorSPToDataVector(), sgpp::base::DataVectorSP::getSize(), grid_, 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 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::DataVectorSP::get(), sgpp::base::DataVectorSP::getSize(), python.statsfileInfo::i, sgpp::base::DataVectorSP::sqr(), sgpp::base::DataVectorSP::sub(), sgpp::base::DataVectorSP::sum(), and analyse_erg::tmp.
|
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 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::DataVectorSP::get(), sgpp::base::DataVectorSP::getSize(), python.statsfileInfo::i, sgpp::datadriven::ClassificatorQuality::trueNegative_, and sgpp::datadriven::ClassificatorQuality::truePositive_.
bool sgpp::datadriven::LearnerBaseSP::getIsRegression | ( | ) | const |
determines the current mode
References isRegression_.
bool sgpp::datadriven::LearnerBaseSP::getIsVerbose | ( | ) | const |
determines the current verbose mode of learner
References isVerbose_.
|
protectedvirtual |
Initialize the grid and its coefficients.
GridConfig | structure which describes the regular start grid |
References alpha_, sgpp::base::GeneralGridConfiguration::dim_, sgpp::base::Grid::getGenerator(), sgpp::base::Grid::getSize(), grid_, sgpp::base::GeneralGridConfiguration::level_, sgpp::base::Linear, sgpp::base::LinearBoundary, sgpp::base::ModLinear, sgpp::base::GridGenerator::regular(), sgpp::base::DataVectorSP::setAll(), and sgpp::base::GeneralGridConfiguration::type_.
Referenced by train().
|
protectedvirtual |
Hook-Method for post-processing after each refinement learning.
can be overwritten by derived classes
trainDataset | matrix with training data set |
solver | solver |
numNeededIterations | number of required iterations |
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 |
References alpha_, sgpp::base::PrecisionConverter::convertDataMatrixSPToDataMatrix(), sgpp::base::PrecisionConverter::convertDataVectorSPToDataVector(), sgpp::base::PrecisionConverter::convertDataVectorToDataVectorSP(), sgpp::op_factory::createOperationMultipleEval(), sgpp::base::DataMatrixSP::getNcols(), sgpp::base::DataMatrixSP::getNrows(), sgpp::base::Grid::getSize(), grid_, and sgpp::base::OperationMultipleEval::mult().
Referenced by getAccuracy(), and getCassificatorQuality().
|
protectedvirtual |
Hook-Method for pre-processing before starting learning.
can be overwritten by derived classes
Referenced by train().
void sgpp::datadriven::LearnerBaseSP::setIsVerbose | ( | const bool | isVerbose | ) |
sets the current verbose mode of learner
isVerbose | the current learner's verbose output |
void sgpp::datadriven::LearnerBaseSP::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.
testDataset | 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 |
References alpha_, chess::b, sgpp::solver::BiCGSTAB, sgpp::solver::CG, sgpp::base::PrecisionConverter::convertDataVectorSPToDataVector(), createDMSystem(), sgpp::solver::SLESolverSPConfiguration::eps_, execTime_, sgpp::datadriven::LearnerTiming::GByte_, GByte_, sgpp::datadriven::DMSystemMatrixBaseSP::generateb(), getAccuracy(), sgpp::base::Grid::getGenerator(), sgpp::base::DataMatrixSP::getNrows(), sgpp::solver::SGSolverSP::getNumberIterations(), sgpp::solver::SGSolverSP::getResiduum(), sgpp::base::DataVectorSP::getSize(), sgpp::base::Grid::getSize(), sgpp::datadriven::DMSystemMatrixBaseSP::getTimers(), GFlop_, sgpp::datadriven::LearnerTiming::GFlop_, grid_, python.statsfileInfo::i, InitializeGrid(), sgpp::solver::SLESolverSPConfiguration::maxIterations_, sgpp::base::AdaptivityConfiguration::noPoints_, sgpp::base::AdaptivityConfiguration::numRefinements_, postProcessing(), preProcessing(), sgpp::datadriven::DMSystemMatrixBaseSP::rebuildLevelAndIndex(), sgpp::base::GridGenerator::refine(), sgpp::base::DataVectorSP::resizeZero(), sgpp::solver::SGSolverSP::setEpsilon(), sgpp::solver::SGSolverSP::setMaxIterations(), sgpp::solver::SLESolverSP::solve(), sgpp::base::SGppStopwatch::start(), sgpp::base::SGppStopwatch::stop(), 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::SLESolverSPConfiguration::type_.
Referenced by train().
LearnerTiming sgpp::datadriven::LearnerBaseSP::train | ( | sgpp::base::DataMatrixSP & | testDataset, |
sgpp::base::DataVectorSP & | classes, | ||
const sgpp::base::RegularGridConfiguration & | GridConfig, | ||
const sgpp::solver::SLESolverSPConfiguration & | SolverConfig, | ||
const float | lambdaRegularization | ||
) |
Learning a dataset with regular sparse grids.
testDataset | 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(), InitializeGrid(), LearnerBaseSP(), predict(), train(), and ~LearnerBaseSP().
|
protected |
execution time
Referenced by train().
|
protected |
number of transferred Gbytes
Referenced by train().
|
protected |
number of executed Floating Point operations
Referenced by train().
|
protected |
sparse grid object
Referenced by dumpFunction(), dumpGrid(), InitializeGrid(), LearnerBaseSP(), predict(), train(), and ~LearnerBaseSP().
|
protected |
is regression selected
Referenced by getIsRegression(), and LearnerBaseSP().
|
protected |
is the grid trained
|
protected |
is verbose output enabled
Referenced by getIsVerbose().