Is the threshold user input used correctly?
After a lot of testing I'm not sure anymore, if the HaSa uses the user input correct.
Here is one example:
As the picture above shows, the input threshold was 94. In the upper probability map are 4 pixels marked with their values. In the probability below all 4 Pixels are cut out, so they were rated as part of the class even if three of them are cleary below the threshold.
Even if you consider rounding errors and truncated decimal places this seems to be wrong.
In the lines 505 to 511 in the
outer_procedure.r the threshold is implemented to the raster to make a "cut pattern".
thres <- as.numeric(decision) dummy <- maFo_rf@layer[] max_prob <- raster::cellStats(dummy, "max") thres <- (max_prob/100) * thres dummy[dummy < thres] <- 1 dummy[dummy >= thres] <- NA in.raster <- in.raster * dummy
If you assume that
max_prob = 100(%) then the threshold should be excatly 94.
(100/100) * 94 = 94
If you assume that
max_prob = 32 (max. number of models) then the threshold should be calculated like:
(32/100) * 94 = 30.08 so assuming the variable thres is an integer its value should be 30.
(30/32) * 100 = 93.75(%) so this would explain why the pixel with value 93.75% is in the class, but it doesnt explains the other two pixels with 90.62% are also assigned to that class.
To explain the assignment of these two pixles, the absolute number of models calculated from the users input has to be 29.
(29/32) * 100 = 90.625(%)
I cant see how the user's input of 94(%) leeds to the outcome of 29 models.
If the absolute number of models is low, the difference between user input and used threshold gets quite extrem. Below is an example with 5 models, an user input of 80% but all the pixel with 60% are also assigned.
@romulo @alibeam Did you also experienced this behaviour? Does it just take one model less then the input threshold? Is there something I missed in the code?