library(tidyverse)
library(dplyr)
library(ggplot2)
data <- read.csv("data/observations_2022.csv")
head(data)
## year ID recorder file_name region site tool cam_date day_sample week
## 1 2022 1 Mario DSCF0001 Carrizo 3 camera trap 17-May 1 1
## 2 2022 2 Mario DSCF0002 Carrizo 3 camera trap 17-May 1 1
## 3 2022 3 Mario DSCF0003 Carrizo 3 camera trap 17-May 1 1
## 4 2022 4 Mario DSCF0004 Carrizo 3 camera trap 17-May 1 1
## 5 2022 5 Mario DSCF0005 Carrizo 3 camera trap 17-May 1 1
## 6 2022 6 Mario DSCF0006 Carrizo 3 camera trap 17-May 1 1
## day rep plot shrub_density cam_ID photo_rep animal RTU actual_time
## 1 1 1 1 density 1 1 0 none 6:37
## 2 1 2 1 density 1 2 0 none 6:40
## 3 1 3 1 density 1 3 0 none 6:44
## 4 1 4 1 density 1 4 1 Kangaroo Rat 14:57
## 5 1 5 1 density 1 5 1 Kangaroo Rat 15:18
## 6 1 6 1 density 1 6 1 Kangaroo Rat 15:20
## time_block behavior observation notes microsite
## 1 am Camera Deployed shrub
## 2 am shrub
## 3 am shrub
## 4 pm standing shrub
## 5 pm standing shrub
## 6 pm standing shrub
data %>%
group_by(RTU) %>% filter(RTU != "none") %>%
summarise(count=n())
## # A tibble: 11 × 2
## RTU count
## <chr> <int>
## 1 "" 2
## 2 "America Badger" 1
## 3 "Antellope Squirrel" 1
## 4 "Antelope Squirrel" 34
## 5 "Coyote" 6
## 6 "Ground Squirrel" 29
## 7 "Jack Rabbit" 16
## 8 "Kangaroo Rat" 265
## 9 "San Joaquin Kit Fox" 2
## 10 "Unidentifiable" 9
## 11 "Unidentified Bird" 2
n_total <- nrow(data)
n_hit <- data %>%
filter(animal != 0) %>%
nrow()
percent_capture <- (n_hit/n_total)*100
n_total ### Total Photos
## [1] 1643
n_hit ### Total Hits
## [1] 365
percent_capture ### Percent Capture Rate
## [1] 22.21546
WI <- read.csv("images_2.csv")
WI %>%
group_by(genus) %>% filter(genus != "NA") %>%
summarise(count=n())
## # A tibble: 9 × 2
## genus count
## <chr> <int>
## 1 "" 1491
## 2 "Ammoperdix" 10
## 3 "Canis" 6
## 4 "Homo" 14
## 5 "Lepus" 24
## 6 "Lynx" 2
## 7 "No CV Result" 74
## 8 "Taxidea" 2
## 9 "Vulpes" 10
head(WI)
## project_id region site shrub_density plot cam_ID date
## 1 2004957 Carrizo 3 density 2 2 17/05/2022
## 2 2004957 Carrizo 3 density 2 2 17/05/2022
## 3 2004957 Carrizo 3 density 2 2 17/05/2022
## 4 2004957 Carrizo 3 density 2 2 17/05/2022
## 5 2004957 Carrizo 3 density 2 2 17/05/2022
## 6 2004957 Carrizo 3 density 2 2 17/05/2022
## image_id file_name
## 1 53004bd7-804f-4bf8-832c-bc489b995742 DSCF0004
## 2 5614afef-f55e-4426-b25d-dc3141a7fff6 DSCF0003
## 3 4043251e-5791-4677-89cf-7c3631673daf DSCF0006
## 4 b17bd793-1015-4208-98fe-eed11284ff5d DSCF0005
## 5 c622870c-d641-45a7-bd25-42d326aa4e54 DSCF0001
## 6 cd065c1b-3bd5-4954-b6af-57ad1188e9bd DSCF0010
## location
## 1 gs://145625598251_2004957_186_cam_traps_2022__main/deployment/2213467/prod/directUpload/53004bd7-804f-4bf8-832c-bc489b995742.JPG
## 2 gs://145625598251_2004957_186_cam_traps_2022__main/deployment/2213467/prod/directUpload/5614afef-f55e-4426-b25d-dc3141a7fff6.JPG
## 3 gs://145625598251_2004957_186_cam_traps_2022__main/deployment/2213467/prod/directUpload/4043251e-5791-4677-89cf-7c3631673daf.JPG
## 4 gs://145625598251_2004957_186_cam_traps_2022__main/deployment/2213467/prod/directUpload/b17bd793-1015-4208-98fe-eed11284ff5d.JPG
## 5 gs://145625598251_2004957_186_cam_traps_2022__main/deployment/2213467/prod/directUpload/c622870c-d641-45a7-bd25-42d326aa4e54.JPG
## 6 gs://145625598251_2004957_186_cam_traps_2022__main/deployment/2213467/prod/directUpload/cd065c1b-3bd5-4954-b6af-57ad1188e9bd.JPG
## is_blank identified_by wi_taxon_id class
## 1 1 Computer vision e70effd7-855e-4ba3-966c-a4fbb74eab13 Mammalia
## 2 0 Computer vision f1856211-cfb7-4a5b-9158-c0f72fd09ee6
## 3 0 Computer vision f1856211-cfb7-4a5b-9158-c0f72fd09ee6
## 4 0 Computer vision f1856211-cfb7-4a5b-9158-c0f72fd09ee6
## 5 1 Computer vision 990ae9dd-7a59-4344-afcb-1b7b21368000 Mammalia
## 6 0 Computer vision f1856211-cfb7-4a5b-9158-c0f72fd09ee6
## order family genus species common_name uncertainty
## 1 Carnivora Mustelidae Taxidea taxus American Badger NA
## 2 Blank NA
## 3 Blank NA
## 4 Blank NA
## 5 Primates Hominidae Homo sapiens Human NA
## 6 Blank NA
## timestamp number_of_objects age sex animal_recognizable individual_id
## 1 2021-01-02 15:13 1 NA NA FALSE NA
## 2 2021-01-02 15:12 1 NA NA FALSE NA
## 3 2021-01-02 17:07 1 NA NA FALSE NA
## 4 2021-01-02 16:28 1 NA NA FALSE NA
## 5 2021-01-02 6:58 1 NA NA FALSE NA
## 6 2021-01-03 15:04 1 NA NA FALSE NA
## individual_animal_notes behavior highlighted markings cv_confidence license
## 1 NA NA FALSE NA 0.90 CC0
## 2 NA NA FALSE NA 0.89 CC0
## 3 NA NA FALSE NA 0.92 CC0
## 4 NA NA FALSE NA 0.91 CC0
## 5 NA NA FALSE NA 0.99 CC0
## 6 NA NA FALSE NA 0.91 CC0
n_total_WI <- nrow(WI)
n_hit_WI <- WI %>%
filter(is_blank != 0) %>% ### The WI file give blanks 1s and hits 0s
nrow()
percent_capture_WI <- (n_hit_WI/n_total_WI)*100
n_total_WI ### Total Photos
## [1] 1633
n_hit_WI ### Total Hits
## [1] 376
percent_capture_WI ### Percent Capture Rate
## [1] 23.02511
### Step 2: Compare the 2 methods to see if they return hits and misses on the same photos.
WI_filtered <- WI %>%
select(region, site, shrub_density, plot, cam_ID, file_name, is_blank, common_name)
combined <- left_join(data, WI_filtered, by=c("region", "site", "shrub_density", "plot", "cam_ID", "file_name"))
combined <- combined%>%
select(-tool, -behavior, -observation, -notes)
df <- combined%>%
rowwise()%>%
mutate(difference = animal-is_blank)
df <- df %>%
filter(common_name != "Human")
n_negative <- df %>%
filter(difference == -1) %>%
nrow()
n_zero <- df %>%
filter(difference == 0) %>%
nrow()
n_one <- df %>%
filter(difference == 1) %>%
nrow()
RATES: Mario 22.2 WI 23.025
Differences Tallied" -1 : 31
0 : 1407
1 : 25
### Percent hits on cameras via human
(n_hit/n_total)*100
## [1] 22.21546
### Percent animals missed from WI vs visually seen
(n_one/n_hit)*100
## [1] 6.849315
### Percent capture rate Table
Percent <- read.csv("Percent Captures.csv")
## Warning in read.table(file = file, header = header, sep = sep, quote = quote, :
## incomplete final line found by readTableHeader on 'Percent Captures.csv'
knitr::kable(Percent)
method | percent.capture |
---|---|
visual | 22.215 |
WI | 23.025 |
### Comparison of Visual and WI processing
negative <- data.frame(n_negative)
zero <- data.frame(n_zero)
positive <- data.frame(n_one)
tally <- merge(negative, zero)
tally <- merge(tally, positive)
names(tally)[1] <- "WI Detected (-1)"
names(tally)[2] <- "Visual & WI Detected (0)"
names(tally)[3] <- "Visually Detected (1)"
knitr::kable(tally)
WI Detected (-1) | Visual & WI Detected (0) | Visually Detected (1) |
---|---|---|
31 | 1407 | 25 |
### Accuracy of WI System
subset <- subset(df, difference == -1)
#write.csv(subset, "Subset.csv")
accuracy <- read.csv("Subset.csv")
n_total_accuracy <- nrow(accuracy)
n_false <- accuracy %>%
filter(accuracy == FALSE) %>%
nrow()
### Incorrectly detected animal there.
percent_incorrect <- (n_false/n_total_accuracy)*100
percent_incorrect
## [1] 58.06452
n_true <- accuracy %>%
filter(accuracy == TRUE) %>%
nrow()
percent_correct <- (n_true/n_total_accuracy)*100
percent_correct
## [1] 41.93548