![]()  | 
  
    SG++-Doxygen-Documentation
    
   | 
 
Class to host all methods required to perform the harmonica algorithm. More...
#include <Harmonica.hpp>
Public Member Functions | |
| bool | addConstraint (size_t idx, int bias) | 
| Adds a constraint based on an entry in the parity row.  More... | |
| void | calculateConstrainedSpace (const DataVector &transformedScores, double lambda, int shrink) | 
| Second step of the harmonica algorithm.  More... | |
| bool | checkConstraints () | 
| Tests all constraints for validity in the current bit configuration.  More... | |
| void | createRandomConfigs (size_t nBits, std::vector< int > &configIDs, int seed, size_t start) | 
| Function to create a vector of random numbers within the valid range of possible configurations without duplicates.  More... | |
| void | fixConfigBits (bool resetFree) | 
| resolves constraints, fixing free and dependent bits  More... | |
| Harmonica (FitterFactory *fitterFactory) | |
| Constructor.  More... | |
| int | moveToNewSpace (int configID, std::vector< ConfigurationBit *> oldFreeBits) | 
| Recalculates a configID to the new constrained binary space.  More... | |
| void | prepareConfigs (std::vector< ModelFittingBase *> &fitters, int seed, std::vector< std::string > &configStrings) | 
| First step in harmonica.  More... | |
| void | resetBits () | 
| resets bits to be able to resolve constraints again  More... | |
| void | setParameters (int configID, size_t matrixrow) | 
| Sets bits and the resulting parameter configuration based on a configID while simultaneously creating one row of the parity function matrix.  More... | |
| void | transformScores (const DataVector &source, DataVector &target) | 
| Transforms scores to accentuate the optimum.  More... | |
Protected Attributes | |
| std::vector< ConfigurationBit * > | configBits | 
| all configuration bits  More... | |
| std::vector< int > | configIDs | 
| binary configurations as integers  More... | |
| std::vector< std::unique_ptr< ConfigurationRestriction > > | constraints | 
| all constraints that currently exist  More... | |
| FitterFactory * | fitterFactory | 
| pointer to the fitterFactory to produce fitters for each configuration  More... | |
| std::vector< ConfigurationBit * > | freeBits | 
| bits that are not dependent on other bits  More... | |
| base::DataMatrix | paritymatrix | 
| matrix that holds the values of the parity function (predictors for regression) for all samples  More... | |
| std::vector< std::vector< ConfigurationBit * > > | parityrow | 
| row to create the parity matrix and the constraints  More... | |
| DataVector | savedScores | 
| Scores saved for moving configurations to new space.  More... | |
Class to host all methods required to perform the harmonica algorithm.
      
  | 
  explicit | 
Constructor.
| fitterFactory | to produce fitter type objects | 
References configBits, freeBits, and sgpp::datadriven::FitterFactory::getConfigBits().
| bool sgpp::datadriven::Harmonica::addConstraint | ( | size_t | idx, | 
| int | bias | ||
| ) | 
Adds a constraint based on an entry in the parity row.
| idx | index of the parity row that holds pointers to the bits that will be constrained | 
| bias | bias value of the constraint | 
References checkConstraints(), constraints, fixConfigBits(), parityrow, and resetBits().
Referenced by calculateConstrainedSpace().
| void sgpp::datadriven::Harmonica::calculateConstrainedSpace | ( | const DataVector & | transformedScores, | 
| double | lambda, | ||
| int | shrink | ||
| ) | 
Second step of the harmonica algorithm.
Calculates relavance of ConfigurationBits and introduces constraints to reduce the search space
| transformedScores | input (possibly transformed) scores after evaluation | 
| lambda | used for regression | 
| shrink | number of constraints to introduce | 
References addConstraint(), alpha, configIDs, DEFAULT_RES_THRESHOLD, freeBits, g, sgpp::base::DataMatrix::getNcols(), python.statsfileInfo::i, moveToNewSpace(), sgpp::base::DataVector::normalize(), paritymatrix, parityrow, and savedScores.
| bool sgpp::datadriven::Harmonica::checkConstraints | ( | ) | 
Tests all constraints for validity in the current bit configuration.
References constraints.
Referenced by addConstraint(), and moveToNewSpace().
| void sgpp::datadriven::Harmonica::createRandomConfigs | ( | size_t | nBits, | 
| std::vector< int > & | configIDs, | ||
| int | seed, | ||
| size_t | start | ||
| ) | 
Function to create a vector of random numbers within the valid range of possible configurations without duplicates.
| nBits | number of bits a configuration consists of | 
| configIDs | container to store generated random configuration ID's | 
| seed | to use in random generator | 
| start | to offset newly generated ID's from existing ones from previous iterations | 
References python.statsfileInfo::i, and sgpp::combigrid::pow().
Referenced by prepareConfigs().
| void sgpp::datadriven::Harmonica::fixConfigBits | ( | bool | resetFree | ) | 
resolves constraints, fixing free and dependent bits
References configBits, constraints, and freeBits.
Referenced by addConstraint(), moveToNewSpace(), and setParameters().
| int sgpp::datadriven::Harmonica::moveToNewSpace | ( | int | configID, | 
| std::vector< ConfigurationBit *> | oldFreeBits | ||
| ) | 
Recalculates a configID to the new constrained binary space.
| configID | binary configuration in old space as integer | 
| oldFreeBits | bits that received the old binary values | 
References checkConstraints(), fixConfigBits(), freeBits, m, and resetBits().
Referenced by calculateConstrainedSpace().
| void sgpp::datadriven::Harmonica::prepareConfigs | ( | std::vector< ModelFittingBase *> & | fitters, | 
| int | seed, | ||
| std::vector< std::string > & | configStrings | ||
| ) | 
First step in harmonica.
Configurations are prepared for evaluation and the parity function matrix is constructed for later use.
| fitters | container to store fitters for evaluation outside the class | 
| seed | for random sampling | 
| configStrings | container to store information about the configurations in string form | 
References sgpp::datadriven::FitterFactory::buildFitter(), configIDs, createRandomConfigs(), fitterFactory, freeBits, python.statsfileInfo::i, m, paritymatrix, parityrow, sgpp::datadriven::FitterFactory::printConfig(), chess::seed, and setParameters().
| void sgpp::datadriven::Harmonica::resetBits | ( | ) | 
resets bits to be able to resolve constraints again
References configBits, and constraints.
Referenced by addConstraint(), moveToNewSpace(), and setParameters().
| void sgpp::datadriven::Harmonica::setParameters | ( | int | configID, | 
| size_t | matrixrow | ||
| ) | 
Sets bits and the resulting parameter configuration based on a configID while simultaneously creating one row of the parity function matrix.
| configID | bits of the configuration as an integer | 
| matrixrow | index of the row of the parity matrix to be filled | 
References fitterFactory, fixConfigBits(), freeBits, python.statsfileInfo::i, paritymatrix, parityrow, resetBits(), sgpp::base::DataMatrix::set(), sgpp::datadriven::FitterFactory::setHarmonica(), and analyse_erg::tmp.
Referenced by prepareConfigs().
| void sgpp::datadriven::Harmonica::transformScores | ( | const DataVector & | source, | 
| DataVector & | target | ||
| ) | 
Transforms scores to accentuate the optimum.
| source | |
| target | 
References python.statsfileInfo::i, and sgpp::combigrid::pow().
      
  | 
  protected | 
all configuration bits
Referenced by fixConfigBits(), Harmonica(), and resetBits().
      
  | 
  protected | 
binary configurations as integers
Referenced by calculateConstrainedSpace(), and prepareConfigs().
      
  | 
  protected | 
all constraints that currently exist
Referenced by addConstraint(), checkConstraints(), fixConfigBits(), and resetBits().
      
  | 
  protected | 
pointer to the fitterFactory to produce fitters for each configuration
Referenced by prepareConfigs(), and setParameters().
      
  | 
  protected | 
bits that are not dependent on other bits
Referenced by calculateConstrainedSpace(), fixConfigBits(), Harmonica(), moveToNewSpace(), prepareConfigs(), and setParameters().
      
  | 
  protected | 
matrix that holds the values of the parity function (predictors for regression) for all samples
Referenced by calculateConstrainedSpace(), prepareConfigs(), and setParameters().
      
  | 
  protected | 
row to create the parity matrix and the constraints
Referenced by addConstraint(), calculateConstrainedSpace(), prepareConfigs(), and setParameters().
      
  | 
  protected | 
Scores saved for moving configurations to new space.
Referenced by calculateConstrainedSpace().