SG++-Doxygen-Documentation
|
LearnerSVM learns the data using support vector machines and sparse grid kernels. More...
#include <LearnerSVM.hpp>
Public Member Functions | |
double | getAccuracy (sgpp::base::DataMatrix &testDataset, const sgpp::base::DataVector &referenceLabels, const double threshold) |
Computes the classification accuracy on the given dataset. More... | |
double | getAccuracy (const sgpp::base::DataVector &referenceLabels, const double threshold, const sgpp::base::DataVector &predictedLabels) |
Computes the classification accuracy. More... | |
double | getError (sgpp::base::DataMatrix &data, sgpp::base::DataVector &labels, std::string errorType) |
Computes specified error type (e.g. More... | |
void | initialize (size_t budget) |
Initializes the SVM learner. More... | |
LearnerSVM (base::RegularGridConfiguration &gridConfig, base::AdaptivityConfiguration &adaptConfig, base::DataMatrix &pTrainData, base::DataVector &pTrainLabels, base::DataMatrix &pTestData, base::DataVector &pTestLabels, base::DataMatrix *pValidData, base::DataVector *pValidLabels) | |
Constructor. More... | |
void | predict (sgpp::base::DataMatrix &testData, sgpp::base::DataVector &predictedLabels) |
Predicts class labels based on the trained model. More... | |
void | storeResults (sgpp::base::DataMatrix &testDataset) |
Stores classified data, grids and function evaluations to csv files. More... | |
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. More... | |
~LearnerSVM () | |
Destructor. More... | |
Public Attributes | |
sgpp::base::DataVector | avgErrors |
double | error |
Protected Member Functions | |
std::unique_ptr< base::Grid > | createRegularGrid () |
Generates a regular sparse grid. More... | |
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 & | adaptConfig, | ||
base::DataMatrix & | pTrainData, | ||
base::DataVector & | pTrainLabels, | ||
base::DataMatrix & | pTestData, | ||
base::DataVector & | pTestLabels, | ||
base::DataMatrix * | pValidData, | ||
base::DataVector * | pValidLabels | ||
) |
Constructor.
gridConfig | The grid configuration |
adaptConfig | 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 | ( | 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 sgpp::base::DataMatrix::getNrows(), and predict().
Referenced by train().
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(), sgpp::base::DataVector::getSize(), and python.statsfileInfo::i.
double sgpp::datadriven::LearnerSVM::getError | ( | sgpp::base::DataMatrix & | data, |
sgpp::base::DataVector & | labels, | ||
std::string | errorType | ||
) |
Computes specified error type (e.g.
MSE).
data | The data points |
labels | The corresponding class labels |
errorType | The type of the error measurement (MSE or Hinge loss) |
References chess::dim, error, sgpp::base::DataVector::get(), sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), sgpp::base::DataMatrix::getRow(), grid, python.statsfileInfo::i, sgpp::base::DataVector::set(), sgpp::base::DataVector::setAll(), and svm.
Referenced by train().
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 chess::dim, sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), sgpp::base::DataMatrix::getRow(), grid, python.statsfileInfo::i, sgpp::base::DataVector::set(), and svm.
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(), chess::dim, 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, python.statsfileInfo::i, python.utils.statsfile2gnuplot::j, 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, chess::dim, error, sgpp::base::ImpurityRefinement::free_refine(), sgpp::base::ForwardSelectorRefinement::free_refine(), sgpp::base::DataVector::get(), getAccuracy(), getError(), sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), sgpp::base::DataMatrix::getRow(), grid, python.utils.sg_projections::gridStorage, python.statsfileInfo::i, sgpp::base::AdaptivityConfiguration::noPoints_, predict(), sgpp::datadriven::RefinementMonitor::pushToBuffer(), sgpp::datadriven::RefinementMonitor::refinementsNecessary(), svm, testData, testLabels, sgpp::base::AdaptivityConfiguration::threshold_, 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 getError(), and train().
|
protected |
Referenced by python.uq.learner.Interpolant.Interpolant::doLearningIteration(), python.learner.Classifier.Classifier::evalError(), python.uq.learner.Interpolant.Interpolant::evalError(), python.uq.learner.SimulationLearner.SimulationLearner::getCollocationNodes(), getError(), python.uq.learner.SimulationLearner.SimulationLearner::getGrid(), python.uq.learner.SimulationLearner.SimulationLearner::getLearner(), initialize(), python.uq.learner.Regressor.Regressor::learnData(), python.uq.learner.Regressor.Regressor::learnDataWithFolding(), python.uq.learner.Regressor.Regressor::learnDataWithTest(), predict(), python.learner.Classifier.Classifier::refineGrid(), python.learner.Regressor.Regressor::refineGrid(), python.uq.learner.Regressor.Regressor::refineGrid(), python.uq.learner.SimulationLearner.SimulationLearner::refineGrid(), storeResults(), train(), python.learner.Classifier.Classifier::updateResults(), python.learner.Regressor.Regressor::updateResults(), and python.uq.learner.Regressor.Regressor::updateResults().
|
protected |
Referenced by createRegularGrid().
|
protected |
Referenced by getError(), initialize(), predict(), storeResults(), and train().
|
protected |
Referenced by train().
|
protected |
Referenced by train().
|
protected |
|
protected |
Referenced by train().
|
protected |
Referenced by train().
|
protected |
Referenced by train().