EricArcher / banter

banter is a package for creating hierarchical acoustic event classifiers out of multiple call type detectors.
9 stars 0 forks source link

runBanterModel crashes if spaces in names of detectors #2

Closed TaikiSan21 closed 5 years ago

TaikiSan21 commented 5 years ago

runBanterModel crashes with an error if there are spaces in the names of your detectors.

Error in eval(predvars, data, env) : 
  object 'prop.Click Detector_0' not found
EricArcher commented 5 years ago

would you run traceback() after this error and post the output so I can see where in runBanterModel this is happening?

TaikiSan21 commented 5 years ago

Oops, yeah that would be useful.

> traceback()
7: eval(predvars, data, env)
6: eval(predvars, data, env)
5: model.frame.default(terms(reformulate(attributes(Terms)$term.labels)), 
       data.frame(m))
4: model.frame(terms(reformulate(attributes(Terms)$term.labels)), 
       data.frame(m))
3: randomForest.formula(species ~ ., data = x@model.data, ntree = ntree, 
       sampsize = sampsize, replace = FALSE, importance = TRUE, 
       proximity = TRUE)
2: randomForest::randomForest(species ~ ., data = x@model.data, 
       ntree = ntree, sampsize = sampsize, replace = FALSE, importance = TRUE, 
       proximity = TRUE)
1: runBanterModel(bntModel, ntree = 5000, sampsize = 2)
EricArcher commented 5 years ago

Fixed. Detector names and detector predictor column names are now run through make.names in addBanterDetector to remove spaces and special characters.