sylvainschmitt / SSDM

Stacked Species Distribution Modelling R package
Other
41 stars 17 forks source link

The issue of the evaluate value in SSDM exceeding 1 #127

Closed zakzom closed 6 months ago

zakzom commented 1 year ago

Dear Sylvain and Lukas, I'm so sorry for all the questions and have a doubt about stacking modles. When executing the stacking (), (this process hasn't report error).the evaluate value in the resulting SSDM model was obtained, and it was found that the value of prediction.success was greater than 1,That made me confuse, By looking through the instructions for using the evaluate of SSDM specified by Pottier, J. and others, it is determined that the calculation method of prediction.success is defined, and theoretically the final value should not be greater than one.Later, I checked the values of AlgoCorr and AlgoEval of each part of the ESDM and did not find the problem.

After checking the SSDM/R/evaluate.R part, I found that the number of columns in conf should not be less than the sum of a and b, but why is my prediction success value greater than one? I have tried many methods but failed to solve this situation, so I sincerely hope that you can give me some suggestions again.

 # Evaluation indices
  n <- dim(conf)[2] # Renaming according to Pottier et al, 2013
  a <- conf$TP
  b <- conf$FP
  c <- conf$FN
  d <- conf$TN
  kappa.inter <- ((a + b)*(a + c) + (c + d)*(d + b)) / n*n
  eval <- data.frame(
    'species richness error' = rowSums(pred) - rowSums(obs),
    'prediction success' = (a + d) / n,
    'kappa' = (((a + d) / n) - kappa.inter) / (1 - kappa.inter),
    'specificity' = d / (b + d),
    'sensitivity' = a / (a + c),
    'Jaccard' = a / (a + b + c)
  )

Best wishes, zakzom

Here is using code :

#i =species name
ESDM<- ensemble_modelling(c('CTA', 'SVM','GLM','GAM','MARS','GBM','RF','MAXENT','ANN'),subset(Occurrences, Occurrences$species == i),
                               Env, rep = 10, Xcol = 'Longitude', Ycol = 'Latitude',name = i,
                               ensemble.thresh = 0.70, verbose = FALSE)

SSDM <- stacking(ESDM1, ESDM2,ESDM3,ESDM4,ESDM5,ESDM6, ESDM7,ESDM8,ESDM9,ESDM10) Stack creation... naming... done. range restriction... done. diversity mapping... Local species richness computed by summing individual probabilities. done. uncertainty mapping... done. endemism mapping... done. comparing variable importnace... done. comparing algorithms correlation... done. comparing algorithms evaluation done. evaluating...

image

zakzom commented 1 year ago

Dear Sylvain and Lukas, I'm so sorry for all the questions and have a doubt about stacking modles. I think that is a bug. conf should be change to conftab.

 # Evaluation indices
  n <- dim(conf)[2] # Renaming according to Pottier et al, 2013#conf -----conftab
  a <- conf$TP
  b <- conf$FP
  c <- conf$FN
  d <- conf$TN
  kappa.inter <- ((a + b)*(a + c) + (c + d)*(d + b)) / n*n
  eval <- data.frame(
    'species richness error' = rowSums(pred) - rowSums(obs),
    'prediction success' = (a + d) / n,
    'kappa' = (((a + d) / n) - kappa.inter) / (1 - kappa.inter),
    'specificity' = d / (b + d),
    'sensitivity' = a / (a + c),
    'Jaccard' = a / (a + b + c)
  )

Best wishes, zakzom

sylvainschmitt commented 6 months ago

Definitely not, conf is the formatted conftab and conftab would not represent TP, TN, FP, and FN.