3 Part 2. Run the detector/classifier

3.1 Part 2a. Feature extraction

  library(gibbonR)

# Change this so that it points to the location on your computer
FolderPath <- '/Users/denaclink/Library/CloudStorage/Box-Box/gibbonRSampleFiles/'

# Specify the folder where the training data were saved
TrainingDataFolderLocation <- paste(FolderPath,"/TrainingDataFromRavenSelectionTables/",
                                    sep='')
  
TrainingDataMFCC <- MFCCFunction(input.dir= TrainingDataFolderLocation, min.freq = 400, max.freq = 1600,win.avg="standard")
## [1] "processing sound event 1 out of 53"
## [1] "processing sound event 2 out of 53"
## [1] "processing sound event 3 out of 53"
## [1] "processing sound event 4 out of 53"
## [1] "processing sound event 5 out of 53"
## [1] "processing sound event 6 out of 53"
## [1] "processing sound event 7 out of 53"
## [1] "processing sound event 8 out of 53"
## [1] "processing sound event 9 out of 53"
## [1] "processing sound event 10 out of 53"
## [1] "processing sound event 11 out of 53"
## [1] "processing sound event 12 out of 53"
## [1] "processing sound event 13 out of 53"
## [1] "processing sound event 14 out of 53"
## [1] "processing sound event 15 out of 53"
## [1] "processing sound event 16 out of 53"
## [1] "processing sound event 17 out of 53"
## [1] "processing sound event 18 out of 53"
## [1] "processing sound event 19 out of 53"
## [1] "processing sound event 20 out of 53"
## [1] "processing sound event 21 out of 53"
## [1] "processing sound event 22 out of 53"
## [1] "processing sound event 23 out of 53"
## [1] "processing sound event 24 out of 53"
## [1] "processing sound event 25 out of 53"
## [1] "processing sound event 26 out of 53"
## [1] "processing sound event 27 out of 53"
## [1] "processing sound event 28 out of 53"
## [1] "processing sound event 29 out of 53"
## [1] "processing sound event 30 out of 53"
## [1] "processing sound event 31 out of 53"
## [1] "processing sound event 32 out of 53"
## [1] "processing sound event 33 out of 53"
## [1] "processing sound event 34 out of 53"
## [1] "processing sound event 35 out of 53"
## [1] "processing sound event 36 out of 53"
## [1] "processing sound event 37 out of 53"
## [1] "processing sound event 38 out of 53"
## [1] "processing sound event 39 out of 53"
## [1] "processing sound event 40 out of 53"
## [1] "processing sound event 41 out of 53"
## [1] "processing sound event 42 out of 53"
## [1] "processing sound event 43 out of 53"
## [1] "processing sound event 44 out of 53"
## [1] "processing sound event 45 out of 53"
## [1] "processing sound event 46 out of 53"
## [1] "processing sound event 47 out of 53"
## [1] "processing sound event 48 out of 53"
## [1] "processing sound event 49 out of 53"
## [1] "processing sound event 50 out of 53"
## [1] "processing sound event 51 out of 53"
## [1] "processing sound event 52 out of 53"
## [1] "processing sound event 53 out of 53"
TrainingDataMFCC$class <- as.factor(TrainingDataMFCC$class)

3.2 Part 2b. Run the detector/classifier using the ‘gibbonR’ function.

  library(gibbonR)

  # Specify the folder where the training data will be saved
TestFileDirectory <- paste(FolderPath,"/GibbonTestFiles/",
                                    sep='')

# Specify output directory
OutputDirectory <-  "data/DetectAndClassifyOutput"

# Create if doesn't exist  
dir.create(OutputDirectory,recursive = TRUE)
## Warning in dir.create(OutputDirectory, recursive = TRUE):
## 'data/DetectAndClassifyOutput' already exists
# Run the function to detect and classify  
gibbonR(input=TestFileDirectory,
          input.type = 'directory',
                    feature.df=TrainingDataMFCC,
                    model.type.list=c('SVM'), # Can specify SVM or RF 
                    tune = TRUE,
                    short.wav.duration=300,
                    target.signal = c("female.gibbon"),
                    min.freq = 400, max.freq = 1600,
                    noise.quantile.val=0.15,
                    minimum.separation =3,
                    n.windows = 9, num.cep = 12,
                    spectrogram.window =160,
                    pattern.split = ".wav",
                    min.signal.dur = 3,
                    max.sound.event.dur = 25,
                    maximum.separation =1,
                    probability.thresh.svm = 0.15,
                    probability.thresh.rf = 0.15,
                    wav.output = "FALSE",
                    output.dir =OutputDirectory,
                    swift.time=TRUE,time.start=5,time.stop=10,
                    write.table.output=TRUE,verbose=TRUE,
                    random.sample='NA')
## [1] "Machine learning in progress..."
## [1] "SVM in progress..."
## [1] "SVM accuracy 98.1132075471698"
## Time difference of 1.385307 secs
## [1] "Classifying for target signal female.gibbon"
## [1] "Computing spectrogram for file S11_20180217_080003 1 out of 1"
## [1] "Running detector over sound files"
## [1] "Creating datasheet"
## [1] "Saving Sound Files S11_20180217_080003 1 out of 1"
## [1] "System processed 7201 seconds in 12 seconds this translates to 579.7 hours processed in 1 hour"