39 #define MAX_ALGORITHMS 5
41 #define CONSENSUS_LOG_PREFIX "Consensus: "
54 "First algorithm to be used in the consensus. It must be specified by its id followed by a sequence of parameter_name=parameter_value separated by comma and enclosed by a parentheses, such as: RF(NumTrees=10,VarsPerTree=0,ForceUnsupervisedLearning=0). Existing algorithm ids and parameter names can be found in the end of the om_console request file that comes with the openModeller command line interface.",
59 "RF(NumTrees=10,VarsPerTree=0,ForceUnsupervisedLearning=1)"
67 "Second algorithm to be used in the consensus. It must be specified by its id followed by a sequence of parameter_name=parameter_value separated by comma and enclosed by a parentheses, such as: RF(NumTrees=10,VarsPerTree=0,ForceUnsupervisedLearning=0). Existing algorithm ids and parameter names can be found in the end of the om_console request file that comes with the openModeller command line interface. Leave empty if you don't want to use any further algorithms",
80 "Third algorithm to be used in the consensus. It must be specified by its id followed by a sequence of parameter_name=parameter_value separated by comma and enclosed by a parentheses, such as: RF(NumTrees=10,VarsPerTree=0,ForceUnsupervisedLearning=0). Existing algorithm ids and parameter names can be found in the end of the om_console request file that comes with the openModeller command line interface. Leave empty if you don't want to use any further algorithms",
93 "Fourth algorithm to be used in the consensus. It must be specified by its id followed by a sequence of parameter_name=parameter_value separated by comma and enclosed by a parentheses, such as: RF(NumTrees=10,VarsPerTree=0,ForceUnsupervisedLearning=0). Existing algorithm ids and parameter names can be found in the end of the om_console request file that comes with the openModeller command line interface. Leave empty if you don't want to use any further algorithms",
106 "Fifth algorithm to be used in the consensus. It must be specified by its id followed by a sequence of parameter_name=parameter_value separated by comma and enclosed by a parentheses, such as: RF(NumTrees=10,VarsPerTree=0,ForceUnsupervisedLearning=0). Existing algorithm ids and parameter names can be found in the end of the om_console request file that comes with the openModeller command line interface. Leave empty if you don't want to use any further algorithms",
119 "Sequence of weights, each one related to the corresponding algorithm, separated by space. This can be used to give more importance to certain algorithms. Use dot as decimal separator.",
124 "1.0 0.0 0.0 0.0 0.0"
131 "Minimum level of agreement",
132 "Minimum level of agreement between the algorithms. Only predictions that are agreed between the specified number of algorithms will be returned as a positive value.",
151 "Builds a consensus model with the specified algorithms",
154 "This is a kind of meta algorithm that receives other algorithms as parameters so that it can generate the individual models and then merge the results into an aggregated model. The maximum number of algorithms is limited to 5. Leave the algorithm parameter blank if you want to use fewer algorithms. IMPORTANT: To specify an algorithm you need to know the algorithm id and its parameters names in openModeller (you can do this by inspecting the request.txt file that comes as an exemple in the command-line interface). Before merging the models, each individual model is transformed into a binary model using the lowest presence threshold. You can assign different weights to each algorithm and also specify the minimum level of agreement between the algorithms. A minimum level of 3 when 5 algorithms are used means that, when less than 3 algorithms agree on a prediction, the result will be zero, so the final model only shows areas where the specified number of algorithms agree on the prediction.",
156 "Renato De Giovanni",
159 "Renato De Giovanni",
160 "renato [at] cria . org . br",
196 _initialized( false ),
208 for (
int i=0; i < (int)
_algs.size(); i++ ) {
270 if ( _agreement < 1 || _agreement >
_num_algs ) {
280 std::string weights_param;
288 stringstream ss(weights_param);
291 while ( getline(ss, weight,
' ') ) {
294 sscanf( weight.c_str(),
"%lf", &weight_val );
320 _algs[j]->setSampler( fresh_sampler );
321 _algs[j]->initialize();
333 alg_str.erase( std::remove_if( alg_str.begin(), alg_str.end(), ::isspace ), alg_str.end() );
335 if ( alg_str.size() == 0 ) {
341 size_t ini_p = alg_str.find(
"(" );
344 if ( ini_p == string::npos ) {
349 _algs.push_back( alg );
351 _norms.push_back( alg->getNormalizer() );
359 std::string alg_id = alg_str.substr(0, ini_p);
362 size_t end_p = alg_str.find(
")" );
364 if ( end_p == string::npos ) {
369 else if ( end_p < ini_p ) {
375 std::string alg_params = alg_str.substr(ini_p + 1, end_p - ini_p -1);
377 vector<string> pairs;
378 stringstream ss(alg_params);
381 while ( getline(ss, pair,
',') ) {
383 pairs.push_back(pair);
389 for (
int i = 0; i < nparam; i++) {
391 size_t eq = pairs[i].find(
"=" );
393 if ( eq == string::npos || eq == 0 ) {
399 std::string param_id = pairs[i].substr(0, eq);
400 std::string param_val = pairs[i].substr(eq+1);
402 params.insert( std::pair<icstring,std::string>(param_id, param_val) );
407 alg->setParameters( params );
409 _algs.push_back( alg );
411 _norms.push_back( alg->getNormalizer() );
446 while ( p_iterator != p_end ) {
448 Sample env = (*p_iterator)->environment();
455 _norms[j]->normalize( &mysamp );
456 val =
_algs[j]->getValue( mysamp );
460 val =
_algs[j]->getValue( env );
480 float progress = 0.0;
484 progress +=
_algs[j]->getProgress();
487 return progress/(float)_num_algs;
513 _norms[i]->normalize( &y );
514 v =
_algs[i]->getValue( y );
518 v =
_algs[i]->getValue( x );
554 config->addSubsection( model_config );
556 model_config->addNameValue(
"Thresholds",
_thresholds );
559 model_config->addSubsection( algs_config );
564 algs_config->addSubsection( alg_config );
573 if ( ! model_config )
591 std::string weights_param;
604 stringstream ss(weights_param);
607 while ( getline(ss, weight,
' ') ) {
610 sscanf( weight.c_str(),
"%lf", &weight_val );
627 _thresholds = model_config->getAttributeAsSample(
"Thresholds" );
631 if ( ! algs_config ) {
639 Configuration::subsection_list::const_iterator end = subelements.end();
640 Configuration::subsection_list::const_iterator it = subelements.begin();
641 for ( ; it != end; ++it ) {
645 if ( subelement->getName() ==
"Algorithm" ) {
649 _algs.push_back( alg );
651 _norms.push_back( alg->getNormalizer() );
Normalizer * getNormalizer() const
vector< AlgorithmPtr > _algs
float getProgress() const
OM_ALG_DLL_EXPORT AlgMetadata const * algorithmMetadata()
std::vector< ConfigurationPtr > subsection_list
static AlgorithmPtr newAlgorithm(std::string const id)
double Scalar
Type of map values.
vector< Normalizer * > _norms
SamplerPtr cloneSampler(const SamplerPtr &orig)
static Log * instance()
Returns the instance pointer, creating the object on the first call.
int getConvergence(Scalar *const val) const
void error(const char *format,...)
'Error' level.
int getParameter(std::string const &name, std::string *value)
void resize(std::size_t size)
OM_ALG_DLL_EXPORT AlgorithmImpl * algorithmFactory()
std::map< icstring, std::string > ParamSetType
void _getConfiguration(ConfigurationPtr &) const
static AlgParamMetadata parameters[NUM_PARAM]
void _setConfiguration(const ConstConfigurationPtr &)
bool _setAlgorithm(std::string alg_str)
std::vector< OccurrencePtr >::const_iterator const_iterator
Scalar getValue(const Sample &x) const
static AlgMetadata metadata
#define CONSENSUS_LOG_PREFIX