111 return std::string( OM_VERSION );
152 if ( ( ! presence || presence->numOccurrences() == 0 ) &&
153 ( ! absence || absence->numOccurrences() == 0 ) ) {
168 std::vector<std::string> continuous_map,
169 const std::string& mask )
188 if ( nparam && ! param ) {
199 Log::instance()->
warn(
"Sampler could not be initialized. Environment not set.\n" );
204 Log::instance()->
warn(
"Sampler could not be initialized. Occurrences not set.\n" );
223 _alg->setParameters( nparam, param );
300 string fname( output_file );
302 int pos = fname.length() - 4;
306 if ( fname.compare( pos, 4,
".bmp" ) == 0 ) {
309 Log::instance()->
warn (
"Using greyscale bmp as output format based on extension\n" );
377 const Sample& sample = env->get( x, y );
379 if ( sample.
size() == 0 ) {
385 if ( val < 0.0 ) val = 0.0;
386 if ( val > 1.0 ) val = 1.0;
397 Sample tmp(
_env->numLayers() ,environment_values );
398 return _alg->getValue( tmp );
422 double proportionAreaToSample)
424 int i, sampleSize, numCells, xdim, ydim;
444 env->getMask()->getDim(&xdim, &ydim);
445 numCells = xdim * ydim;
447 sampleSize = (int) (numCells * proportionAreaToSample);
449 for (i = 0; i < sampleSize; i++) {
451 const Sample& sample = env->getRandom();
498 config->addSubsection( sampler_config );
502 config->addSubsection( alg_config );
510 stats_config->addSubsection( cm_config );
517 stats_config->addSubsection( roc_config );
520 config->addSubsection( stats_config );
555 ConstConfigurationPtr occ_filter_config = options_config->getSubsection(
"OccurrencesFilter",
false );
557 if ( occ_filter_config ) {
563 _samp->spatiallyUnique();
566 ConstConfigurationPtr eu_config = occ_filter_config->getSubsection(
"EnvironmentallyUnique",
false );
570 _samp->environmentallyUnique();
598 string formatId = template_layer_config->getAttribute(
"Id" );
606 fileType = output_param_config->getAttribute(
"FileType" );
608 if ( ! fileType.empty() ) {
624 ConstConfigurationPtr areastats_param_config = stats_param_config->getSubsection(
"AreaStatistics" );
626 double threshold = areastats_param_config->getAttributeAsDouble(
"PredictionThreshold", 0.5 );
655 bool calc_matrix =
false;
657 int ignore_absences_int = 0;
659 bool calc_roc =
false;
661 int num_background = -1;
662 double max_omission = 1.0;
663 int use_absences_as_background_int = 0;
671 ConfigurationPtr matrix_param = statistics_param->getSubsection(
"ConfusionMatrix" );
675 std::string threshold_str = matrix_param->getAttribute(
"Threshold",
"" );
677 if ( threshold_str.compare(
"lpt" ) == 0 ) {
686 ignore_absences_int = matrix_param->getAttributeAsInt(
"IgnoreAbsences", 0 );
688 if ( threshold < 0.0 ) {
700 Log::instance()->
error(
"Cannot determine lowest training threshold without a Model and a Sampler. The default confusion matrix threshold will be used.\n" );
716 resolution = roc_param->getAttributeAsInt(
"Resolution", -1 );
718 num_background = roc_param->getAttributeAsInt(
"BackgroundPoints", -1 );
720 max_omission = roc_param->getAttributeAsDouble(
"MaxOmission", 1.0 );
722 use_absences_as_background_int = roc_param->getAttributeAsInt(
"UseAbsencesAsBackground", 0 );
739 if ( calc_matrix || calc_roc )
754 int num_presences =
_samp->numPresence();
755 int num_absences =
_samp->numAbsence();
758 if ( calc_matrix && ( num_presences || num_absences ) ) {
760 bool ignore_absences =
false;
762 if ( ignore_absences_int > 0 ) {
764 ignore_absences =
true;
773 if ( calc_roc && num_presences ) {
775 bool use_absences_as_background =
false;
779 if ( use_absences_as_background_int > 0 ) {
781 use_absences_as_background =
true;
787 if ( num_background > 0 ) {
801 if ( max_omission < 1.0 ) {
void reset(Scalar predictionThreshold=CONF_MATRIX_DEFAULT_THRESHOLD, bool ignoreAbsences=false)
void setAbortionCallback(AbortionCallback func, void *param)
void initialize(int resolution=ROC_DEFAULT_RESOLUTION)
void setProjectionConfiguration(const ConstConfigurationPtr &)
void warn(const char *format,...)
'Warn' level.
void setModelProjectionCallback(ModelProjectionCallback func, void *param)
ConfusionMatrix _confusion_matrix
int numAvailableAlgorithms()
static AlgorithmPtr newAlgorithm(std::string const id)
static AlgMetadata const ** availableAlgorithms()
void addPrediction(Scalar predictionValue)
double Scalar
Type of map values.
AreaStats * getActualAreaStats()
void setModelCallback(ModelCreationCallback func, void *param=0)
void(* ModelCreationCallback)(float progress, void *extra_param)
void calculateModelStatistics(const ConstConfigurationPtr &)
const ConfusionMatrix *const getConfusionMatrix()
static Log * instance()
Returns the instance pointer, creating the object on the first call.
void setMapCallback(ModelProjectionCallback func, void *param=0)
void setLogLevel(Log::Level level)
ConfigurationPtr getModelConfiguration() const
void setLevel(Level level)
void reset(Scalar predictionThreshold=0.5)
AreaStats * _actualAreaStats
EnvironmentPtr createEnvironment(const std::vector< std::string > &categs, const std::vector< std::string > &maps, const std::string &mask_file)
SamplerPtr createSampler(const EnvironmentPtr &env, const OccurrencesPtr &presence, const OccurrencesPtr &absence)
int createMap(const EnvironmentPtr &env, char const *output_file, MapFormat &format)
void error(const char *format,...)
'Error' level.
AreaStats * _estimatedAreaStats
void calculate(const EnvironmentPtr &env, const Model &model, const OccurrencesPtr &presences, const OccurrencesPtr &absences=OccurrencesPtr())
Scalar getValue(const ConstEnvironmentPtr &env, Coord x, Coord y)
static bool createMap(const Model &model, const EnvironmentPtr &env, Map *map, AreaStats *areaStats=0, CallbackWrapper *callbackWrapper=0)
int setOccurrences(const OccurrencesPtr &presence, const OccurrencesPtr &absence=OccurrencesPtr())
AlgMetadata const * algorithmMetadata(char const *algorithm_id)
AlgMetadata const ** availableAlgorithms()
void setAbortionCallback(AbortionCallback func, void *param=0)
static int numAvailableAlgorithms()
static RasterFactory & instance()
void setLowestTrainingThreshold(const Model &model, const SamplerPtr &sampler)
int setAlgorithm(std::string const id, int nparam, AlgParameter const *param)
static AlgMetadata const * algorithmMetadata(std::string const algorithm_id)
void setSampler(const SamplerPtr &sampler)
double getThreshold() const
bool(* AbortionCallback)(void *extra_param)
#define ROC_DEFAULT_RESOLUTION
void info(const char *format,...)
'Info' level.
void setEnvironment(std::vector< std::string > categ_map, std::vector< std::string > continuous_map, const std::string &mask)
void setModelCreationCallback(ModelCreationCallback func, void *param)
const SamplerPtr & getSampler() const
void calculate(const Model &model, const SamplerPtr &sampler)
ConfigurationPtr getConfiguration() const
AreaStats * getEstimatedAreaStats(double proportionAreaToSample=0.01)
double Coord
Type of map coordinates.
RocCurve *const getRocCurve()
ConfigurationPtr getConfiguration() const
void(* ModelProjectionCallback)(float progress, void *extra_param)
#define CONF_MATRIX_DEFAULT_THRESHOLD
CallbackWrapper _callback_wrapper
void debug(const char *format,...)
'Debug' level.
double getPartialAreaRatio(double e=1.0)
void setModelConfiguration(const ConstConfigurationPtr &)