View source: R/SOptim_FitnessFunctions.R
fitFuncGeneric | R Documentation |
The fitness function takes a candidate solution to the problem as input (in this case the segmentation parameters) and produces an output value measuring how "fit" or how "good" the solution is with respect to the problem in hand (i.e., classification performance results).
fitFuncGeneric(
x,
rstFeatures,
trainData,
segmentMethod,
...,
trainThresh = 0.5,
segmStatsFuns = c("mean", "sd"),
bylayer = FALSE,
tiles = NULL,
classificationMethod = "RF",
classificationMethodParams = NULL,
balanceTrainData = FALSE,
balanceMethod = "ubUnder",
evalMethod = "5FCV",
trainPerc = 0.8,
nRounds = 20,
evalMetric = "Kappa",
minTrainCases = 30,
minCasesByClassTrain = 10,
minCasesByClassTest = 10,
minImgSegm = 30,
ndigits = 2,
verbose = TRUE
)
x |
Vector with segmentation parameters that will be optimized by the genetic algorithms from GA package. |
rstFeatures |
Features used for supervised classification (typically a multi-layer SpatRaster with one feature
per band). May be defined as a string with the path to a raster dataset or a |
trainData |
Input train data used for supervised classification. It must be a |
segmentMethod |
Character string used to define the segmentation method. Available options are:
|
... |
Additional parameters passed to the segmentation functions that will not be optimized (see also:
|
trainThresh |
A threshold value defining the minimum proportion of the segment ]0, 1] that must be covered
by a certain class to be considered as a training case. This threshold will only apply if |
segmStatsFuns |
An aggregation function (e.g., |
bylayer |
Calculate statistics layer by layer instead of all at once? (slightly increases computation time but spares memory load; default: FALSE). |
tiles |
Number of times to slice the SpatRaster across row
and column direction. The total number of tiles will be given by:
|
classificationMethod |
An input string defining the classification algorithm to be used. Available options are:
|
classificationMethodParams |
A list object with a customized set of parameters to be used for the classification algorithms (default = NULL). See also generateDefaultClassifierParams to see which parameters can be changed and how to structure the list object. |
balanceTrainData |
Defines if data balancing is to be used (only available for single-class problems; default: TRUE). |
balanceMethod |
A character string used to set the data balancing method. Available methods are based on under-sampling
|
evalMethod |
A character string defining the evaluation method. The available methods are |
trainPerc |
A decimal number defining the training proportion (default: 0.8; if |
nRounds |
Number of training rounds used for holdout cross-validation (default: 20; if |
evalMetric |
A character string setting the evaluation metric or a function that calculates the performance score
based on two vectors one for observed and the other for predicted values (see below for more details).
This option defines the outcome value of the genetic algorithm fitness function and the output of grid or random search
optimization routines. Check |
minTrainCases |
The minimum number of training cases used for calibration (default: 20). If the number of rows
in |
minCasesByClassTrain |
Minimum number of cases by class for each train data split so that the classifier is able to run. |
minCasesByClassTest |
Minimum number of cases by class for each test data split so that the classifier is able to run. |
minImgSegm |
Minimum number of image segments/objects necessary to generate train data. |
ndigits |
Number of decimal plates to consider for rounding the fitness function output. For example,
if |
verbose |
Print output messages? (default: TRUE). |
"A fitness function is a particular type of objective function that is used to summarise, as a single figure of merit, how close a given design solution is to achieving the set aims" (from wikipedia). In particular the fitness function also acts as a 'wrapper' function linking together several other in the following worflow sequence:
Run segmentation and load the results;
Load train data for the segmentation generated;
Extract feature data for the segments (segment statistics calculation);
Merge calibration and feature data;
Do train/test data partitions;
Perform data balancing (if required by user and only for the train and single-class);
Perform classification using the selected algorithm;
Do performance evaluation for each subset;
Return evaluation score (fitness value);
The fitness function value (depends on the option set in evalMetric
).
Check the segmentation parameters and data used by each algorithm that must be
defined in ...
:
segmentationGeneric
,
SAGA Seeded Region Growing: segmentation_SAGA_SRG
,
GRASS Region Growing: segmentation_GRASS_RG
,
ArcGIS Mean Shift: segmentation_ArcGIS_MShift
,
TerraLib Baatz-Schaphe: segmentation_Terralib_Baatz
,
Terralib Mean Region Growing: segmentation_Terralib_MRGrow
,
RSGISLib Shepherd: segmentation_RSGISLib_Shep
,
OTB Large Scale Mean Shift: segmentation_OTB_LSMS
,
OTB Large Scale Mean Shift with two sets of parameters: segmentation_OTB_LSMS2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.