![]() |
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. | |
void | dumpGrid (std::string tFilename) |
simple dump of grid points into file, e.g. | |
virtual double | getAccuracy (const sgpp::base::DataVectorSP &classesComputed, const sgpp::base::DataVectorSP &classesReference, const float threshold=0.0) |
compute the accuracy for given testDataset. | |
virtual double | getAccuracy (sgpp::base::DataMatrixSP &testDataset, const sgpp::base::DataVectorSP &classesReference, const float threshold=0.0) |
compute the accuracy for given testDataset. | |
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! | |
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 | |
bool | getIsRegression () const |
determines the current mode | |
bool | getIsVerbose () const |
determines the current verbose mode of learner | |
LearnerBaseSP (const bool isRegression, const bool isVerbose=true) | |
Constructor. | |
LearnerBaseSP (const LearnerBaseSP ©Me) | |
Copy-Constructor. | |
LearnerBaseSP (std::string tGridFilename, std::string tAlphaFilename, const bool isRegression, const bool isVerbose=true) | |
Constructor. | |
virtual sgpp::base::DataVectorSP | predict (sgpp::base::DataMatrixSP &testDataset) |
executes a Regression test for a given dataset and returns the result | |
void | setIsVerbose (const bool isVerbose) |
sets the current verbose mode of learner | |
void | store (std::string tGridFilename, std::string tAlphaFilename) |
store the grid and its current coefficients into files for further usage. | |
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. | |
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 &adaptivityConfig, bool testAccDuringAdapt, const float lambdaRegularization) |
Learning a dataset with spatially adaptive sparse grids. | |
virtual | ~LearnerBaseSP () |
Destructor. | |
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! | |
virtual void | InitializeGrid (const sgpp::base::RegularGridConfiguration &gridConfig) |
Initialize the grid and its coefficients. | |
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. | |
virtual void | preProcessing () |
Hook-Method for pre-processing before starting learning. | |
Protected Attributes | |
sgpp::base::DataVectorSP * | alpha_ |
the grid's coefficients | |
double | execTime_ |
execution time | |
double | GByte_ |
number of transferred Gbytes | |
double | GFlop_ |
number of executed Floating Point operations | |
sgpp::base::Grid * | grid_ |
sparse grid object | |
bool | isRegression_ |
is regression selected | |
bool | isTrained_ |
is the grid trained | |
bool | isVerbose_ |
is verbose output enabled | |
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_, execTime_, GByte_, GFlop_, grid_, isRegression_, isTrained_, 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_, isTrained_, 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_, isTrained_, and sgpp::base::GridPrinter::printSparseGrid().
|
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(), and isRegression_.
|
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 getAccuracy(), and predict().
Referenced by getAccuracy(), and train().
|
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(), isRegression_, sgpp::datadriven::ClassificatorQuality::trueNegative_, and sgpp::datadriven::ClassificatorQuality::truePositive_.
|
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 getCassificatorQuality(), and predict().
Referenced by getCassificatorQuality().
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 |
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 |
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 |
References isVerbose_.
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 |
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 adaptivityConfig, sgpp::base::AdaptivityConfiguration::maxLevelType_, sgpp::base::AdaptivityConfiguration::numRefinementPoints_, sgpp::base::AdaptivityConfiguration::numRefinements_, sgpp::base::AdaptivityConfiguration::percent_, sgpp::base::AdaptivityConfiguration::refinementThreshold_, and train().
|
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 |
adaptivityConfig | 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 adaptivityConfig, alpha_, sgpp::solver::BiCGSTAB, sgpp::solver::CG, sgpp::base::PrecisionConverter::convertDataVectorSPToDataVector(), createDMSystem(), sgpp::solver::SLESolverSPConfiguration::eps_, execTime_, GByte_, sgpp::datadriven::LearnerTiming::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_, InitializeGrid(), isRegression_, isTrained_, isVerbose_, sgpp::solver::SLESolverSPConfiguration::maxIterations_, sgpp::base::AdaptivityConfiguration::numRefinementPoints_, sgpp::base::AdaptivityConfiguration::numRefinements_, postProcessing(), preProcessing(), sgpp::datadriven::DMSystemMatrixBaseSP::rebuildLevelAndIndex(), sgpp::base::GridGenerator::refine(), sgpp::base::AdaptivityConfiguration::refinementThreshold_, 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::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().
|
protected |
the grid's coefficients
Referenced by dumpFunction(), dumpGrid(), InitializeGrid(), LearnerBaseSP(), predict(), train(), and ~LearnerBaseSP().
|
protected |
execution time
Referenced by LearnerBaseSP(), postProcessing(), and train().
|
protected |
number of transferred Gbytes
Referenced by LearnerBaseSP(), and train().
|
protected |
number of executed Floating Point operations
Referenced by LearnerBaseSP(), and train().
|
protected |
sparse grid object
Referenced by dumpFunction(), dumpGrid(), InitializeGrid(), LearnerBaseSP(), predict(), train(), and ~LearnerBaseSP().
|
protected |
is regression selected
Referenced by getAccuracy(), getCassificatorQuality(), getIsRegression(), LearnerBaseSP(), and train().
|
protected |
is the grid trained
Referenced by dumpFunction(), dumpGrid(), LearnerBaseSP(), and train().
|
protected |
is verbose output enabled
Referenced by getIsVerbose(), postProcessing(), setIsVerbose(), and train().