![]() |
SG++-Doxygen-Documentation
|
Classification refinement builds up the combined grid of all classes, then iterates through it always keeping track of the neighbors to detect class changes between neighbors. More...
#include <ClassificationRefinementFunctor.hpp>
Public Member Functions | |
std::vector< std::vector< size_t > > | adaptAllGrids () |
Refine and Coarsen all grids of the model. | |
ClassificationRefinementFunctor (std::vector< base::Grid * > grids, std::vector< base::DataVector * > alphas, std::vector< double > priors, size_t refinements_num=1, size_t coarsenings_num=1, bool level_penalize=true, sgpp::base::AdaptivityThresholdType thresholdType=sgpp::base::AdaptivityThresholdType::Absolute, double refinementThreshold=0.0, double coarseningThreshold=1.0, bool coarsenInitialPoints=true, size_t minimumCoarseningIndex=0) | |
Constructor. | |
size_t | getNumGrids () override |
Returns the number of grids the functor can / does refine. | |
size_t | getRefinementsNum () const override |
Returns the maximal number of points that should be refined. | |
double | getRefinementThreshold () const override |
Returns the threshold for refinement. | |
double | operator() (base::GridStorage &storage, size_t seq) const override |
This should be returning a refinement value for every grid point. | |
void | preComputeEvaluations () override |
Used if expensive computations (eg. | |
void | setGridIndex (size_t grid_index) override |
Sets the index (into the vector of grids) of the grid to be refined. | |
double | start () const override |
Returns the lower bound of refinement criterion (e.g., alpha or error) (lower bound). | |
~ClassificationRefinementFunctor () override | |
![]() | |
virtual | ~MultiGridRefinementFunctor () |
![]() | |
virtual double | getTotalRefinementValue (GridStorage &storage) const |
Returns the total sum of local (error) indicators used for refinement. | |
RefinementFunctor () | |
Constructor. | |
virtual | ~RefinementFunctor () |
Destructor. | |
Protected Member Functions | |
void | collectNeighbors (base::HashGridPoint leaf, base::HashGridPoint neighbor, size_t dim, bool isLeft) |
Stores the relation of two found neighbors. | |
std::vector< double > | getEvalVector (size_t ind, size_t seq) const |
Gets the evaluations of all grids at the coords of seq. | |
void | insertCoarseningCandidate (size_t y, std::vector< std::multimap< double, std::tuple< size_t, size_t, bool > > > &classMapsCoarsening, size_t leafSeqNumber, double score, std::tuple< size_t, size_t, bool > candidate) |
Checks if a refinement candidate should be inserted into the map of candidates. | |
int | sgn (double d) const |
void | stepDown (size_t d, size_t minDim, base::HashGridPoint &gp, std::vector< std::pair< base::HashGridPoint, base::HashGridPoint > > &neighbors) |
Iterate through the sparse grid tree. | |
Protected Attributes | |
std::vector< base::DataVector * > | alphas |
size_t | coarsenings_num |
Maximum number of coarsened points per iteration. | |
double | coarseningThreshold |
bool | coarsenInitialPoints |
Whether or not to coarsen initial grid points. | |
std::vector< base::Grid * > | grids |
bool | level_penalize |
size_t | minimumCoarseningIndex |
std::vector< std::tuple< size_t, size_t, size_t, bool, base::GridPoint::level_type > > | neighborRels |
std::vector< std::map< std::string, double > > | pre_comp_evals |
Stores grid evaluations at all grids (vector) at the union of grid point coordinates over all grids (hashed by string representation in the map) | |
std::vector< double > | priors |
size_t | refinements_num |
double | refinementThreshold |
sgpp::base::AdaptivityThresholdType | thresholdType |
base::GridStorage | total_grid |
Maximum index of the initial grid points. | |
Additional Inherited Members | |
![]() | |
typedef double | value_type |
Classification refinement builds up the combined grid of all classes, then iterates through it always keeping track of the neighbors to detect class changes between neighbors.
Only the children in the relevant dimension and direction will be added to the grid.
sgpp::datadriven::ClassificationRefinementFunctor::ClassificationRefinementFunctor | ( | std::vector< base::Grid * > | grids, |
std::vector< base::DataVector * > | alphas, | ||
std::vector< double > | priors, | ||
size_t | refinements_num = 1 , |
||
size_t | coarsenings_num = 1 , |
||
bool | level_penalize = true , |
||
sgpp::base::AdaptivityThresholdType | thresholdType = sgpp::base::AdaptivityThresholdType::Absolute , |
||
double | refinementThreshold = 0.0 , |
||
double | coarseningThreshold = 1.0 , |
||
bool | coarsenInitialPoints = true , |
||
size_t | minimumCoarseningIndex = 0 |
||
) |
Constructor.
grids | Vector of grids. current_grid_index specifies the grid to be refined |
alphas | Vector of surpluses related to the grids |
priors | Vector of priors related to the classificator |
refinements_num | Maximum number of refinements done |
coarsenings_num | Maximum number of coarsenings done |
level_penalize | If a level penalizing is multiplied to the score (2^{|l|_1}) |
thresholdType | type of the threshold: absolute score value or relative score value |
refinementThreshold | Threshold for refinement scores |
coarseningThreshold | Threshold for coarsening scores |
coarsenInitialPoints | Whether or not to coarsen initial grid points |
minimumCoarseningIndex | Mimimum index of grid points that can be coarsened, used when coarsenInitialPoints = false. |
|
inlineoverride |
std::vector< std::vector< size_t > > sgpp::datadriven::ClassificationRefinementFunctor::adaptAllGrids | ( | ) |
Refine and Coarsen all grids of the model.
References alphas, coarsenings_num, coarseningThreshold, coarsenInitialPoints, sgpp::op_factory::createOperationMultipleEval(), sgpp::base::OperationMultipleEval::eval(), sgpp::base::DataMatrix::get(), sgpp::base::HashGridPoint::getLeftChild(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridPoint::getRightChild(), sgpp::base::HashGridPoint::getRoot(), sgpp::base::HashGridStorage::getSize(), sgpp::base::HashGridPoint::getStandardCoordinates(), grids, sgpp::base::HashGridStorage::insert(), insertCoarseningCandidate(), sgpp::base::HashGridStorage::isContaining(), minimumCoarseningIndex, sgpp::base::DataVector::mult(), neighborRels, priors, sgpp::base::HashGridStorage::recalcLeafProperty(), refinements_num, refinementThreshold, sgpp::base::HashGridPoint::rehash(), sgpp::base::Relative, sgpp::base::HashGridPoint::set(), sgpp::base::DataMatrix::setColumn(), sgpp::base::DataMatrix::setRow(), stepDown(), thresholdType, and total_grid.
Referenced by sgpp::datadriven::ModelFittingClassification::adapt().
|
protected |
Stores the relation of two found neighbors.
References sgpp::base::HashGridPoint::getLevelSum(), sgpp::base::HashGridStorage::getSequenceNumber(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridStorage::isContaining(), neighborRels, and total_grid.
Referenced by stepDown().
|
protected |
Gets the evaluations of all grids at the coords of seq.
|
overridevirtual |
Returns the number of grids the functor can / does refine.
Implements sgpp::datadriven::MultiGridRefinementFunctor.
References grids.
|
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.
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.
Implements sgpp::base::RefinementFunctor.
References refinementThreshold.
|
protected |
Checks if a refinement candidate should be inserted into the map of candidates.
Referenced by adaptAllGrids().
|
overridevirtual |
This should be returning a refinement value for every grid point.
The point with the highest value will be refined first.
storage | reference to the grids storage object |
seq | sequence number in the coefficients array |
Implements sgpp::base::RefinementFunctor.
|
overridevirtual |
Used if expensive computations (eg.
grid evaluations) are cached, usually for one refinement step.
Reimplemented from sgpp::datadriven::MultiGridRefinementFunctor.
|
overridevirtual |
Sets the index (into the vector of grids) of the grid to be refined.
grid_index | The index of the grid to be refined |
Implements sgpp::datadriven::MultiGridRefinementFunctor.
|
protected |
|
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
Implements sgpp::base::RefinementFunctor.
|
protected |
Iterate through the sparse grid tree.
References collectNeighbors(), sgpp::base::HashGridPoint::get(), sgpp::base::HashGridStorage::isContaining(), level, sgpp::base::HashGridPoint::set(), stepDown(), and total_grid.
Referenced by adaptAllGrids(), and stepDown().
|
protected |
Referenced by adaptAllGrids().
|
protected |
Maximum number of coarsened points per iteration.
Referenced by adaptAllGrids().
|
protected |
Referenced by adaptAllGrids().
|
protected |
Whether or not to coarsen initial grid points.
Referenced by adaptAllGrids().
|
protected |
Referenced by adaptAllGrids(), and getNumGrids().
|
protected |
|
protected |
Referenced by adaptAllGrids().
|
protected |
Referenced by adaptAllGrids(), and collectNeighbors().
|
protected |
Stores grid evaluations at all grids (vector) at the union of grid point coordinates over all grids (hashed by string representation in the map)
|
protected |
Referenced by adaptAllGrids().
|
protected |
Referenced by adaptAllGrids(), and getRefinementsNum().
|
protected |
Referenced by adaptAllGrids(), and getRefinementThreshold().
|
protected |
Referenced by adaptAllGrids().
|
protected |
Maximum index of the initial grid points.
Referenced by adaptAllGrids(), collectNeighbors(), and stepDown().