Title: | BioAcoustic eveNT classifiER |
---|---|
Description: | Create a hierarchical acoustic event species classifier out of multiple call type detectors as described in Rankin et al (2017) <doi:10.1111/mms.12381>. |
Authors: | Eric Archer [aut, cre], Taiki Sakai [aut] |
Maintainer: | Eric Archer <[email protected]> |
License: | GNU General Public License |
Version: | 0.9.6 |
Built: | 2024-10-30 06:52:30 UTC |
Source: | CRAN |
banter
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
Add a detector model to a BANTER classifier.
addBanterDetector( x, data, name, ntree, sampsize = 1, importance = FALSE, num.cores = 1 ) removeBanterDetector(x, name)
addBanterDetector( x, data, name, ntree, sampsize = 1, importance = FALSE, num.cores = 1 ) removeBanterDetector(x, name)
x |
a |
data |
detector data.frame or named list of detector data.frames. If
a data.frame, then |
name |
detector name. |
ntree |
number of trees. |
sampsize |
number or fraction of samples to use in each tree. If < 1, then it will be used to select this fraction of the smallest sample size. |
importance |
retain importance scores in model? Defaults to
|
num.cores |
number of cores to use for Random Forest model. Set to
|
a banter_model
object with the detector model added or
removed.
Eric Archer [email protected]
Rankin, S., Archer, F., Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add the 'bp' (burst pulse) detector model bant.mdl <- addBanterDetector( x = bant.mdl, data = train.data$detectors$bp, name = "bp", ntree = 50, sampsize = 1, num.cores = 1 ) bant.mdl # remove the 'bp' detector model bant.mdl <- removeBanterDetector(bant.mdl, "bp") bant.mdl
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add the 'bp' (burst pulse) detector model bant.mdl <- addBanterDetector( x = bant.mdl, data = train.data$detectors$bp, name = "bp", ntree = 50, sampsize = 1, num.cores = 1 ) bant.mdl # remove the 'bp' detector model bant.mdl <- removeBanterDetector(bant.mdl, "bp") bant.mdl
Open a browser window displaying "BANTER: A User’s Guide to Acoustic Classification".
banterGuide()
banterGuide()
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
Extract BANTER event or detector Random Forest model.
getBanterModel(x, model = "event")
getBanterModel(x, model = "event")
x |
a |
model |
name of model to extract. Default is |
a randomForest
model object.
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) # extract the event randomForest model event.rf <- getBanterModel(bant.mdl) event.rf # extract the burst pulse (bp) detector model bp.rf <- getBanterModel(bant.mdl, "bp") bp.rf
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) # extract the event randomForest model event.rf <- getBanterModel(bant.mdl) event.rf # extract the burst pulse (bp) detector model bp.rf <- getBanterModel(bant.mdl, "bp") bp.rf
Extract BANTER event data used for the Random Forest model.
getBanterModelData(x)
getBanterModelData(x)
x |
a |
the event data frame used to build the input model x
.
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) event.df <- getBanterModelData(bant.mdl) head(event.df)
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) event.df <- getBanterModelData(bant.mdl) head(event.df)
Return names of detectors loaded in BANTER model.
getDetectorNames(x)
getDetectorNames(x)
x |
a |
a vector of names.
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) getDetectorNames(bant.mdl)
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) getDetectorNames(bant.mdl)
Return sample sizes used for a BANTER model.
getSampSize(x, model = "event")
getSampSize(x, model = "event")
x |
a |
model |
name of model to extract. Default is |
a vector of sample sizes.
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 2, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) # sample size for the event model getSampSize(bant.mdl) # sample size for the burst pulse (bp) detector model getSampSize(bant.mdl, "bp")
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 2, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) # sample size for the event model getSampSize(bant.mdl) # sample size for the burst pulse (bp) detector model getSampSize(bant.mdl, "bp")
Initialize a BANTER model with event data.
initBanterModel(x)
initBanterModel(x)
x |
a data.frame of events. Every row is a unique event. Must have
columns named |
a banter_model
object without any detector models.
Values in the column species
are passed through the
make.names
function on creation to ensure they
don't include invalid characters.
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) bant.mdl
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) bant.mdl
Extract percent correctly classified by species for detector and event models.
modelPctCorrect(x)
modelPctCorrect(x)
x |
a |
a data.frame with the percent correctly classified for each model
in x
.
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) modelPctCorrect(bant.mdl)
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) modelPctCorrect(bant.mdl)
Return the number and proportion of calls in BANTER detector models.
numCalls(x, by = c("species", "event")) propCalls(x, by = c("species", "event"))
numCalls(x, by = c("species", "event")) propCalls(x, by = c("species", "event"))
x |
a |
by |
return summary by |
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) # number of calls by species and event numCalls(bant.mdl, "species") numCalls(bant.mdl, "event") # proportion of calls by species and event propCalls(bant.mdl, "species") propCalls(bant.mdl, "event")
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) # number of calls by species and event numCalls(bant.mdl, "species") numCalls(bant.mdl, "event") # proportion of calls by species and event propCalls(bant.mdl, "species") propCalls(bant.mdl, "event")
Return the number of events in a BANTER model by species.
numEvents(x, model = "event")
numEvents(x, model = "event")
x |
a |
model |
name of model to extract. Default is |
a data.frame giving the number of events available for each species.
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) # number of events in event model numEvents(bant.mdl) # number of events in burst pulse (bp) detector model numEvents(bant.mdl, "bp")
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) # number of events in event model numEvents(bant.mdl) # number of events in burst pulse (bp) detector model numEvents(bant.mdl, "bp")
Plot traces of OOB error rates for detector Random Forest models.
plotDetectorTrace(x, detector = NULL)
plotDetectorTrace(x, detector = NULL)
x |
a |
detector |
names of models to plot. If set to |
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) plotDetectorTrace(bant.mdl)
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) plotDetectorTrace(bant.mdl)
Predict species of events for novel data from a BANTER model.
predict(object, ...) ## S3 method for class 'banter_model' predict(object, new.data, ...) ## S4 method for signature 'banter_model' predict(object, new.data, ...)
predict(object, ...) ## S3 method for class 'banter_model' predict(object, new.data, ...) ## S4 method for signature 'banter_model' predict(object, new.data, ...)
object |
a |
... |
unused. |
new.data |
a list of event and detector data that has the same
predictors as in the |
A list with the following elements:
the data frame used in the event model for predictions.
data.frame of predicted species and assignment probabilities for each event.
data.frame giving the number of events available for each detector.
if species
is a column in new.data
,
a table giving the classification rate for each event
At least one detector in the model must be present in new.data
.
Any detectors in the training model that are absent will have all species
proportions and the the detector propoprtion set to 0. If a column called
species
is in new.data
, columns for the original species
designation and if that matches predicted (correct
) will be added
to the predict.df
data.frame of the output.
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 2, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) # predict test data data(test.data) test.pred <- predict(bant.mdl, test.data) test.pred
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 2, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) # predict test data data(test.data) test.pred <- predict(bant.mdl, test.data) test.pred
Build full event classifier model
runBanterModel(x, ntree, sampsize = 1)
runBanterModel(x, ntree, sampsize = 1)
x |
a |
ntree |
number of trees. |
sampsize |
number or fraction of samples to use in each tree. |
a banter_model
object with the complete BANTER model.
Eric Archer [email protected]
Rankin, S., Archer, F., Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) summary(bant.mdl)
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) summary(bant.mdl)
Extract a random subsample of detections for each event and detector.
subsampleDetections(data, n)
subsampleDetections(data, n)
data |
a detector data.frame or list of detector data.frames. |
n |
a value giving the number ( |
a detector data.frame or list of detector data.frames with
no more than n
detections per event per detector.
Eric Archer [email protected]
Rankin, S., Archer, F., Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initial number of detections per event per detector sapply(train.data$detectors, function(x) table(x$event.id)) # select half of all detectors detect.half <- subsampleDetections(train.data$detectors, 0.5) sapply(detect.half, function(x) table(x$event.id)) # select 20 detections detect.20 <- subsampleDetections(train.data$detectors, 20) sapply(detect.20, function(x) table(x$event.id)) # select 10 detections fro 'ec' detector ec.10 <- subsampleDetections(train.data$detectors$ec, 10) table(ec.10$event.id)
data(train.data) # initial number of detections per event per detector sapply(train.data$detectors, function(x) table(x$event.id)) # select half of all detectors detect.half <- subsampleDetections(train.data$detectors, 0.5) sapply(detect.half, function(x) table(x$event.id)) # select 20 detections detect.20 <- subsampleDetections(train.data$detectors, 20) sapply(detect.20, function(x) table(x$event.id)) # select 10 detections fro 'ec' detector ec.10 <- subsampleDetections(train.data$detectors$ec, 10) table(ec.10$event.id)
Display summaries for event and detector models
summary(object, ...) ## S3 method for class 'banter_model' summary(object, model = "event", n = 0.5, bins = 20, ...) ## S4 method for signature 'banter_model' summary(object, model = "event", n = 0.5, bins = 20, ...)
summary(object, ...) ## S3 method for class 'banter_model' summary(object, model = "event", n = 0.5, bins = 20, ...) ## S4 method for signature 'banter_model' summary(object, model = "event", n = 0.5, bins = 20, ...)
object |
a |
... |
ignored. |
model |
name of model to summarize. Default is |
n |
number of final iterations to summarize OOB error rate for. If between 0 and 1 is taken as a proportion of chain. |
bins |
number of bins in inbag histogram. |
In the plot that is created, the upper panel shows the trace of the Random Forest model OOB rate across sequential trees in the forest. The lower plot shows a frequency histogram of the number of times each sample was inbag (used as training data in a tree in the forest). The vertical red lines indicate the expected inbag rate for samples of each species.
Eric Archer [email protected]
Rankin, S. , Archer, F. , Keating, J. L., Oswald, J. N., Oswald, M. , Curtis, A. and Barlow, J. (2017), Acoustic classification of dolphins in the California Current using whistles, echolocation clicks, and burst pulses. Marine Mammal Science 33:520-540. doi:10.1111/mms.12381
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) summary(bant.mdl)
data(train.data) # initialize BANTER model with event data bant.mdl <- initBanterModel(train.data$events) # add all detector models bant.mdl <- addBanterDetector( bant.mdl, train.data$detectors, ntree = 50, sampsize = 1, num.cores = 1 ) # run BANTER event model bant.mdl <- runBanterModel(bant.mdl, ntree = 1000, sampsize = 1) summary(bant.mdl)
A list of events and call data from detectors for testing BANTER model
data(test.data)
data(test.data)
list
A list of events and call data from detectors for training BANTER model
data(train.data)
data(train.data)
list