SG++-Doxygen-Documentation
sgpp::datadriven::DataBasedRefinementFunctor Class Reference

Data based refinement uses data points to find refinement candidates. More...

#include <DataBasedRefinementFunctor.hpp>

Inheritance diagram for sgpp::datadriven::DataBasedRefinementFunctor:
sgpp::datadriven::MultiGridRefinementFunctor sgpp::base::RefinementFunctor

Public Member Functions

void computeH ()
 Recomputes the set of relevant data (the set H). More...
 
 DataBasedRefinementFunctor (std::vector< base::Grid *> grids, std::vector< base::DataVector *> alphas, base::DataMatrix *data, base::DataVector *targets, size_t refinements_num=1, bool level_penalize=false, std::vector< double > coeff_a=std::vector< double >(), double threshold=0.0)
 Constructor. More...
 
base::DataMatrixgetHk (size_t index)
 Returns a ref to the specified H_k, used for debugging /plotting. More...
 
size_t getNumGrids () override
 Returns the number of grids the functor can / does refine. More...
 
size_t getRefinementsNum () const override
 Returns the maximal number of points that should be refined. More...
 
double getRefinementThreshold () const override
 Returns the threshold for refinement. More...
 
double operator() (base::GridStorage &storage, size_t seq) const override
 This should be returning a refinement value for every grid point. More...
 
void setData (base::DataMatrix *data, base::DataVector *targets)
 Set the training data + targets which is the basis for determining relevant data points. More...
 
void setGridIndex (size_t grid_index) override
 Sets the index (into the vector of grids) of the grid to be refined. More...
 
double start () const override
 Returns the lower bound of refinement criterion (e.g., alpha or error) (lower bound). More...
 
virtual ~DataBasedRefinementFunctor ()
 
- Public Member Functions inherited from sgpp::datadriven::MultiGridRefinementFunctor
virtual void preComputeEvaluations ()
 Used if expensive computations (eg. More...
 
virtual ~MultiGridRefinementFunctor ()
 
- Public Member Functions inherited from sgpp::base::RefinementFunctor
virtual double getTotalRefinementValue (GridStorage &storage) const
 Returns the total sum of local (error) indicators used for refinement. More...
 
 RefinementFunctor ()
 Constructor. More...
 
virtual ~RefinementFunctor ()
 Destructor. More...
 

Protected Member Functions

void computeHkl (base::DataMatrix &inters, size_t cl_ind1, size_t cl_ind2)
 Computes the "intersection data points" of class k and l. More...
 
bool isWithinSupport (base::HashGridPoint &gp, base::DataVector &point) const
 Is point in support of basis function at gp. More...
 

Protected Attributes

std::vector< base::DataVector * > alphas
 
std::vector< double > coeff_a
 The scaling coefficients for this->means. More...
 
size_t current_grid_index
 
base::DataMatrixdata
 Pointer to the training data used for determining H. More...
 
base::DataMatrix evals
 Evaluations of data points are cached here. More...
 
std::vector< base::Grid * > grids
 
std::vector< base::DataMatrixh
 Each H_k contains a set of "intersection data points" between class k and all other classes. More...
 
bool level_penalize
 
std::vector< double > means
 The mean values of the PDFs given by grids, alphas Approximated using this->data. More...
 
size_t refinements_num
 
base::DataVectortargets
 Pointer to targets related to this->data. More...
 
double threshold
 

Additional Inherited Members

- Public Types inherited from sgpp::base::RefinementFunctor
typedef double value_type
 

Detailed Description

Data based refinement uses data points to find refinement candidates.

For the given data sets class-intersection sets H_k are computed. A grid points is included in H_k if for at least on class l PDF_k(point) > coeff_a_k * mu_k AND PDF_l(point) > coeff_a_l * mu_l. To determine the score of a grid point, the number of data points from H_k within the support of this grid point is taken

Constructor & Destructor Documentation

◆ DataBasedRefinementFunctor()

sgpp::datadriven::DataBasedRefinementFunctor::DataBasedRefinementFunctor ( std::vector< base::Grid *>  grids,
std::vector< base::DataVector *>  alphas,
base::DataMatrix data,
base::DataVector targets,
size_t  refinements_num = 1,
bool  level_penalize = false,
std::vector< double >  coeff_a = std::vector<double>(),
double  threshold = 0.0 
)

Constructor.

Parameters
gridsVector of grids. current_grid_index specifies the grid to be refined
alphasVector of surpluses related to the grids
dataThe data used to compute the sets H_k
targetsThe classes for data
refinements_numMaximum number of refinements done
level_penalizeIf a level penalizing is multiplied to the score (2^{|l|_1})
coeff_aScaling coefficients for the computation of H_k. Per default 1.0
thresholdThreshold for refinement scores

References computeH().

◆ ~DataBasedRefinementFunctor()

virtual sgpp::datadriven::DataBasedRefinementFunctor::~DataBasedRefinementFunctor ( )
inlinevirtual

Member Function Documentation

◆ computeH()

void sgpp::datadriven::DataBasedRefinementFunctor::computeH ( )

Recomputes the set of relevant data (the set H).

If the training data is changed, call this method to actually re-compute H. Might require a lot of time depending on the size of the training data.

References alphas, computeHkl(), sgpp::op_factory::createOperationMultipleEval(), data, evals, sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), grids, h, python.statsfileInfo::i, python.utils.statsfile2gnuplot::j, means, sgpp::base::DataMatrix::resize(), and sgpp::base::DataMatrix::setColumn().

Referenced by DataBasedRefinementFunctor(), and ~DataBasedRefinementFunctor().

◆ computeHkl()

void sgpp::datadriven::DataBasedRefinementFunctor::computeHkl ( base::DataMatrix inters,
size_t  cl_ind1,
size_t  cl_ind2 
)
protected

◆ getHk()

base::DataMatrix & sgpp::datadriven::DataBasedRefinementFunctor::getHk ( size_t  index)

Returns a ref to the specified H_k, used for debugging /plotting.

Parameters
indexThe index k for H_k

References h.

Referenced by ~DataBasedRefinementFunctor().

◆ getNumGrids()

size_t sgpp::datadriven::DataBasedRefinementFunctor::getNumGrids ( )
overridevirtual

Returns the number of grids the functor can / does refine.

Implements sgpp::datadriven::MultiGridRefinementFunctor.

References grids.

Referenced by ~DataBasedRefinementFunctor().

◆ getRefinementsNum()

size_t sgpp::datadriven::DataBasedRefinementFunctor::getRefinementsNum ( ) const
overridevirtual

Returns the maximal number of points that should be refined.

The maximal number of points to refine is set in the constructor of the implementing class.

Returns
number of points that should refined. Default value: 1.

Reimplemented from sgpp::base::RefinementFunctor.

References refinements_num.

◆ getRefinementThreshold()

double sgpp::datadriven::DataBasedRefinementFunctor::getRefinementThreshold ( ) const
overridevirtual

Returns the threshold for refinement.

Only the grid points with absolute value of refinement criterion (e.g., alpha or error) greater or equal to this threshold will be refined.

Returns
threshold value for refinement. Default value: 0.

Implements sgpp::base::RefinementFunctor.

References threshold.

◆ isWithinSupport()

bool sgpp::datadriven::DataBasedRefinementFunctor::isWithinSupport ( base::HashGridPoint gp,
base::DataVector point 
) const
protected

◆ operator()()

double sgpp::datadriven::DataBasedRefinementFunctor::operator() ( base::GridStorage storage,
size_t  seq 
) const
overridevirtual

This should be returning a refinement value for every grid point.

The point with the highest value will be refined first.

Parameters
storagereference to the grids storage object
seqsequence number in the coefficients array
Returns
refinement value

Implements sgpp::base::RefinementFunctor.

References current_grid_index, data, sgpp::base::HashGridPoint::getLevelSum(), sgpp::base::DataMatrix::getNcols(), sgpp::base::HashGridStorage::getPoint(), h, isWithinSupport(), python.utils.statsfile2gnuplot::j, level_penalize, friedman::p, and sgpp::combigrid::pow().

◆ setData()

void sgpp::datadriven::DataBasedRefinementFunctor::setData ( base::DataMatrix data,
base::DataVector targets 
)

Set the training data + targets which is the basis for determining relevant data points.

This method is only necessary in data-streaming scenarios where the training data changes overall.

Parameters
dataPointer to the (subset of) training data used
targetsPointer to the related targets

References data, and targets.

Referenced by ~DataBasedRefinementFunctor().

◆ setGridIndex()

void sgpp::datadriven::DataBasedRefinementFunctor::setGridIndex ( size_t  grid_index)
overridevirtual

Sets the index (into the vector of grids) of the grid to be refined.

Parameters
grid_indexThe index of the grid to be refined

Implements sgpp::datadriven::MultiGridRefinementFunctor.

References current_grid_index.

Referenced by ~DataBasedRefinementFunctor().

◆ start()

double sgpp::datadriven::DataBasedRefinementFunctor::start ( ) const
overridevirtual

Returns the lower bound of refinement criterion (e.g., alpha or error) (lower bound).

The refinement value of grid points to be refined have to be larger than this value

Returns
lower bound

Implements sgpp::base::RefinementFunctor.

Member Data Documentation

◆ alphas

std::vector<base::DataVector*> sgpp::datadriven::DataBasedRefinementFunctor::alphas
protected

Referenced by computeH().

◆ coeff_a

std::vector<double> sgpp::datadriven::DataBasedRefinementFunctor::coeff_a
protected

The scaling coefficients for this->means.

Referenced by computeHkl().

◆ current_grid_index

size_t sgpp::datadriven::DataBasedRefinementFunctor::current_grid_index
protected

Referenced by operator()(), and setGridIndex().

◆ data

base::DataMatrix* sgpp::datadriven::DataBasedRefinementFunctor::data
protected

Pointer to the training data used for determining H.

Referenced by computeH(), computeHkl(), operator()(), and setData().

◆ evals

base::DataMatrix sgpp::datadriven::DataBasedRefinementFunctor::evals
protected

Evaluations of data points are cached here.

Referenced by computeH(), and computeHkl().

◆ grids

std::vector<base::Grid*> sgpp::datadriven::DataBasedRefinementFunctor::grids
protected

Referenced by computeH(), and getNumGrids().

◆ h

std::vector<base::DataMatrix> sgpp::datadriven::DataBasedRefinementFunctor::h
protected

Each H_k contains a set of "intersection data points" between class k and all other classes.

These sets are the basis for the scoring process

Referenced by computeH(), getHk(), and operator()().

◆ level_penalize

bool sgpp::datadriven::DataBasedRefinementFunctor::level_penalize
protected

Referenced by operator()().

◆ means

std::vector<double> sgpp::datadriven::DataBasedRefinementFunctor::means
protected

The mean values of the PDFs given by grids, alphas Approximated using this->data.

Referenced by computeH(), and computeHkl().

◆ refinements_num

size_t sgpp::datadriven::DataBasedRefinementFunctor::refinements_num
protected

Referenced by getRefinementsNum().

◆ targets

base::DataVector* sgpp::datadriven::DataBasedRefinementFunctor::targets
protected

Pointer to targets related to this->data.

Referenced by setData().

◆ threshold

double sgpp::datadriven::DataBasedRefinementFunctor::threshold
protected

Referenced by getRefinementThreshold().


The documentation for this class was generated from the following files: