Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kuenm_feval and summary not running/running slowly #66

Open
leibar4 opened this issue Sep 10, 2024 · 1 comment
Open

kuenm_feval and summary not running/running slowly #66

leibar4 opened this issue Sep 10, 2024 · 1 comment

Comments

@leibar4
Copy link

leibar4 commented Sep 10, 2024

Can anyone see anything wrong with my script? kuenm_feval is stuck on 6% for hours, I'm not sure if it's stuck or just running slowly. Either way it's a bit frustrating and I can't afford to spend too long waiting it out. 17 Final models were produced. Additionally, the summary of results also does not work.
nayaur_occ_kuenm.csv
nayaur_ind.csv
nayaur_train.csv
nayaur_test.csv
nayaur_joint.csv

##. Set the working directory --------------------------------------------

wd <- "/Users/apple/Downloads/kuenm/nayaur"
setwd(wd)
get(wd)

#1. Packages & libraries -------------------------------------------------

packages <- c("devtools", "kuenm", "NCmisc")

installed_packages <- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {install.packages(packages[!installed_packages])}
sapply(packages, require, character.only = TRUE)

If error with installing and loading kuenm:

if(!require(kuenm)){devtools::install_github("marlonecobos/kuenm")}
library(kuenm)

#2. Import data --------------------------------------------

nayaur_occurrence <- read.csv(file = "nayaur_occ_kuenm.csv")

#3. Run maxent via kuenm --------------------------------------------

#subset occ data

kuenm_occsplit(nayaur_occurrence, train.proportion = 0.75, method = "random",
save = TRUE, name = "nayaur")

#Workflow Recording
{

Preparing variables to be used in arguments

file_name <- "nayaur_enm_process"
kuenm_start(file.name = file_name)
}
#Calibration of models
{
#Creation of candidate models
{

# Variables with information to be used as arguments.

occ_joint <- "nayaur_joint.csv"
occ_tra <- "nayaur_train.csv"
M_var_dir <- "M_variables"
batch_cal <- "Candidate_Models"
out_dir <- "Candidate_models"
reg_mult <- c(seq(0.1, 1, 0.1), seq(2, 15, 1))
f_clas <- "all"
args <- "togglelayertype=t" # e.g., "maximumbackground=20000" for increasing the number of pixels in the background or
# note that some arguments are fixed in the function and should not be changed
maxent_path <- wd
wait <- TRUE
run <- TRUE

#Model creation
kuenm_cal(occ.joint = occ_joint, occ.tra = occ_tra, M.var.dir = M_var_dir, batch = batch_cal,
          out.dir = out_dir, reg.mult = reg_mult, f.clas = f_clas, args = args,
          maxent.path = maxent_path, wait = wait, run = run)

}
#Evaluation and selection of best models
{

occ_test <- "nayaur_test.csv"
out_eval <- "Calibration_results"
threshold <- 5
rand_percent <- 50
iterations <- 500
kept <- TRUE
selection <- "OR_AICc"
paral_proc <- TRUE # make this true to perform pROC calculations in parallel, recommended
# only if a powerful computer is used (see function's help)
# Note, some of the variables used here as arguments were already created for previous function

cal_eval <- kuenm_ceval(path = out_dir, occ.joint = occ_joint, occ.tra = occ_tra, occ.test = occ_test, 
                        batch = batch_cal, out.eval = out_eval, threshold = threshold, 
                        rand.percent = rand_percent, iterations = iterations, kept = kept, 
                        selection = selection, parallel.proc = paral_proc)

}
}
#Final model creation
{

batch_fin <- "Final_Models"
mod_dir <- "Final_models"
rep_n <- 10
rep_type <- "Bootstrap"
jackknife <- TRUE
G_var_dir <- "G_variables"
out_format <- "logistic"
project <- FALSE
ext_type <- "ext"
write_mess <- FALSE
write_clamp <- FALSE
wait1 <- TRUE
run1 <- TRUE
args <- "togglelayertype=t" # e.g., "maximumbackground=20000" for increasing the number of pixels in the background or

"outputgrids=false" which avoids writing grids of replicated models and only writes the

summary of them (e.g., average, median, etc.) when rep.n > 1

note that some arguments are fixed in the function and should not be changed

Again, some of the variables used here as arguments were already created for previous functions

kuenm_mod(occ.joint = occ_joint, M.var.dir = M_var_dir, out.eval = out_eval, batch = batch_fin,
rep.n = rep_n, rep.type = rep_type, jackknife = jackknife, out.dir = mod_dir,
out.format = out_format, project = project, G.var.dir = G_var_dir, ext.type = ext_type,
write.mess = write_mess, write.clamp = write_clamp, maxent.path = maxent_path, args = args,
wait = wait1, run = run1)
}
#Final model evaluation
{help(kuenm_feval)

occ_ind <- "nayaur_ind.csv"
replicates <- TRUE
out_feval <- "Final_models_evaluation"

Most of the variables used here as arguments were already created for previous functions

fin_eval <- kuenm_feval(path = mod_dir, occ.joint = occ_joint, occ.ind = occ_ind, replicates = replicates,
out.eval = out_feval, threshold = threshold, rand.percent = rand_percent,
iterations = iterations, parallel.proc = paral_proc)
}
#Summary of results ***NOT WORKING
{
spname <- "nayaur"
modstats <- "Final_model_stats"
moddir <- "Final_models"

help("kuenm_modstats")

kuenm_modstats(sp.name = spname, fmod.dir = moddir, format = "asc", project = FALSE,
statistics = c("med", "min", "max", "range"), replicated = TRUE,
out.dir = modstats)
}

@marlonecobos
Copy link
Owner

It looks to me that your coordinates are in a projected coordinate system. To my knowledge Maxent needs coordinates to be in WGS84 (non-projected) format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants