openModeller  Version 1.5.0
RfAlgorithm Class Reference

#include <rf_alg.hh>

Inheritance diagram for RfAlgorithm:
Inheritance graph
Collaboration diagram for RfAlgorithm:
Collaboration graph

Public Member Functions

 RfAlgorithm ()
 
 ~RfAlgorithm ()
 
int needNormalization ()
 
int initialize ()
 
int iterate ()
 
float getProgress () const
 
int done () const
 
Scalar getValue (const Sample &x) const
 
int getConvergence (Scalar *const val) const
 
- Public Member Functions inherited from AlgorithmImpl
 AlgorithmImpl (AlgMetadata const *metadata)
 
virtual ~AlgorithmImpl ()
 
void setParameters (int nparam, AlgParameter const *param)
 
void setParameters (const ParamSetType &)
 
std::string const getID () const
 
AlgMetadata const * getMetadata () const
 
AlgorithmPtr getFreshCopy ()
 
virtual int supportsModelProjection () const
 
Model createModel (const SamplerPtr &samp, CallbackWrapper *func=0)
 
void setSampler (const SamplerPtr &samp)
 
virtual int finalize ()
 
NormalizergetNormalizer () const
 
void setNormalization (const SamplerPtr &samp) const
 
void setNormalization (const EnvironmentPtr &env) const
 
virtual Model getModel () const
 
ConfigurationPtr getConfiguration () const
 
void setConfiguration (const ConstConfigurationPtr &)
 
- Public Member Functions inherited from Configurable
virtual ~Configurable ()
 

Protected Member Functions

void _sampleToLine (Sample sample, stringstream &ss) const
 
void _getConfiguration (ConfigurationPtr &) const
 
void _setConfiguration (const ConstConfigurationPtr &)
 
- Protected Member Functions inherited from AlgorithmImpl
int dimDomain ()
 
int getParameter (std::string const &name, std::string *value)
 
int getParameter (std::string const &name, double *value)
 
int getParameter (std::string const &name, float *value)
 
int getParameter (std::string const &name, int *value)
 

Protected Attributes

bool _done
 
int _num_trees
 
int _k
 
bool _initialized
 
Random _rand
 
librf::InstanceSet * _set
 
vector< int > _class_weights
 
vector< librf::Tree * > _trees
 
- Protected Attributes inherited from AlgorithmImpl
SamplerPtr _samp
 
Normalizer_normalizerPtr
 
ParamSetType _param
 

Additional Inherited Members

- Public Types inherited from AlgorithmImpl
typedef std::map< icstring,
std::string > 
ParamSetType
 

Detailed Description

Declaration of RF algorithm class.

Author
Renato De Giovanni (renato [at] cria org br)
Id:
rf_alg.hh 5259 2011-01-24 14:32:50Z rdg

LICENSE INFORMATION

Copyright(c) 2010 by CRIA - Centro de Referencia em Informacao Ambiental

http://www.cria.org.br

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details:

http://www.gnu.org/copyleft/gpl.html Algorithm to generate models using Random Forests.

Definition at line 44 of file rf_alg.hh.

Constructor & Destructor Documentation

RfAlgorithm::RfAlgorithm ( )

Definition at line 153 of file rf_alg.cpp.

RfAlgorithm::~RfAlgorithm ( )

Definition at line 164 of file rf_alg.cpp.

References _initialized, _set, and _trees.

Member Function Documentation

void RfAlgorithm::_getConfiguration ( ConfigurationPtr config) const
protectedvirtual

Reimplemented from AlgorithmImpl.

Definition at line 416 of file rf_alg.cpp.

References _done, _k, _num_trees, and _trees.

void RfAlgorithm::_sampleToLine ( Sample  sample,
stringstream &  ss 
) const
protected

Definition at line 311 of file rf_alg.cpp.

References Sample::size().

Referenced by getValue(), and initialize().

Here is the call graph for this function:

void RfAlgorithm::_setConfiguration ( const ConstConfigurationPtr config)
protectedvirtual

Reimplemented from AlgorithmImpl.

Definition at line 480 of file rf_alg.cpp.

References _done, _initialized, _k, _num_trees, and _trees.

int RfAlgorithm::done ( ) const
virtual

Return != 0 if algorithm finished.

Reimplemented from AlgorithmImpl.

Definition at line 367 of file rf_alg.cpp.

References _done.

Referenced by getProgress().

int RfAlgorithm::getConvergence ( Scalar *const  val) const
virtual

Returns the algorithm's convergence value at the moment

Reimplemented from AlgorithmImpl.

Definition at line 407 of file rf_alg.cpp.

float RfAlgorithm::getProgress ( ) const
virtual

Returns progress so far (between 0.0 and 1.0)

Reimplemented from AlgorithmImpl.

Definition at line 353 of file rf_alg.cpp.

References _num_trees, _trees, and done().

Here is the call graph for this function:

Scalar RfAlgorithm::getValue ( const Sample x) const
virtual

The algorithm must return the occurrence probability at the given environment conditions.

Parameters
xEnvironmental conditions.
Returns
The occurrence probability in the range [0,1].

Implements AlgorithmImpl.

Definition at line 375 of file rf_alg.cpp.

References _sampleToLine(), and _trees.

Here is the call graph for this function:

int RfAlgorithm::initialize ( )
virtual

Initiate a new training.

Implements AlgorithmImpl.

Definition at line 187 of file rf_alg.cpp.

References _class_weights, _initialized, _k, _num_trees, _rand, AlgorithmImpl::_samp, _sampleToLine(), _set, _trees, Log::error(), Random::get(), AlgorithmImpl::getParameter(), Log::instance(), K_ID, NUMTREES_ID, RF_LOG_PREFIX, UNSUP_ID, and Log::warn().

Here is the call graph for this function:

int RfAlgorithm::iterate ( )
virtual

One step further on the training. Return 0 if something wrong happened.

Reimplemented from AlgorithmImpl.

Definition at line 325 of file rf_alg.cpp.

References _class_weights, _done, _k, _num_trees, _rand, _set, _trees, and Random::get().

Here is the call graph for this function:

int RfAlgorithm::needNormalization ( )
virtual

The algorithm should return != 0 if it needs normalization of environmental variables (non categorical ones).

Reimplemented from AlgorithmImpl.

Definition at line 179 of file rf_alg.cpp.

Member Data Documentation

vector<int> RfAlgorithm::_class_weights
protected

Definition at line 81 of file rf_alg.hh.

Referenced by initialize(), and iterate().

bool RfAlgorithm::_done
protected

Definition at line 69 of file rf_alg.hh.

Referenced by _getConfiguration(), _setConfiguration(), done(), and iterate().

bool RfAlgorithm::_initialized
protected

Definition at line 75 of file rf_alg.hh.

Referenced by _setConfiguration(), initialize(), and ~RfAlgorithm().

int RfAlgorithm::_k
protected

Definition at line 73 of file rf_alg.hh.

Referenced by _getConfiguration(), _setConfiguration(), initialize(), and iterate().

int RfAlgorithm::_num_trees
protected

Definition at line 71 of file rf_alg.hh.

Referenced by _getConfiguration(), _setConfiguration(), getProgress(), initialize(), and iterate().

Random RfAlgorithm::_rand
protected

Definition at line 77 of file rf_alg.hh.

Referenced by initialize(), and iterate().

librf::InstanceSet* RfAlgorithm::_set
protected

Definition at line 79 of file rf_alg.hh.

Referenced by initialize(), iterate(), and ~RfAlgorithm().

vector<librf::Tree*> RfAlgorithm::_trees
protected

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