![]() |
SG++-Doxygen-Documentation
|
LearnerSVM learns the data using support vector machines and sparse grid kernels. More...
#include <LearnerSVM.hpp>
Public Member Functions | |
double | getAccuracy (const sgpp::base::DataVector &referenceLabels, const double threshold, const sgpp::base::DataVector &predictedLabels) |
Computes the classification accuracy. | |
double | getAccuracy (sgpp::base::DataMatrix &testDataset, const sgpp::base::DataVector &referenceLabels, const double threshold) |
Computes the classification accuracy on the given dataset. | |
double | getError (sgpp::base::DataMatrix &data, sgpp::base::DataVector &labels, std::string errorType) |
Computes specified error type (e.g. | |
void | initialize (size_t budget) |
Initializes the SVM learner. | |
LearnerSVM (base::RegularGridConfiguration &gridConfig, base::AdaptivityConfiguration &adaptivityConfig, base::DataMatrix &pTrainData, base::DataVector &pTrainLabels, base::DataMatrix &pTestData, base::DataVector &pTestLabels, base::DataMatrix *pValidData, base::DataVector *pValidLabels) | |
Constructor. | |
void | predict (sgpp::base::DataMatrix &testData, sgpp::base::DataVector &predictedLabels) |
Predicts class labels based on the trained model. | |
void | storeResults (sgpp::base::DataMatrix &testDataset) |
Stores classified data, grids and function evaluations to csv files. | |
void | train (size_t maxDataPasses, double lambda, double betaRef, std::string refType, std::string refMonitor, size_t refPeriod, double errorDeclineThreshold, size_t errorDeclineBufferSize, size_t minRefInterval) |
Implements support vector learning with sparse grid kernels. | |
~LearnerSVM () | |
Destructor. | |
Public Attributes | |
sgpp::base::DataVector | avgErrors |
double | error |
Protected Member Functions | |
std::unique_ptr< base::Grid > | createRegularGrid () |
Generates a regular sparse grid. | |
Protected Attributes | |
base::AdaptivityConfiguration | adaptivityConfig |
std::unique_ptr< base::Grid > | grid |
base::RegularGridConfiguration | gridConfig |
std::unique_ptr< PrimalDualSVM > | svm |
base::DataMatrix & | testData |
base::DataVector & | testLabels |
base::DataMatrix & | trainData |
base::DataVector & | trainLabels |
base::DataMatrix * | validData |
base::DataVector * | validLabels |
LearnerSVM learns the data using support vector machines and sparse grid kernels.
As learning algorithm the Pegasos-method is implemented.
sgpp::datadriven::LearnerSVM::LearnerSVM | ( | base::RegularGridConfiguration & | gridConfig, |
base::AdaptivityConfiguration & | adaptivityConfig, | ||
base::DataMatrix & | pTrainData, | ||
base::DataVector & | pTrainLabels, | ||
base::DataMatrix & | pTestData, | ||
base::DataVector & | pTestLabels, | ||
base::DataMatrix * | pValidData, | ||
base::DataVector * | pValidLabels | ||
) |
Constructor.
gridConfig | The grid configuration |
adaptivityConfig | The refinement configuration |
pTrainData | The training dataset |
pTrainLabels | The corresponding training labels |
pTestData | The test dataset |
pTestLabels | The corresponding test labels |
pValidData | The validation dataset |
pValidLabels | The corresponding validation labels |
sgpp::datadriven::LearnerSVM::~LearnerSVM | ( | ) |
Destructor.
|
protected |
Generates a regular sparse grid.
References sgpp::base::Grid::createModLinearGrid(), sgpp::base::GeneralGridConfiguration::dim_, gridConfig, sgpp::base::GeneralGridConfiguration::level_, sgpp::base::ModLinear, and sgpp::base::GeneralGridConfiguration::type_.
Referenced by initialize().
double sgpp::datadriven::LearnerSVM::getAccuracy | ( | const sgpp::base::DataVector & | referenceLabels, |
const double | threshold, | ||
const sgpp::base::DataVector & | predictedLabels | ||
) |
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(), and sgpp::base::DataVector::getSize().
double sgpp::datadriven::LearnerSVM::getAccuracy | ( | sgpp::base::DataMatrix & | testDataset, |
const sgpp::base::DataVector & | referenceLabels, | ||
const double | threshold | ||
) |
Computes the classification accuracy on the given dataset.
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 getAccuracy(), sgpp::base::DataMatrix::getNrows(), and predict().
Referenced by getAccuracy(), and train().
double sgpp::datadriven::LearnerSVM::getError | ( | sgpp::base::DataMatrix & | data, |
sgpp::base::DataVector & | labels, | ||
std::string | errorType | ||
) |
void sgpp::datadriven::LearnerSVM::initialize | ( | size_t | budget | ) |
Initializes the SVM learner.
budget | The max. number of stored support vectors |
References createRegularGrid(), sgpp::base::DataMatrix::getNcols(), grid, svm, and trainData.
void sgpp::datadriven::LearnerSVM::predict | ( | sgpp::base::DataMatrix & | testData, |
sgpp::base::DataVector & | predictedLabels | ||
) |
Predicts class labels based on the trained model.
testData | The data for which class labels should be predicted |
predictedLabels | The predicted class labels |
References sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), sgpp::base::DataMatrix::getRow(), grid, sgpp::base::DataVector::set(), svm, and testData.
Referenced by getAccuracy(), storeResults(), and train().
void sgpp::datadriven::LearnerSVM::storeResults | ( | sgpp::base::DataMatrix & | testDataset | ) |
Stores classified data, grids and function evaluations to csv files.
testDataset | Data points for which the model is evaluated |
References sgpp::base::DataMatrix::appendRow(), sgpp::base::HashGridStorage::begin(), sgpp::base::HashGridStorage::end(), 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, predict(), sgpp::base::DataVector::set(), and svm.
void sgpp::datadriven::LearnerSVM::train | ( | size_t | maxDataPasses, |
double | lambda, | ||
double | betaRef, | ||
std::string | refType, | ||
std::string | refMonitor, | ||
size_t | refPeriod, | ||
double | errorDeclineThreshold, | ||
size_t | errorDeclineBufferSize, | ||
size_t | minRefInterval | ||
) |
Implements support vector learning with sparse grid kernels.
maxDataPasses | The number of passes over the whole training data |
lambda | The regularization parameter |
betaRef | Weighting factor for grid points; used within combined-measure refinement |
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) |
errorDeclineThreshold | The convergence threshold (if convergence-based refinement is chosen) |
errorDeclineBufferSize | The number of error measurements which are used to check convergence (if convergence-based refinement is chosen) |
minRefInterval | The minimum number of data points which have to be processed before next refinement can be scheduled (if convergence-based refinement is chosen) |
References adaptivityConfig, sgpp::base::DataVector::append(), avgErrors, error, sgpp::base::ForwardSelectorRefinement::free_refine(), sgpp::base::ImpurityRefinement::free_refine(), sgpp::base::DataVector::get(), getAccuracy(), getError(), sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), sgpp::base::DataMatrix::getRow(), grid, lambda, sgpp::base::AdaptivityConfiguration::numRefinementPoints_, predict(), sgpp::datadriven::RefinementMonitor::pushToBuffer(), sgpp::datadriven::RefinementMonitor::refinementsNecessary(), sgpp::base::AdaptivityConfiguration::refinementThreshold_, svm, testData, testLabels, trainData, trainLabels, validData, and validLabels.
|
protected |
Referenced by train().
sgpp::base::DataVector sgpp::datadriven::LearnerSVM::avgErrors |
Referenced by train().
double sgpp::datadriven::LearnerSVM::error |
Referenced by python.uq.dists.J.J::discretize(), python.learner.Regressor.Regressor::evalError(), python.uq.learner.Regressor.Regressor::evalError(), getError(), python.learner.Regressor.Regressor::getL2NormError(), python.uq.learner.Regressor.Regressor::getL2NormError(), python.learner.Regressor.Regressor::getMaxError(), python.uq.learner.Regressor.Regressor::getMaxError(), python.learner.Regressor.Regressor::getMinError(), python.uq.learner.Regressor.Regressor::getMinError(), and train().
|
protected |
Referenced by python.uq.dists.SGDEdist.SGDEdist::__str__(), python.learner.Learner.Learner::applyData(), python.tools.Matrix::ApplyMatrix(), python.uq.dists.SGDEdist.SGDEdist::cdf(), python.uq.learner.Interpolant.Interpolant::doLearningIteration(), python.learner.Learner.Learner::doLearningIteration(), python.learner.Classifier.Classifier::evalError(), python.uq.learner.Interpolant.Interpolant::evalError(), python.tools.Matrix::generateb(), python.controller.CheckpointController.CheckpointController::generateFoldValidationJob(), python.uq.learner.SimulationLearner.SimulationLearner::getCollocationNodes(), getError(), python.uq.learner.SimulationLearner.SimulationLearner::getGrid(), python.uq.learner.SimulationLearner.SimulationLearner::getLearner(), initialize(), python.learner.Learner.Learner::learnData(), python.learner.Learner.Learner::learnDataWithFolding(), python.uq.learner.Regressor.Regressor::learnDataWithFolding(), python.learner.Learner.Learner::learnDataWithTest(), python.uq.learner.Regressor.Regressor::learnDataWithTest(), python.controller.CheckpointController.CheckpointController::loadAll(), python.uq.operations.forcePositivity.operationMakePositive.OperationMakePositive::makePositive(), python.uq.operations.forcePositivity.operationMakePositiveFast.OperationMakePositiveFast::makePositive(), python.uq.dists.SGDEdist.SGDEdist::mean(), python.uq.dists.SGDEdist.SGDEdist::pdf(), python.uq.dists.SGDEdist.SGDEdist::ppf(), predict(), python.learner.Classifier.Classifier::refineGrid(), python.learner.Regressor.Regressor::refineGrid(), python.uq.learner.Regressor.Regressor::refineGrid(), python.uq.learner.SimulationLearner.SimulationLearner::refineGrid(), python.controller.CheckpointController.CheckpointController::saveGrid(), python.controller.CheckpointController.CheckpointController::setGrid(), python.learner.Learner.Learner::setGrid(), python.uq.learner.Learner.Learner::setGrid(), python.uq.operations.forcePositivity.localFullGridSearch.LocalFullGrid::split(), storeResults(), python.uq.dists.SGDEdist.SGDEdist::toJson(), train(), and python.uq.dists.SGDEdist.SGDEdist::var().
|
protected |
Referenced by createRegularGrid().
|
protected |
Referenced by getError(), initialize(), predict(), storeResults(), and train().
|
protected |
|
protected |
Referenced by train().
|
protected |
Referenced by python.uq.dists.KDEDist.KDEDist::__init__(), python.uq.dists.LibAGFDist.LibAGFDist::cdf(), python.uq.dists.EstimatedDist.EstimatedDist::getSamples(), initialize(), python.uq.dists.KDEDist.KDEDist::marginalize(), python.uq.dists.SGDEdist.SGDEdist::marginalize(), python.uq.dists.KDEDist.KDEDist::marginalizeToDimX(), python.uq.dists.SGDEdist.SGDEdist::marginalizeToDimX(), python.uq.dists.LibAGFDist.LibAGFDist::pdf(), python.uq.dists.LibAGFDist.LibAGFDist::ppf(), python.uq.dists.SGDEdist.SGDEdist::toJson(), and train().
|
protected |
Referenced by train().
|
protected |
Referenced by train().
|
protected |
Referenced by train().