SG++

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

#include <DataBasedRefinementFunctor.hpp>

## 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

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

 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 threshold = 0.0 )

Constructor.

Parameters
 grids Vector of grids. current_grid_index specifies the grid to be refined alphas Vector of surpluses related to the grids data The data used to compute the sets H_k targets The classes for data refinements_num Maximum number of refinements done level_penalize If a level penalizing is multiplied to the score (2^{|l|_1}) coeff_a Scaling coefficients for the computation of H_k. Per default 1.0 threshold Threshold for refinement scores

References computeH().

inlinevirtual

## Member Function Documentation

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.

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

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

Computes the "intersection data points" of class k and l.

Referenced by computeH().

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

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

Parameters
 index The index k for H_k

References h.

Referenced by ~DataBasedRefinementFunctor().

overridevirtual

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

References grids.

Referenced by ~DataBasedRefinementFunctor().

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.

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.

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

Is point in support of basis function at gp.

Referenced by 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
 storage reference to the grids storage object seq sequence number in the coefficients array
Returns
refinement value

Implements sgpp::base::RefinementFunctor.

 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
 data Pointer to the (subset of) training data used targets Pointer to the related targets

References data, and targets.

Referenced by ~DataBasedRefinementFunctor().

 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_index The index of the grid to be refined

References current_grid_index.

Referenced by ~DataBasedRefinementFunctor().

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

protected

Referenced by computeH().

protected

The scaling coefficients for this->means.

Referenced by computeHkl().

protected

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

protected

Pointer to the training data used for determining H.

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

protected

Evaluations of data points are cached here.

Referenced by computeH(), and computeHkl().

protected

Referenced by computeH(), and getNumGrids().

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()().

protected

Referenced by operator()().

protected

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

Referenced by computeH(), and computeHkl().

protected

Referenced by getRefinementsNum().