R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

#Run once in the console if needed:

install.packages("corrr")
install.packages("corrplott")
install.packages("kknn")
install.packages("pROC")
install.packages("PRROC")
library(tidyverse)
## Warning: package 'ggplot2' was built under R version 4.5.2
## Warning: package 'readr' was built under R version 4.5.2
## Warning: package 'dplyr' was built under R version 4.5.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.2.0
## ✔ forcats   1.0.0     ✔ stringr   1.5.2
## ✔ ggplot2   4.0.1     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(lubridate)

# Visualization / exploration

library(corrr)
## Warning: package 'corrr' was built under R version 4.5.3
library(gridExtra)
## 
## Attaching package: 'gridExtra'
## 
## The following object is masked from 'package:dplyr':
## 
##     combine
library(corrplot)
## corrplot 0.95 loaded
# Tables
library(DT)

# Modeling
library(leaps)
library(glmnet)
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 4.5.2
## 
## Attaching package: 'Matrix'
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## Loaded glmnet 4.1-10
# Correlation plots
library(PerformanceAnalytics)
## Warning: package 'PerformanceAnalytics' was built under R version 4.5.2
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## 
## ######################### Warning from 'xts' package ##########################
## #                                                                             #
## # The dplyr lag() function breaks how base R's lag() function is supposed to  #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or       #
## # source() into this session won't work correctly.                            #
## #                                                                             #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop           #
## # dplyr from breaking base R's lag() function.                                #
## #                                                                             #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning.  #
## #                                                                             #
## ###############################################################################
## 
## Attaching package: 'xts'
## 
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## 
## Attaching package: 'PerformanceAnalytics'
## 
## The following object is masked from 'package:graphics':
## 
##     legend
setwd("~/UTSA/Capstone LAPD/Machine Learning/Use_of_Force_R_Prediction")
CPD1 <- read.csv("trr_all_with_rollingNew2_AB_May2.csv", check.names = FALSE)
glimpse(CPD1)
## Rows: 15,629
## Columns: 158
## $ `REPORT NO`                                                      <chr> "2022…
## $ INCIDENTDATETIME                                                 <chr> "1/26…
## $ BEAT                                                             <int> 111, …
## $ WARD                                                             <int> 42, 4…
## $ COMMUNITY                                                        <chr> "LOOP…
## $ `STREET NAME`                                                    <chr> "STAT…
## $ `ZIP CODE`                                                       <int> 60601…
## $ `LOCATION CODE`                                                  <chr> "CTA …
## $ INDOOR_OR_OUTDOOR                                                <chr> "INDO…
## $ LIGHTING_CONDITION                                               <chr> "ARTI…
## $ WEATHER_CONDITION                                                <chr> "CLEA…
## $ MEM_WAS_ALONE_PARTNER                                            <chr> "PART…
## $ ASSISTING_UNIT_ON_SCENE                                          <chr> "Y", …
## $ PATROL_TYPE                                                      <chr> "CAR"…
## $ INVOLVED_PURSUIT                                                 <chr> "", "…
## $ MEMBER_INJURY                                                    <chr> "NONE…
## $ SUBJSEX                                                          <chr> "MALE…
## $ SUB_RACE                                                         <chr> "BLAC…
## $ SUBJECT_CONDITION_NEW_TRR                                        <chr> "ALLE…
## $ SUBJECT_INJURED                                                  <chr> "No",…
## $ SUBJECT_ALLEGED_INJURY                                           <chr> "No",…
## $ `Subject Actions`                                                <chr> "DID …
## $ SUBJECT_ARMED                                                    <chr> "No",…
## $ SUBJECTARMEDWITH                                                 <chr> "", "…
## $ WEAPON_PERCEIVED_AS                                              <chr> "", "…
## $ `Subject Weapon`                                                 <chr> "", "…
## $ SUBDRUGRELATED                                                   <chr> "No",…
## $ SUBGANGRELATED                                                   <chr> "No",…
## $ `Assault-Batt Against PO`                                        <chr> "N", …
## $ `Officer Resp Control Tactics`                                   <chr> "", "…
## $ `Type Activity New TRR`                                          <chr> "", "…
## $ `ReasonForResponse New TRR`                                      <chr> "", "…
## $ `ForceMitigationEfforts New TRR`                                 <chr> "", "…
## $ `ControlTactics New TRR`                                         <chr> "", "…
## $ `ResponseWithoutWeapons New TRR`                                 <chr> "", "…
## $ `ResponseWithWeapon New TRR`                                     <chr> "", "…
## $ Subject_Actions_List                                             <chr> "['DI…
## $ `Action_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM`   <int> 0, 0,…
## $ `Action_IMMINENT THREAT OF BATTERY-NO WPN`                       <int> 0, 0,…
## $ `Action_OTHER (DESCRIBE)`                                        <int> 0, 0,…
## $ `Action_DID NOT FOLLOW VERBAL DIRECTION`                         <int> 1, 1,…
## $ `Action_OTHER (SPECIFY)`                                         <int> 0, 0,…
## $ `Action_ATTACK WITHOUT WEAPON`                                   <int> 0, 0,…
## $ Action_WPN                                                       <int> 0, 0,…
## $ `Action_ATTACK WITH WEAPON`                                      <int> 0, 0,…
## $ `Action_IMMINENT THREAT OF BATTERY`                              <int> 0, 0,…
## $ `Action_PHYSICAL ATTACK WITH WEAPON`                             <int> 0, 0,…
## $ `Action_ATT. TO OBTAIN MEMBER'S WEAPON`                          <int> 0, 0,…
## $ `Action_PHYSICAL OBSTRUCTION`                                    <int> 0, 0,…
## $ `Action_FORCE LIKELY TO CAUSE DEATH`                             <int> 0, 0,…
## $ `Action_WEAPON(DESCRIBE IN ADDITIONAL INFO)`                     <int> 0, 0,…
## $ `Action_UNABLE TO UNDERSTAND VERBAL DIRECTION`                   <int> 0, 0,…
## $ `Action_PHYSICAL ATTACK WITHOUT WEAPON`                          <int> 0, 0,…
## $ `Action_PULLED AWAY`                                             <int> 1, 1,…
## $ `Action_IMMINENT THREAT OF BATTERY W`                            <int> 0, 0,…
## $ `Action_PERCEIVED AS (SPECIFY)`                                  <int> 0, 0,…
## $ `Action_STIFFENED (DEAD WEIGHT)`                                 <int> 1, 1,…
## $ Action_FLED                                                      <int> 0, 0,…
## $ `Action_GREAT BODILY HARM`                                       <int> 0, 0,…
## $ `Action_VERBAL THREATS`                                          <int> 0, 0,…
## $ `Action_THROWN OBJECT`                                           <int> 0, 0,…
## $ `Officer Resp Control Tactics_List`                              <chr> "[]",…
## $ `Response_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM` <int> 0, 0,…
## $ `Response_IMMINENT THREAT OF BATTERY-NO WPN`                     <int> 0, 0,…
## $ `Response_OTHER (DESCRIBE)`                                      <int> 0, 0,…
## $ `Response_DID NOT FOLLOW VERBAL DIRECTION`                       <int> 1, 1,…
## $ `Response_OTHER (SPECIFY)`                                       <int> 0, 0,…
## $ `Response_ATTACK WITHOUT WEAPON`                                 <int> 0, 0,…
## $ Response_WPN                                                     <int> 0, 0,…
## $ `Response_ATTACK WITH WEAPON`                                    <int> 0, 0,…
## $ `Response_IMMINENT THREAT OF BATTERY`                            <int> 0, 0,…
## $ `Response_PHYSICAL ATTACK WITH WEAPON`                           <int> 0, 0,…
## $ `Response_ATT. TO OBTAIN MEMBER'S WEAPON`                        <int> 0, 0,…
## $ `Response_PHYSICAL OBSTRUCTION`                                  <int> 0, 0,…
## $ `Response_FORCE LIKELY TO CAUSE DEATH`                           <int> 0, 0,…
## $ `Response_WEAPON(DESCRIBE IN ADDITIONAL INFO)`                   <int> 0, 0,…
## $ `Response_UNABLE TO UNDERSTAND VERBAL DIRECTION`                 <int> 0, 0,…
## $ `Response_PHYSICAL ATTACK WITHOUT WEAPON`                        <int> 0, 0,…
## $ `Response_PULLED AWAY`                                           <int> 1, 1,…
## $ `Response_IMMINENT THREAT OF BATTERY W`                          <int> 0, 0,…
## $ `Response_PERCEIVED AS (SPECIFY)`                                <int> 0, 0,…
## $ `Response_STIFFENED (DEAD WEIGHT)`                               <int> 1, 1,…
## $ Response_FLED                                                    <int> 0, 0,…
## $ `Response_GREAT BODILY HARM`                                     <int> 0, 0,…
## $ `Response_VERBAL THREATS`                                        <int> 0, 0,…
## $ `Response_THROWN OBJECT`                                         <int> 0, 0,…
## $ `Response_VERBAL COMMANDS`                                       <int> 0, 0,…
## $ Response_WRISTLOCK                                               <int> 0, 1,…
## $ Response_KICKS                                                   <int> 0, 0,…
## $ Response_PUNCH                                                   <int> 0, 0,…
## $ `Response_TASER (ARC CYLCLE) 2`                                  <int> 0, 0,…
## $ Response_AUTHORIZATION                                           <int> 0, 0,…
## $ `Response_TASER (CONTACT STUN) 2`                                <int> 0, 0,…
## $ `Response_IMPACT MUNITION (DESCRIBE IN ADDITIONAL INFO)`         <int> 0, 0,…
## $ `Response_TASER (ARC CYLCLE) 1`                                  <int> 0, 0,…
## $ `Response_IMPACT WEAPON (DESCRIBE IN ADDITIONAL INFO)`           <int> 0, 0,…
## $ `Response_KNEE STRIKE`                                           <int> 0, 0,…
## $ `Response_CHEMICAL WEAPON`                                       <int> 0, 0,…
## $ `Response_EMERGENCY HANDCUFFING`                                 <int> 0, 0,…
## $ Response_O.C.                                                    <int> 0, 0,…
## $ `Response_CLOSED HAND STRIKE`                                    <int> 0, 0,…
## $ `Response_MEMBER PRESENCE`                                       <int> 0, 0,…
## $ `Response_CONTROL INSTRUMENT`                                    <int> 0, 0,…
## $ `Response_TASER (CONTACT STUN) 1`                                <int> 0, 0,…
## $ `Response_PHYSICAL REDIRECTION`                                  <int> 0, 0,…
## $ Response_FIREARM                                                 <int> 0, 0,…
## $ `Response_TASER (PROBE DISCHARGE) 3`                             <int> 0, 0,…
## $ `Response_TASER (PROBE DISCHARGE) 1`                             <int> 0, 0,…
## $ `Response_ELBOW STRIKE`                                          <int> 0, 0,…
## $ Response_ARMBAR                                                  <int> 0, 0,…
## $ `Response_TASER (SPARK DISPLAYED)`                               <int> 0, 0,…
## $ `Response_TASER (PROBE DISCHARGE)`                               <int> 0, 0,…
## $ `Response_ESCORT HOLDS`                                          <int> 0, 1,…
## $ Response_CANINE                                                  <int> 0, 0,…
## $ `Response_TASER (PROBE DISCHARGE) 2`                             <int> 0, 0,…
## $ `Response_TASER (SPARK DISPLAYED) 1`                             <int> 0, 0,…
## $ `Response_TASER (CONTACT STUN) 3`                                <int> 0, 0,…
## $ `Response_TASER (ARC CYLCLE)`                                    <int> 0, 0,…
## $ `Response_OPEN HAND STRIKE`                                      <int> 0, 0,…
## $ `Response_TASER (ARC CYLCLE) 3`                                  <int> 0, 0,…
## $ `Response_TAKE DOWN`                                             <int> 0, 0,…
## $ `Response_TASER (CONTACT STUN)`                                  <int> 0, 0,…
## $ `Response_PRESSURE SENSITIVE AREAS`                              <int> 0, 0,…
## $ `Response_CHEMICAL WEAPON W`                                     <int> 0, 0,…
## $ Response_PUSH                                                    <int> 0, 0,…
## $ `Response_TASER (LASER TARGETED)`                                <int> 0, 0,…
## $ Subject_Conditions_List                                          <chr> "['AL…
## $ Condition_INJURED_UNRELATED_TO_FORCE                             <int> 0, 0,…
## $ Condition_EMOTIONAL_DISORDER                                     <int> 0, 0,…
## $ Condition_DISABILITY                                             <int> 0, 0,…
## $ Condition_APPARENTLY_NORMAL                                      <int> 0, 0,…
## $ Condition_UNDER_INFLUENCE_OF_ALCOHOL                             <int> 0, 0,…
## $ Condition_INJURED_BY_MEMBER                                      <int> 0, 1,…
## $ Condition_MENTAL_ILL.                                            <int> 0, 0,…
## $ Condition_UNDER_INFLUENCE_OF_DRUGS                               <int> 0, 0,…
## $ Condition_ALLEGES_INJURY_BY_MEMBER                               <int> 1, 1,…
## $ Condition_OTHER                                                  <int> 0, 0,…
## $ Force_Level                                                      <int> 1, 1,…
## $ Escalation                                                       <int> 0, 0,…
## $ datetime                                                         <chr> "1/26…
## $ crime_7d                                                         <int> 29, 2…
## $ violent_crime_7d                                                 <int> 10, 1…
## $ arrest_7d                                                        <int> 6, 6,…
## $ cad_24h                                                          <int> 11, 1…
## $ crime_7d.1                                                       <int> 29, 2…
## $ violent_7d                                                       <int> 8, 8,…
## $ arrest_7d.1                                                      <int> 6, 6,…
## $ cad_24h.1                                                        <int> 11, 1…
## $ cad_rate                                                         <dbl> 0.458…
## $ crime_rate                                                       <dbl> 4.142…
## $ violent_ratio                                                    <dbl> 0.275…
## $ beat_cad_mean                                                    <dbl> 11.31…
## $ cad_relative                                                     <dbl> 0.972…
## $ hour                                                             <int> 7, 7,…
## $ day_of_week                                                      <int> 2, 2,…
## $ month                                                            <int> 1, 1,…
## $ is_weekend                                                       <int> 0, 0,…
## $ time_since_last_trr                                              <dbl> 7.526…
summary(CPD1)
##   REPORT NO         INCIDENTDATETIME        BEAT           WARD      
##  Length:15629       Length:15629       Min.   : 111   Min.   : 1.00  
##  Class :character   Class :character   1st Qu.: 612   1st Qu.:11.00  
##  Mode  :character   Mode  :character   Median :1024   Median :24.00  
##                                        Mean   :1113   Mean   :22.67  
##                                        3rd Qu.:1613   3rd Qu.:30.00  
##                                        Max.   :4100   Max.   :50.00  
##                                                       NA's   :104    
##   COMMUNITY         STREET NAME           ZIP CODE     LOCATION CODE     
##  Length:15629       Length:15629       Min.   :46327   Length:15629      
##  Class :character   Class :character   1st Qu.:60617   Class :character  
##  Mode  :character   Mode  :character   Median :60624   Mode  :character  
##                                        Mean   :60625                     
##                                        3rd Qu.:60639                     
##                                        Max.   :61104                     
##                                                                          
##  INDOOR_OR_OUTDOOR  LIGHTING_CONDITION WEATHER_CONDITION  MEM_WAS_ALONE_PARTNER
##  Length:15629       Length:15629       Length:15629       Length:15629         
##  Class :character   Class :character   Class :character   Class :character     
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character     
##                                                                                
##                                                                                
##                                                                                
##                                                                                
##  ASSISTING_UNIT_ON_SCENE PATROL_TYPE        INVOLVED_PURSUIT  
##  Length:15629            Length:15629       Length:15629      
##  Class :character        Class :character   Class :character  
##  Mode  :character        Mode  :character   Mode  :character  
##                                                               
##                                                               
##                                                               
##                                                               
##  MEMBER_INJURY        SUBJSEX            SUB_RACE        
##  Length:15629       Length:15629       Length:15629      
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##                                                          
##                                                          
##                                                          
##                                                          
##  SUBJECT_CONDITION_NEW_TRR SUBJECT_INJURED    SUBJECT_ALLEGED_INJURY
##  Length:15629              Length:15629       Length:15629          
##  Class :character          Class :character   Class :character      
##  Mode  :character          Mode  :character   Mode  :character      
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##  Subject Actions    SUBJECT_ARMED      SUBJECTARMEDWITH   WEAPON_PERCEIVED_AS
##  Length:15629       Length:15629       Length:15629       Length:15629       
##  Class :character   Class :character   Class :character   Class :character   
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character   
##                                                                              
##                                                                              
##                                                                              
##                                                                              
##  Subject Weapon     SUBDRUGRELATED     SUBGANGRELATED    
##  Length:15629       Length:15629       Length:15629      
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##                                                          
##                                                          
##                                                          
##                                                          
##  Assault-Batt Against PO Officer Resp Control Tactics Type Activity New TRR
##  Length:15629            Length:15629                 Length:15629         
##  Class :character        Class :character             Class :character     
##  Mode  :character        Mode  :character             Mode  :character     
##                                                                            
##                                                                            
##                                                                            
##                                                                            
##  ReasonForResponse New TRR ForceMitigationEfforts New TRR
##  Length:15629              Length:15629                  
##  Class :character          Class :character              
##  Mode  :character          Mode  :character              
##                                                          
##                                                          
##                                                          
##                                                          
##  ControlTactics New TRR ResponseWithoutWeapons New TRR
##  Length:15629           Length:15629                  
##  Class :character       Class :character              
##  Mode  :character       Mode  :character              
##                                                       
##                                                       
##                                                       
##                                                       
##  ResponseWithWeapon New TRR Subject_Actions_List
##  Length:15629               Length:15629        
##  Class :character           Class :character    
##  Mode  :character           Mode  :character    
##                                                 
##                                                 
##                                                 
##                                                 
##  Action_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM
##  Min.   :0                                                   
##  1st Qu.:0                                                   
##  Median :0                                                   
##  Mean   :0                                                   
##  3rd Qu.:0                                                   
##  Max.   :0                                                   
##                                                              
##  Action_IMMINENT THREAT OF BATTERY-NO WPN Action_OTHER (DESCRIBE)
##  Min.   :0.0000                           Min.   :0.0000         
##  1st Qu.:0.0000                           1st Qu.:0.0000         
##  Median :0.0000                           Median :0.0000         
##  Mean   :0.2059                           Mean   :0.1115         
##  3rd Qu.:0.0000                           3rd Qu.:0.0000         
##  Max.   :1.0000                           Max.   :1.0000         
##                                                                  
##  Action_DID NOT FOLLOW VERBAL DIRECTION Action_OTHER (SPECIFY)
##  Min.   :0.0000                         Min.   :0             
##  1st Qu.:1.0000                         1st Qu.:0             
##  Median :1.0000                         Median :0             
##  Mean   :0.8794                         Mean   :0             
##  3rd Qu.:1.0000                         3rd Qu.:0             
##  Max.   :1.0000                         Max.   :0             
##                                                               
##  Action_ATTACK WITHOUT WEAPON   Action_WPN      Action_ATTACK WITH WEAPON
##  Min.   :0                    Min.   :0.00000   Min.   :0                
##  1st Qu.:0                    1st Qu.:0.00000   1st Qu.:0                
##  Median :0                    Median :0.00000   Median :0                
##  Mean   :0                    Mean   :0.09572   Mean   :0                
##  3rd Qu.:0                    3rd Qu.:0.00000   3rd Qu.:0                
##  Max.   :0                    Max.   :1.00000   Max.   :0                
##                                                                          
##  Action_IMMINENT THREAT OF BATTERY Action_PHYSICAL ATTACK WITH WEAPON
##  Min.   :0                         Min.   :0.00000                   
##  1st Qu.:0                         1st Qu.:0.00000                   
##  Median :0                         Median :0.00000                   
##  Mean   :0                         Mean   :0.02361                   
##  3rd Qu.:0                         3rd Qu.:0.00000                   
##  Max.   :0                         Max.   :1.00000                   
##                                                                      
##  Action_ATT. TO OBTAIN MEMBER'S WEAPON Action_PHYSICAL OBSTRUCTION
##  Min.   :0.000000                      Min.   :0.0000             
##  1st Qu.:0.000000                      1st Qu.:0.0000             
##  Median :0.000000                      Median :0.0000             
##  Mean   :0.005503                      Mean   :0.1413             
##  3rd Qu.:0.000000                      3rd Qu.:0.0000             
##  Max.   :1.000000                      Max.   :1.0000             
##                                                                   
##  Action_FORCE LIKELY TO CAUSE DEATH Action_WEAPON(DESCRIBE IN ADDITIONAL INFO)
##  Min.   :0.00000                    Min.   :0                                 
##  1st Qu.:0.00000                    1st Qu.:0                                 
##  Median :0.00000                    Median :0                                 
##  Mean   :0.03065                    Mean   :0                                 
##  3rd Qu.:0.00000                    3rd Qu.:0                                 
##  Max.   :1.00000                    Max.   :0                                 
##                                                                               
##  Action_UNABLE TO UNDERSTAND VERBAL DIRECTION
##  Min.   :0.00000                             
##  1st Qu.:0.00000                             
##  Median :0.00000                             
##  Mean   :0.02022                             
##  3rd Qu.:0.00000                             
##  Max.   :1.00000                             
##                                              
##  Action_PHYSICAL ATTACK WITHOUT WEAPON Action_PULLED AWAY
##  Min.   :0.0000                        Min.   :0.0000    
##  1st Qu.:0.0000                        1st Qu.:0.0000    
##  Median :0.0000                        Median :1.0000    
##  Mean   :0.2431                        Mean   :0.7324    
##  3rd Qu.:0.0000                        3rd Qu.:1.0000    
##  Max.   :1.0000                        Max.   :1.0000    
##                                                          
##  Action_IMMINENT THREAT OF BATTERY W Action_PERCEIVED AS (SPECIFY)
##  Min.   :0.00000                     Min.   :0                    
##  1st Qu.:0.00000                     1st Qu.:0                    
##  Median :0.00000                     Median :0                    
##  Mean   :0.09572                     Mean   :0                    
##  3rd Qu.:0.00000                     3rd Qu.:0                    
##  Max.   :1.00000                     Max.   :0                    
##                                                                   
##  Action_STIFFENED (DEAD WEIGHT)  Action_FLED     Action_GREAT BODILY HARM
##  Min.   :0.0000                 Min.   :0.0000   Min.   :0.00000         
##  1st Qu.:0.0000                 1st Qu.:0.0000   1st Qu.:0.00000         
##  Median :1.0000                 Median :0.0000   Median :0.00000         
##  Mean   :0.6243                 Mean   :0.2347   Mean   :0.03065         
##  3rd Qu.:1.0000                 3rd Qu.:0.0000   3rd Qu.:0.00000         
##  Max.   :1.0000                 Max.   :1.0000   Max.   :1.00000         
##                                                                          
##  Action_VERBAL THREATS Action_THROWN OBJECT Officer Resp Control Tactics_List
##  Min.   :0.000         Min.   :0.0000       Length:15629                     
##  1st Qu.:0.000         1st Qu.:0.0000       Class :character                 
##  Median :0.000         Median :0.0000       Mode  :character                 
##  Mean   :0.217         Mean   :0.0238                                        
##  3rd Qu.:0.000         3rd Qu.:0.0000                                        
##  Max.   :1.000         Max.   :1.0000                                        
##                                                                              
##  Response_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM
##  Min.   :0                                                     
##  1st Qu.:0                                                     
##  Median :0                                                     
##  Mean   :0                                                     
##  3rd Qu.:0                                                     
##  Max.   :0                                                     
##                                                                
##  Response_IMMINENT THREAT OF BATTERY-NO WPN Response_OTHER (DESCRIBE)
##  Min.   :0.0000                             Min.   :0.0000           
##  1st Qu.:0.0000                             1st Qu.:0.0000           
##  Median :0.0000                             Median :0.0000           
##  Mean   :0.2059                             Mean   :0.1115           
##  3rd Qu.:0.0000                             3rd Qu.:0.0000           
##  Max.   :1.0000                             Max.   :1.0000           
##                                                                      
##  Response_DID NOT FOLLOW VERBAL DIRECTION Response_OTHER (SPECIFY)
##  Min.   :0.0000                           Min.   :0.0000          
##  1st Qu.:1.0000                           1st Qu.:0.0000          
##  Median :1.0000                           Median :0.0000          
##  Mean   :0.8794                           Mean   :0.1644          
##  3rd Qu.:1.0000                           3rd Qu.:0.0000          
##  Max.   :1.0000                           Max.   :1.0000          
##                                                                   
##  Response_ATTACK WITHOUT WEAPON  Response_WPN     Response_ATTACK WITH WEAPON
##  Min.   :0                      Min.   :0.00000   Min.   :0                  
##  1st Qu.:0                      1st Qu.:0.00000   1st Qu.:0                  
##  Median :0                      Median :0.00000   Median :0                  
##  Mean   :0                      Mean   :0.09572   Mean   :0                  
##  3rd Qu.:0                      3rd Qu.:0.00000   3rd Qu.:0                  
##  Max.   :0                      Max.   :1.00000   Max.   :0                  
##                                                                              
##  Response_IMMINENT THREAT OF BATTERY Response_PHYSICAL ATTACK WITH WEAPON
##  Min.   :0                           Min.   :0.00000                     
##  1st Qu.:0                           1st Qu.:0.00000                     
##  Median :0                           Median :0.00000                     
##  Mean   :0                           Mean   :0.02361                     
##  3rd Qu.:0                           3rd Qu.:0.00000                     
##  Max.   :0                           Max.   :1.00000                     
##                                                                          
##  Response_ATT. TO OBTAIN MEMBER'S WEAPON Response_PHYSICAL OBSTRUCTION
##  Min.   :0.000000                        Min.   :0.0000               
##  1st Qu.:0.000000                        1st Qu.:0.0000               
##  Median :0.000000                        Median :0.0000               
##  Mean   :0.005503                        Mean   :0.1413               
##  3rd Qu.:0.000000                        3rd Qu.:0.0000               
##  Max.   :1.000000                        Max.   :1.0000               
##                                                                       
##  Response_FORCE LIKELY TO CAUSE DEATH
##  Min.   :0.00000                     
##  1st Qu.:0.00000                     
##  Median :0.00000                     
##  Mean   :0.03065                     
##  3rd Qu.:0.00000                     
##  Max.   :1.00000                     
##                                      
##  Response_WEAPON(DESCRIBE IN ADDITIONAL INFO)
##  Min.   :0                                   
##  1st Qu.:0                                   
##  Median :0                                   
##  Mean   :0                                   
##  3rd Qu.:0                                   
##  Max.   :0                                   
##                                              
##  Response_UNABLE TO UNDERSTAND VERBAL DIRECTION
##  Min.   :0.00000                               
##  1st Qu.:0.00000                               
##  Median :0.00000                               
##  Mean   :0.02022                               
##  3rd Qu.:0.00000                               
##  Max.   :1.00000                               
##                                                
##  Response_PHYSICAL ATTACK WITHOUT WEAPON Response_PULLED AWAY
##  Min.   :0.0000                          Min.   :0.0000      
##  1st Qu.:0.0000                          1st Qu.:0.0000      
##  Median :0.0000                          Median :1.0000      
##  Mean   :0.2431                          Mean   :0.7324      
##  3rd Qu.:0.0000                          3rd Qu.:1.0000      
##  Max.   :1.0000                          Max.   :1.0000      
##                                                              
##  Response_IMMINENT THREAT OF BATTERY W Response_PERCEIVED AS (SPECIFY)
##  Min.   :0.00000                       Min.   :0                      
##  1st Qu.:0.00000                       1st Qu.:0                      
##  Median :0.00000                       Median :0                      
##  Mean   :0.09572                       Mean   :0                      
##  3rd Qu.:0.00000                       3rd Qu.:0                      
##  Max.   :1.00000                       Max.   :0                      
##                                                                       
##  Response_STIFFENED (DEAD WEIGHT) Response_FLED    Response_GREAT BODILY HARM
##  Min.   :0.0000                   Min.   :0.0000   Min.   :0.00000           
##  1st Qu.:0.0000                   1st Qu.:0.0000   1st Qu.:0.00000           
##  Median :1.0000                   Median :0.0000   Median :0.00000           
##  Mean   :0.6243                   Mean   :0.2347   Mean   :0.03065           
##  3rd Qu.:1.0000                   3rd Qu.:0.0000   3rd Qu.:0.00000           
##  Max.   :1.0000                   Max.   :1.0000   Max.   :1.00000           
##                                                                              
##  Response_VERBAL THREATS Response_THROWN OBJECT Response_VERBAL COMMANDS
##  Min.   :0.000           Min.   :0.0000         Min.   :0               
##  1st Qu.:0.000           1st Qu.:0.0000         1st Qu.:0               
##  Median :0.000           Median :0.0000         Median :0               
##  Mean   :0.217           Mean   :0.0238         Mean   :0               
##  3rd Qu.:0.000           3rd Qu.:0.0000         3rd Qu.:0               
##  Max.   :1.000           Max.   :1.0000         Max.   :0               
##                                                                         
##  Response_WRISTLOCK Response_KICKS     Response_PUNCH   
##  Min.   :0.0000     Min.   :0.000000   Min.   :0.00000  
##  1st Qu.:0.0000     1st Qu.:0.000000   1st Qu.:0.00000  
##  Median :0.0000     Median :0.000000   Median :0.00000  
##  Mean   :0.1935     Mean   :0.002367   Mean   :0.03257  
##  3rd Qu.:0.0000     3rd Qu.:0.000000   3rd Qu.:0.00000  
##  Max.   :1.0000     Max.   :1.000000   Max.   :1.00000  
##                                                         
##  Response_TASER (ARC CYLCLE) 2 Response_AUTHORIZATION
##  Min.   :0                     Min.   :0.000000      
##  1st Qu.:0                     1st Qu.:0.000000      
##  Median :0                     Median :0.000000      
##  Mean   :0                     Mean   :0.001536      
##  3rd Qu.:0                     3rd Qu.:0.000000      
##  Max.   :0                     Max.   :1.000000      
##                                                      
##  Response_TASER (CONTACT STUN) 2
##  Min.   :0                      
##  1st Qu.:0                      
##  Median :0                      
##  Mean   :0                      
##  3rd Qu.:0                      
##  Max.   :0                      
##                                 
##  Response_IMPACT MUNITION (DESCRIBE IN ADDITIONAL INFO)
##  Min.   :0.0000000                                     
##  1st Qu.:0.0000000                                     
##  Median :0.0000000                                     
##  Mean   :0.0002559                                     
##  3rd Qu.:0.0000000                                     
##  Max.   :1.0000000                                     
##                                                        
##  Response_TASER (ARC CYLCLE) 1
##  Min.   :0                    
##  1st Qu.:0                    
##  Median :0                    
##  Mean   :0                    
##  3rd Qu.:0                    
##  Max.   :0                    
##                               
##  Response_IMPACT WEAPON (DESCRIBE IN ADDITIONAL INFO) Response_KNEE STRIKE
##  Min.   :0.000000                                     Min.   :0.000000    
##  1st Qu.:0.000000                                     1st Qu.:0.000000    
##  Median :0.000000                                     Median :0.000000    
##  Mean   :0.007934                                     Mean   :0.006206    
##  3rd Qu.:0.000000                                     3rd Qu.:0.000000    
##  Max.   :1.000000                                     Max.   :1.000000    
##                                                                           
##  Response_CHEMICAL WEAPON Response_EMERGENCY HANDCUFFING Response_O.C.     
##  Min.   :0.000000         Min.   :0.0000                 Min.   :0.000000  
##  1st Qu.:0.000000         1st Qu.:0.0000                 1st Qu.:0.000000  
##  Median :0.000000         Median :0.0000                 Median :0.000000  
##  Mean   :0.003647         Mean   :0.3383                 Mean   :0.005119  
##  3rd Qu.:0.000000         3rd Qu.:1.0000                 3rd Qu.:0.000000  
##  Max.   :1.000000         Max.   :1.0000                 Max.   :1.000000  
##                                                                            
##  Response_CLOSED HAND STRIKE Response_MEMBER PRESENCE
##  Min.   :0.00000             Min.   :0               
##  1st Qu.:0.00000             1st Qu.:0               
##  Median :0.00000             Median :0               
##  Mean   :0.03257             Mean   :0               
##  3rd Qu.:0.00000             3rd Qu.:0               
##  Max.   :1.00000             Max.   :0               
##                                                      
##  Response_CONTROL INSTRUMENT Response_TASER (CONTACT STUN) 1
##  Min.   :0.00000             Min.   :0                      
##  1st Qu.:0.00000             1st Qu.:0                      
##  Median :0.00000             Median :0                      
##  Mean   :0.00787             Mean   :0                      
##  3rd Qu.:0.00000             3rd Qu.:0                      
##  Max.   :1.00000             Max.   :0                      
##                                                             
##  Response_PHYSICAL REDIRECTION Response_FIREARM  
##  Min.   :0.0000                Min.   :0.000000  
##  1st Qu.:0.0000                1st Qu.:0.000000  
##  Median :0.0000                Median :0.000000  
##  Mean   :0.3573                Mean   :0.009917  
##  3rd Qu.:1.0000                3rd Qu.:0.000000  
##  Max.   :1.0000                Max.   :1.000000  
##                                                  
##  Response_TASER (PROBE DISCHARGE) 3 Response_TASER (PROBE DISCHARGE) 1
##  Min.   :0                          Min.   :0                         
##  1st Qu.:0                          1st Qu.:0                         
##  Median :0                          Median :0                         
##  Mean   :0                          Mean   :0                         
##  3rd Qu.:0                          3rd Qu.:0                         
##  Max.   :0                          Max.   :0                         
##                                                                       
##  Response_ELBOW STRIKE Response_ARMBAR  Response_TASER (SPARK DISPLAYED)
##  Min.   :0.000000      Min.   :0.0000   Min.   :0                       
##  1st Qu.:0.000000      1st Qu.:0.0000   1st Qu.:0                       
##  Median :0.000000      Median :0.0000   Median :0                       
##  Mean   :0.002367      Mean   :0.1365   Mean   :0                       
##  3rd Qu.:0.000000      3rd Qu.:0.0000   3rd Qu.:0                       
##  Max.   :1.000000      Max.   :1.0000   Max.   :0                       
##                                                                         
##  Response_TASER (PROBE DISCHARGE) Response_ESCORT HOLDS Response_CANINE
##  Min.   :0.00000                  Min.   :0.0000        Min.   :0      
##  1st Qu.:0.00000                  1st Qu.:0.0000        1st Qu.:0      
##  Median :0.00000                  Median :0.0000        Median :0      
##  Mean   :0.02207                  Mean   :0.3761        Mean   :0      
##  3rd Qu.:0.00000                  3rd Qu.:1.0000        3rd Qu.:0      
##  Max.   :1.00000                  Max.   :1.0000        Max.   :0      
##                                                                        
##  Response_TASER (PROBE DISCHARGE) 2 Response_TASER (SPARK DISPLAYED) 1
##  Min.   :0                          Min.   :0                         
##  1st Qu.:0                          1st Qu.:0                         
##  Median :0                          Median :0                         
##  Mean   :0                          Mean   :0                         
##  3rd Qu.:0                          3rd Qu.:0                         
##  Max.   :0                          Max.   :0                         
##                                                                       
##  Response_TASER (CONTACT STUN) 3 Response_TASER (ARC CYLCLE)
##  Min.   :0                       Min.   :0                  
##  1st Qu.:0                       1st Qu.:0                  
##  Median :0                       Median :0                  
##  Mean   :0                       Mean   :0                  
##  3rd Qu.:0                       3rd Qu.:0                  
##  Max.   :0                       Max.   :0                  
##                                                             
##  Response_OPEN HAND STRIKE Response_TASER (ARC CYLCLE) 3 Response_TAKE DOWN
##  Min.   :0.00000           Min.   :0                     Min.   :0.0000    
##  1st Qu.:0.00000           1st Qu.:0                     1st Qu.:0.0000    
##  Median :0.00000           Median :0                     Median :0.0000    
##  Mean   :0.01561           Mean   :0                     Mean   :0.3383    
##  3rd Qu.:0.00000           3rd Qu.:0                     3rd Qu.:1.0000    
##  Max.   :1.00000           Max.   :0                     Max.   :1.0000    
##                                                                            
##  Response_TASER (CONTACT STUN) Response_PRESSURE SENSITIVE AREAS
##  Min.   :0                     Min.   :0.00000                  
##  1st Qu.:0                     1st Qu.:0.00000                  
##  Median :0                     Median :0.00000                  
##  Mean   :0                     Mean   :0.01958                  
##  3rd Qu.:0                     3rd Qu.:0.00000                  
##  Max.   :0                     Max.   :1.00000                  
##                                                                 
##  Response_CHEMICAL WEAPON W Response_PUSH    Response_TASER (LASER TARGETED)
##  Min.   :0.000000           Min.   :0.0000   Min.   :0                      
##  1st Qu.:0.000000           1st Qu.:0.0000   1st Qu.:0                      
##  Median :0.000000           Median :0.0000   Median :0                      
##  Mean   :0.001536           Mean   :0.3573   Mean   :0                      
##  3rd Qu.:0.000000           3rd Qu.:1.0000   3rd Qu.:0                      
##  Max.   :1.000000           Max.   :1.0000   Max.   :0                      
##                                                                             
##  Subject_Conditions_List Condition_INJURED_UNRELATED_TO_FORCE
##  Length:15629            Min.   :0.0000                      
##  Class :character        1st Qu.:0.0000                      
##  Mode  :character        Median :0.0000                      
##                          Mean   :0.1426                      
##                          3rd Qu.:0.0000                      
##                          Max.   :1.0000                      
##                                                              
##  Condition_EMOTIONAL_DISORDER Condition_DISABILITY Condition_APPARENTLY_NORMAL
##  Min.   :0.000                Min.   :0.000000     Min.   :0.00               
##  1st Qu.:0.000                1st Qu.:0.000000     1st Qu.:0.00               
##  Median :0.000                Median :0.000000     Median :0.00               
##  Mean   :0.142                Mean   :0.002623     Mean   :0.33               
##  3rd Qu.:0.000                3rd Qu.:0.000000     3rd Qu.:1.00               
##  Max.   :1.000                Max.   :1.000000     Max.   :1.00               
##                                                                               
##  Condition_UNDER_INFLUENCE_OF_ALCOHOL Condition_INJURED_BY_MEMBER
##  Min.   :0.0000                       Min.   :0.00000            
##  1st Qu.:0.0000                       1st Qu.:0.00000            
##  Median :0.0000                       Median :0.00000            
##  Mean   :0.2235                       Mean   :0.05349            
##  3rd Qu.:0.0000                       3rd Qu.:0.00000            
##  Max.   :1.0000                       Max.   :1.00000            
##                                                                  
##  Condition_MENTAL_ILL. Condition_UNDER_INFLUENCE_OF_DRUGS
##  Min.   :0.000         Min.   :0.00000                   
##  1st Qu.:0.000         1st Qu.:0.00000                   
##  Median :0.000         Median :0.00000                   
##  Mean   :0.142         Mean   :0.09476                   
##  3rd Qu.:0.000         3rd Qu.:0.00000                   
##  Max.   :1.000         Max.   :1.00000                   
##                                                          
##  Condition_ALLEGES_INJURY_BY_MEMBER Condition_OTHER   Force_Level   
##  Min.   :0.0000                     Min.   :0.0000   Min.   :1.000  
##  1st Qu.:0.0000                     1st Qu.:0.0000   1st Qu.:1.000  
##  Median :0.0000                     Median :0.0000   Median :1.000  
##  Mean   :0.1513                     Mean   :0.0309   Mean   :1.105  
##  3rd Qu.:0.0000                     3rd Qu.:0.0000   3rd Qu.:1.000  
##  Max.   :1.0000                     Max.   :1.0000   Max.   :3.000  
##                                                                     
##    Escalation        datetime            crime_7d      violent_crime_7d
##  Min.   :0.00000   Length:15629       Min.   :  0.00   Min.   : 0.000  
##  1st Qu.:0.00000   Class :character   1st Qu.: 15.00   1st Qu.: 5.000  
##  Median :0.00000   Mode  :character   Median : 20.00   Median : 7.000  
##  Mean   :0.09527                      Mean   : 21.59   Mean   : 7.326  
##  3rd Qu.:0.00000                      3rd Qu.: 26.00   3rd Qu.:10.000  
##  Max.   :1.00000                      Max.   :111.00   Max.   :31.000  
##                                                                        
##    arrest_7d         cad_24h        crime_7d.1       violent_7d   
##  Min.   : 0.000   Min.   : 0.00   Min.   :  0.00   Min.   : 0.00  
##  1st Qu.: 2.000   1st Qu.: 0.00   1st Qu.: 15.00   1st Qu.: 4.00  
##  Median : 3.000   Median : 8.00   Median : 20.00   Median : 7.00  
##  Mean   : 4.143   Mean   :10.57   Mean   : 21.49   Mean   : 7.16  
##  3rd Qu.: 5.000   3rd Qu.:19.00   3rd Qu.: 26.00   3rd Qu.: 9.00  
##  Max.   :25.000   Max.   :78.00   Max.   :111.00   Max.   :30.00  
##                                   NA's   :103      NA's   :103    
##   arrest_7d.1       cad_24h.1        cad_rate        crime_rate    
##  Min.   : 0.000   Min.   : 0.00   Min.   :0.0000   Min.   : 0.000  
##  1st Qu.: 2.000   1st Qu.: 0.00   1st Qu.:0.0000   1st Qu.: 2.143  
##  Median : 3.000   Median : 8.00   Median :0.3333   Median : 2.857  
##  Mean   : 4.128   Mean   :10.57   Mean   :0.4404   Mean   : 3.084  
##  3rd Qu.: 5.000   3rd Qu.:19.00   3rd Qu.:0.7917   3rd Qu.: 3.714  
##  Max.   :25.000   Max.   :78.00   Max.   :3.2500   Max.   :15.857  
##  NA's   :103                                                       
##  violent_ratio    beat_cad_mean     cad_relative          hour      
##  Min.   :0.0000   Min.   : 0.000   Min.   : 0.0000   Min.   : 0.00  
##  1st Qu.:0.2414   1st Qu.: 7.696   1st Qu.: 0.0000   1st Qu.: 8.00  
##  Median :0.3333   Median : 9.952   Median : 0.9743   Median :15.00  
##  Mean   :0.3373   Mean   :10.570   Mean   : 1.0000   Mean   :13.17  
##  3rd Qu.:0.4286   3rd Qu.:13.210   3rd Qu.: 1.8075   3rd Qu.:19.00  
##  Max.   :1.0000   Max.   :31.540   Max.   :14.0000   Max.   :23.00  
##                                    NA's   :7                        
##   day_of_week        month          is_weekend     time_since_last_trr
##  Min.   :0.000   Min.   : 1.000   Min.   :0.0000   Min.   :    0.000  
##  1st Qu.:1.000   1st Qu.: 3.000   1st Qu.:0.0000   1st Qu.:    0.000  
##  Median :3.000   Median : 6.000   Median :0.0000   Median :    6.217  
##  Mean   :3.124   Mean   : 5.948   Mean   :0.3241   Mean   :  554.605  
##  3rd Qu.:5.000   3rd Qu.: 8.000   3rd Qu.:1.0000   3rd Qu.:  547.517  
##  Max.   :6.000   Max.   :12.000   Max.   :1.0000   Max.   :42173.450  
##                                                    NA's   :1
colSums(is.na(CPD1))
##                                                      REPORT NO 
##                                                              0 
##                                               INCIDENTDATETIME 
##                                                              0 
##                                                           BEAT 
##                                                              0 
##                                                           WARD 
##                                                            104 
##                                                      COMMUNITY 
##                                                              0 
##                                                    STREET NAME 
##                                                              0 
##                                                       ZIP CODE 
##                                                              0 
##                                                  LOCATION CODE 
##                                                              0 
##                                              INDOOR_OR_OUTDOOR 
##                                                              0 
##                                             LIGHTING_CONDITION 
##                                                              0 
##                                              WEATHER_CONDITION 
##                                                              0 
##                                          MEM_WAS_ALONE_PARTNER 
##                                                              0 
##                                        ASSISTING_UNIT_ON_SCENE 
##                                                              0 
##                                                    PATROL_TYPE 
##                                                              0 
##                                               INVOLVED_PURSUIT 
##                                                              0 
##                                                  MEMBER_INJURY 
##                                                              0 
##                                                        SUBJSEX 
##                                                              0 
##                                                       SUB_RACE 
##                                                              0 
##                                      SUBJECT_CONDITION_NEW_TRR 
##                                                              0 
##                                                SUBJECT_INJURED 
##                                                              0 
##                                         SUBJECT_ALLEGED_INJURY 
##                                                              0 
##                                                Subject Actions 
##                                                              0 
##                                                  SUBJECT_ARMED 
##                                                              0 
##                                               SUBJECTARMEDWITH 
##                                                              0 
##                                            WEAPON_PERCEIVED_AS 
##                                                              0 
##                                                 Subject Weapon 
##                                                              0 
##                                                 SUBDRUGRELATED 
##                                                              0 
##                                                 SUBGANGRELATED 
##                                                              0 
##                                        Assault-Batt Against PO 
##                                                              0 
##                                   Officer Resp Control Tactics 
##                                                              0 
##                                          Type Activity New TRR 
##                                                              0 
##                                      ReasonForResponse New TRR 
##                                                              0 
##                                 ForceMitigationEfforts New TRR 
##                                                              0 
##                                         ControlTactics New TRR 
##                                                              0 
##                                 ResponseWithoutWeapons New TRR 
##                                                              0 
##                                     ResponseWithWeapon New TRR 
##                                                              0 
##                                           Subject_Actions_List 
##                                                              0 
##   Action_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM 
##                                                              0 
##                       Action_IMMINENT THREAT OF BATTERY-NO WPN 
##                                                              0 
##                                        Action_OTHER (DESCRIBE) 
##                                                              0 
##                         Action_DID NOT FOLLOW VERBAL DIRECTION 
##                                                              0 
##                                         Action_OTHER (SPECIFY) 
##                                                              0 
##                                   Action_ATTACK WITHOUT WEAPON 
##                                                              0 
##                                                     Action_WPN 
##                                                              0 
##                                      Action_ATTACK WITH WEAPON 
##                                                              0 
##                              Action_IMMINENT THREAT OF BATTERY 
##                                                              0 
##                             Action_PHYSICAL ATTACK WITH WEAPON 
##                                                              0 
##                          Action_ATT. TO OBTAIN MEMBER'S WEAPON 
##                                                              0 
##                                    Action_PHYSICAL OBSTRUCTION 
##                                                              0 
##                             Action_FORCE LIKELY TO CAUSE DEATH 
##                                                              0 
##                     Action_WEAPON(DESCRIBE IN ADDITIONAL INFO) 
##                                                              0 
##                   Action_UNABLE TO UNDERSTAND VERBAL DIRECTION 
##                                                              0 
##                          Action_PHYSICAL ATTACK WITHOUT WEAPON 
##                                                              0 
##                                             Action_PULLED AWAY 
##                                                              0 
##                            Action_IMMINENT THREAT OF BATTERY W 
##                                                              0 
##                                  Action_PERCEIVED AS (SPECIFY) 
##                                                              0 
##                                 Action_STIFFENED (DEAD WEIGHT) 
##                                                              0 
##                                                    Action_FLED 
##                                                              0 
##                                       Action_GREAT BODILY HARM 
##                                                              0 
##                                          Action_VERBAL THREATS 
##                                                              0 
##                                           Action_THROWN OBJECT 
##                                                              0 
##                              Officer Resp Control Tactics_List 
##                                                              0 
## Response_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM 
##                                                              0 
##                     Response_IMMINENT THREAT OF BATTERY-NO WPN 
##                                                              0 
##                                      Response_OTHER (DESCRIBE) 
##                                                              0 
##                       Response_DID NOT FOLLOW VERBAL DIRECTION 
##                                                              0 
##                                       Response_OTHER (SPECIFY) 
##                                                              0 
##                                 Response_ATTACK WITHOUT WEAPON 
##                                                              0 
##                                                   Response_WPN 
##                                                              0 
##                                    Response_ATTACK WITH WEAPON 
##                                                              0 
##                            Response_IMMINENT THREAT OF BATTERY 
##                                                              0 
##                           Response_PHYSICAL ATTACK WITH WEAPON 
##                                                              0 
##                        Response_ATT. TO OBTAIN MEMBER'S WEAPON 
##                                                              0 
##                                  Response_PHYSICAL OBSTRUCTION 
##                                                              0 
##                           Response_FORCE LIKELY TO CAUSE DEATH 
##                                                              0 
##                   Response_WEAPON(DESCRIBE IN ADDITIONAL INFO) 
##                                                              0 
##                 Response_UNABLE TO UNDERSTAND VERBAL DIRECTION 
##                                                              0 
##                        Response_PHYSICAL ATTACK WITHOUT WEAPON 
##                                                              0 
##                                           Response_PULLED AWAY 
##                                                              0 
##                          Response_IMMINENT THREAT OF BATTERY W 
##                                                              0 
##                                Response_PERCEIVED AS (SPECIFY) 
##                                                              0 
##                               Response_STIFFENED (DEAD WEIGHT) 
##                                                              0 
##                                                  Response_FLED 
##                                                              0 
##                                     Response_GREAT BODILY HARM 
##                                                              0 
##                                        Response_VERBAL THREATS 
##                                                              0 
##                                         Response_THROWN OBJECT 
##                                                              0 
##                                       Response_VERBAL COMMANDS 
##                                                              0 
##                                             Response_WRISTLOCK 
##                                                              0 
##                                                 Response_KICKS 
##                                                              0 
##                                                 Response_PUNCH 
##                                                              0 
##                                  Response_TASER (ARC CYLCLE) 2 
##                                                              0 
##                                         Response_AUTHORIZATION 
##                                                              0 
##                                Response_TASER (CONTACT STUN) 2 
##                                                              0 
##         Response_IMPACT MUNITION (DESCRIBE IN ADDITIONAL INFO) 
##                                                              0 
##                                  Response_TASER (ARC CYLCLE) 1 
##                                                              0 
##           Response_IMPACT WEAPON (DESCRIBE IN ADDITIONAL INFO) 
##                                                              0 
##                                           Response_KNEE STRIKE 
##                                                              0 
##                                       Response_CHEMICAL WEAPON 
##                                                              0 
##                                 Response_EMERGENCY HANDCUFFING 
##                                                              0 
##                                                  Response_O.C. 
##                                                              0 
##                                    Response_CLOSED HAND STRIKE 
##                                                              0 
##                                       Response_MEMBER PRESENCE 
##                                                              0 
##                                    Response_CONTROL INSTRUMENT 
##                                                              0 
##                                Response_TASER (CONTACT STUN) 1 
##                                                              0 
##                                  Response_PHYSICAL REDIRECTION 
##                                                              0 
##                                               Response_FIREARM 
##                                                              0 
##                             Response_TASER (PROBE DISCHARGE) 3 
##                                                              0 
##                             Response_TASER (PROBE DISCHARGE) 1 
##                                                              0 
##                                          Response_ELBOW STRIKE 
##                                                              0 
##                                                Response_ARMBAR 
##                                                              0 
##                               Response_TASER (SPARK DISPLAYED) 
##                                                              0 
##                               Response_TASER (PROBE DISCHARGE) 
##                                                              0 
##                                          Response_ESCORT HOLDS 
##                                                              0 
##                                                Response_CANINE 
##                                                              0 
##                             Response_TASER (PROBE DISCHARGE) 2 
##                                                              0 
##                             Response_TASER (SPARK DISPLAYED) 1 
##                                                              0 
##                                Response_TASER (CONTACT STUN) 3 
##                                                              0 
##                                    Response_TASER (ARC CYLCLE) 
##                                                              0 
##                                      Response_OPEN HAND STRIKE 
##                                                              0 
##                                  Response_TASER (ARC CYLCLE) 3 
##                                                              0 
##                                             Response_TAKE DOWN 
##                                                              0 
##                                  Response_TASER (CONTACT STUN) 
##                                                              0 
##                              Response_PRESSURE SENSITIVE AREAS 
##                                                              0 
##                                     Response_CHEMICAL WEAPON W 
##                                                              0 
##                                                  Response_PUSH 
##                                                              0 
##                                Response_TASER (LASER TARGETED) 
##                                                              0 
##                                        Subject_Conditions_List 
##                                                              0 
##                           Condition_INJURED_UNRELATED_TO_FORCE 
##                                                              0 
##                                   Condition_EMOTIONAL_DISORDER 
##                                                              0 
##                                           Condition_DISABILITY 
##                                                              0 
##                                    Condition_APPARENTLY_NORMAL 
##                                                              0 
##                           Condition_UNDER_INFLUENCE_OF_ALCOHOL 
##                                                              0 
##                                    Condition_INJURED_BY_MEMBER 
##                                                              0 
##                                          Condition_MENTAL_ILL. 
##                                                              0 
##                             Condition_UNDER_INFLUENCE_OF_DRUGS 
##                                                              0 
##                             Condition_ALLEGES_INJURY_BY_MEMBER 
##                                                              0 
##                                                Condition_OTHER 
##                                                              0 
##                                                    Force_Level 
##                                                              0 
##                                                     Escalation 
##                                                              0 
##                                                       datetime 
##                                                              0 
##                                                       crime_7d 
##                                                              0 
##                                               violent_crime_7d 
##                                                              0 
##                                                      arrest_7d 
##                                                              0 
##                                                        cad_24h 
##                                                              0 
##                                                     crime_7d.1 
##                                                            103 
##                                                     violent_7d 
##                                                            103 
##                                                    arrest_7d.1 
##                                                            103 
##                                                      cad_24h.1 
##                                                              0 
##                                                       cad_rate 
##                                                              0 
##                                                     crime_rate 
##                                                              0 
##                                                  violent_ratio 
##                                                              0 
##                                                  beat_cad_mean 
##                                                              0 
##                                                   cad_relative 
##                                                              7 
##                                                           hour 
##                                                              0 
##                                                    day_of_week 
##                                                              0 
##                                                          month 
##                                                              0 
##                                                     is_weekend 
##                                                              0 
##                                            time_since_last_trr 
##                                                              1
head(CPD1)
##    REPORT NO INCIDENTDATETIME BEAT WARD COMMUNITY STREET NAME ZIP CODE
## 1 2022-00165   1/26/2022 7:57  111   42      LOOP    STATE ST    60601
## 2 2022-00164   1/26/2022 7:57  111   42      LOOP    STATE ST    60601
## 3 2022-00602  3/14/2022 16:31  111   34      LOOP RANDOLPH ST    60601
## 4 2022-01055   5/2/2022 17:45  111   34      LOOP RANDOLPH ST    60601
## 5 2022-01942    7/3/2022 0:57  111   34      LOOP  WABASH AVE    60602
## 6 2022-01943    7/3/2022 0:57  111   34      LOOP  WABASH AVE    60602
##   LOCATION CODE INDOOR_OR_OUTDOOR LIGHTING_CONDITION WEATHER_CONDITION
## 1     CTA TRAIN            INDOOR         ARTIFICIAL             CLEAR
## 2     CTA TRAIN            INDOOR           DAYLIGHT             CLEAR
## 3      SIDEWALK           OUTDOOR           DAYLIGHT             CLEAR
## 4      SIDEWALK           OUTDOOR           DAYLIGHT             CLEAR
## 5      SIDEWALK           OUTDOOR         ARTIFICIAL             CLEAR
## 6      SIDEWALK           OUTDOOR         ARTIFICIAL             CLEAR
##   MEM_WAS_ALONE_PARTNER ASSISTING_UNIT_ON_SCENE PATROL_TYPE INVOLVED_PURSUIT
## 1                  PART                       Y         CAR                 
## 2                  PART                       Y         CAR                 
## 3                 ALONE                       Y         CAR                 
## 4                  PART                       N         CAR             Foot
## 5                  PART                       Y         CAR             Foot
## 6                  PART                       N         CAR             Foot
##                                  MEMBER_INJURY SUBJSEX SUB_RACE
## 1                         NONE / NONE APPARENT    MALE    BLACK
## 2                         NONE / NONE APPARENT    MALE    BLACK
## 3                         NONE / NONE APPARENT    MALE    BLACK
## 4 MINOR CONTUSION / LACERATION, MINOR SWELLING    MALE    BLACK
## 5                         NONE / NONE APPARENT    MALE    BLACK
## 6 MINOR SWELLING, OTHER (EXPLAIN IN NARRATIVE)    MALE    BLACK
##                     SUBJECT_CONDITION_NEW_TRR SUBJECT_INJURED
## 1                    ALLEGES INJURY BY MEMBER              No
## 2 ALLEGES INJURY BY MEMBER, INJURED BY MEMBER             Yes
## 3                           APPARENTLY NORMAL              No
## 4                           APPARENTLY NORMAL              No
## 5                  INJURED UNRELATED TO FORCE              No
## 6                  INJURED UNRELATED TO FORCE              No
##   SUBJECT_ALLEGED_INJURY
## 1                     No
## 2                    Yes
## 3                     No
## 4                     No
## 5                     No
## 6                     No
##                                                                                            Subject Actions
## 1                                    DID NOT FOLLOW VERBAL DIRECTION, PULLED AWAY, STIFFENED (DEAD WEIGHT)
## 2                                    DID NOT FOLLOW VERBAL DIRECTION, PULLED AWAY, STIFFENED (DEAD WEIGHT)
## 3                                           DID NOT FOLLOW VERBAL DIRECTION, OTHER (DESCRIBE), PULLED AWAY
## 4                              DID NOT FOLLOW VERBAL DIRECTION, FLED, PULLED AWAY, STIFFENED (DEAD WEIGHT)
## 5                              DID NOT FOLLOW VERBAL DIRECTION, FLED, PULLED AWAY, STIFFENED (DEAD WEIGHT)
## 6 DID NOT FOLLOW VERBAL DIRECTION, FLED, PHYSICAL ATTACK WITH WEAPON, PULLED AWAY, STIFFENED (DEAD WEIGHT)
##   SUBJECT_ARMED SUBJECTARMEDWITH WEAPON_PERCEIVED_AS  Subject Weapon
## 1            No                                                     
## 2            No                                                     
## 3            No                                                     
## 4            No                                                     
## 5           Yes  CHEMICAL WEAPON                     CHEMICAL WEAPON
## 6           Yes  CHEMICAL WEAPON                     CHEMICAL WEAPON
##   SUBDRUGRELATED SUBGANGRELATED Assault-Batt Against PO
## 1             No             No                       N
## 2             No             No                       N
## 3             No             No                       N
## 4             No             No                       Y
## 5             No             No                       N
## 6             No             No                       Y
##      Officer Resp Control Tactics
## 1                                
## 2         ESCORT HOLDS, WRISTLOCK
## 3       PUSH/PHYSICAL REDIRECTION
## 4 TAKE DOWN/EMERGENCY HANDCUFFING
## 5        PRESSURE SENSITIVE AREAS
## 6                                
##                               Type Activity New TRR
## 1                                                  
## 2                     OTHER - DESCRIBE IN NARRATIVE
## 3 DISTURBANCE - OTHER, PURSUING / ARRESTING SUBJECT
## 4           DISTURBANCE - OTHER, INVESTIGATORY STOP
## 5 DISTURBANCE - OTHER, PURSUING / ARRESTING SUBJECT
## 6 DISTURBANCE - OTHER, PURSUING / ARRESTING SUBJECT
##                                                                                                               ReasonForResponse New TRR
## 1                                                                                                                                      
## 2                                                                                                                      OTHER (DESCRIBE)
## 3                                         DEFENSE OF MEMBER OF PUBLIC, DEFENSE OF SELF, FLEEING SUBJECT, OVERCOME RESISTANCE/AGGRESSION
## 4                                                                      DEFENSE OF SELF, FLEEING SUBJECT, OVERCOME RESISTANCE/AGGRESSION
## 5                                 DEFENSE OF DEPARTMENT MEMBER, DEFENSE OF MEMBER OF PUBLIC, FLEEING SUBJECT, SUBJECT ARMED WITH WEAPON
## 6 DEFENSE OF DEPARTMENT MEMBER, DEFENSE OF MEMBER OF PUBLIC, FLEEING SUBJECT, OVERCOME RESISTANCE/AGGRESSION, SUBJECT ARMED WITH WEAPON
##                                                                                     ForceMitigationEfforts New TRR
## 1                                                                                                                 
## 2 ADDITIONAL UNIT MEMBERS, MEMBER PRESENCE, TACTICAL POSITIONING, VERBAL DIR. / CONTROL TECHNIQUES, ZONE OF SAFETY
## 3                                       ADDITIONAL UNIT MEMBERS, MEMBER PRESENCE, VERBAL DIR. / CONTROL TECHNIQUES
## 4                                          MEMBER PRESENCE, TACTICAL POSITIONING, VERBAL DIR. / CONTROL TECHNIQUES
## 5                                                        ADDITIONAL UNIT MEMBERS, VERBAL DIR. / CONTROL TECHNIQUES
## 6                                       ADDITIONAL UNIT MEMBERS, MEMBER PRESENCE, VERBAL DIR. / CONTROL TECHNIQUES
##                                      ControlTactics New TRR
## 1                                                          
## 2  ESCORT HOLDS, HANDCUFFS / PHYSICAL RESTRAINTS, WRISTLOCK
## 3                           HANDCUFFS / PHYSICAL RESTRAINTS
## 4                           HANDCUFFS / PHYSICAL RESTRAINTS
## 5 HANDCUFFS / PHYSICAL RESTRAINTS, PRESSURE SENSITIVE AREAS
## 6                           HANDCUFFS / PHYSICAL RESTRAINTS
##   ResponseWithoutWeapons New TRR ResponseWithWeapon New TRR
## 1                                                          
## 2                                                          
## 3      PUSH/PHYSICAL REDIRECTION                           
## 4                      TAKE DOWN                           
## 5                                                          
## 6                                                          
##                                                                                                   Subject_Actions_List
## 1                                        ['DID NOT FOLLOW VERBAL DIRECTION', 'PULLED AWAY', 'STIFFENED (DEAD WEIGHT)']
## 2                                        ['DID NOT FOLLOW VERBAL DIRECTION', 'PULLED AWAY', 'STIFFENED (DEAD WEIGHT)']
## 3                                               ['DID NOT FOLLOW VERBAL DIRECTION', 'OTHER (DESCRIBE)', 'PULLED AWAY']
## 4                                ['DID NOT FOLLOW VERBAL DIRECTION', 'FLED', 'PULLED AWAY', 'STIFFENED (DEAD WEIGHT)']
## 5                                ['DID NOT FOLLOW VERBAL DIRECTION', 'FLED', 'PULLED AWAY', 'STIFFENED (DEAD WEIGHT)']
## 6 ['DID NOT FOLLOW VERBAL DIRECTION', 'FLED', 'PHYSICAL ATTACK WITH WEAPON', 'PULLED AWAY', 'STIFFENED (DEAD WEIGHT)']
##   Action_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM
## 1                                                            0
## 2                                                            0
## 3                                                            0
## 4                                                            0
## 5                                                            0
## 6                                                            0
##   Action_IMMINENT THREAT OF BATTERY-NO WPN Action_OTHER (DESCRIBE)
## 1                                        0                       0
## 2                                        0                       0
## 3                                        0                       1
## 4                                        0                       0
## 5                                        0                       0
## 6                                        0                       0
##   Action_DID NOT FOLLOW VERBAL DIRECTION Action_OTHER (SPECIFY)
## 1                                      1                      0
## 2                                      1                      0
## 3                                      1                      0
## 4                                      1                      0
## 5                                      1                      0
## 6                                      1                      0
##   Action_ATTACK WITHOUT WEAPON Action_WPN Action_ATTACK WITH WEAPON
## 1                            0          0                         0
## 2                            0          0                         0
## 3                            0          0                         0
## 4                            0          0                         0
## 5                            0          0                         0
## 6                            0          0                         0
##   Action_IMMINENT THREAT OF BATTERY Action_PHYSICAL ATTACK WITH WEAPON
## 1                                 0                                  0
## 2                                 0                                  0
## 3                                 0                                  0
## 4                                 0                                  0
## 5                                 0                                  0
## 6                                 0                                  1
##   Action_ATT. TO OBTAIN MEMBER'S WEAPON Action_PHYSICAL OBSTRUCTION
## 1                                     0                           0
## 2                                     0                           0
## 3                                     0                           0
## 4                                     0                           0
## 5                                     0                           0
## 6                                     0                           0
##   Action_FORCE LIKELY TO CAUSE DEATH Action_WEAPON(DESCRIBE IN ADDITIONAL INFO)
## 1                                  0                                          0
## 2                                  0                                          0
## 3                                  0                                          0
## 4                                  0                                          0
## 5                                  0                                          0
## 6                                  0                                          0
##   Action_UNABLE TO UNDERSTAND VERBAL DIRECTION
## 1                                            0
## 2                                            0
## 3                                            0
## 4                                            0
## 5                                            0
## 6                                            0
##   Action_PHYSICAL ATTACK WITHOUT WEAPON Action_PULLED AWAY
## 1                                     0                  1
## 2                                     0                  1
## 3                                     0                  1
## 4                                     0                  1
## 5                                     0                  1
## 6                                     0                  1
##   Action_IMMINENT THREAT OF BATTERY W Action_PERCEIVED AS (SPECIFY)
## 1                                   0                             0
## 2                                   0                             0
## 3                                   0                             0
## 4                                   0                             0
## 5                                   0                             0
## 6                                   0                             0
##   Action_STIFFENED (DEAD WEIGHT) Action_FLED Action_GREAT BODILY HARM
## 1                              1           0                        0
## 2                              1           0                        0
## 3                              0           0                        0
## 4                              1           1                        0
## 5                              1           1                        0
## 6                              1           1                        0
##   Action_VERBAL THREATS Action_THROWN OBJECT
## 1                     0                    0
## 2                     0                    0
## 3                     0                    0
## 4                     0                    0
## 5                     0                    0
## 6                     0                    0
##        Officer Resp Control Tactics_List
## 1                                     []
## 2          ['ESCORT HOLDS', 'WRISTLOCK']
## 3       ['PUSH', 'PHYSICAL REDIRECTION']
## 4 ['TAKE DOWN', 'EMERGENCY HANDCUFFING']
## 5           ['PRESSURE SENSITIVE AREAS']
## 6                                     []
##   Response_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM
## 1                                                              0
## 2                                                              0
## 3                                                              0
## 4                                                              0
## 5                                                              0
## 6                                                              0
##   Response_IMMINENT THREAT OF BATTERY-NO WPN Response_OTHER (DESCRIBE)
## 1                                          0                         0
## 2                                          0                         0
## 3                                          0                         1
## 4                                          0                         0
## 5                                          0                         0
## 6                                          0                         0
##   Response_DID NOT FOLLOW VERBAL DIRECTION Response_OTHER (SPECIFY)
## 1                                        1                        0
## 2                                        1                        0
## 3                                        1                        0
## 4                                        1                        0
## 5                                        1                        0
## 6                                        1                        0
##   Response_ATTACK WITHOUT WEAPON Response_WPN Response_ATTACK WITH WEAPON
## 1                              0            0                           0
## 2                              0            0                           0
## 3                              0            0                           0
## 4                              0            0                           0
## 5                              0            0                           0
## 6                              0            0                           0
##   Response_IMMINENT THREAT OF BATTERY Response_PHYSICAL ATTACK WITH WEAPON
## 1                                   0                                    0
## 2                                   0                                    0
## 3                                   0                                    0
## 4                                   0                                    0
## 5                                   0                                    0
## 6                                   0                                    1
##   Response_ATT. TO OBTAIN MEMBER'S WEAPON Response_PHYSICAL OBSTRUCTION
## 1                                       0                             0
## 2                                       0                             0
## 3                                       0                             0
## 4                                       0                             0
## 5                                       0                             0
## 6                                       0                             0
##   Response_FORCE LIKELY TO CAUSE DEATH
## 1                                    0
## 2                                    0
## 3                                    0
## 4                                    0
## 5                                    0
## 6                                    0
##   Response_WEAPON(DESCRIBE IN ADDITIONAL INFO)
## 1                                            0
## 2                                            0
## 3                                            0
## 4                                            0
## 5                                            0
## 6                                            0
##   Response_UNABLE TO UNDERSTAND VERBAL DIRECTION
## 1                                              0
## 2                                              0
## 3                                              0
## 4                                              0
## 5                                              0
## 6                                              0
##   Response_PHYSICAL ATTACK WITHOUT WEAPON Response_PULLED AWAY
## 1                                       0                    1
## 2                                       0                    1
## 3                                       0                    1
## 4                                       0                    1
## 5                                       0                    1
## 6                                       0                    1
##   Response_IMMINENT THREAT OF BATTERY W Response_PERCEIVED AS (SPECIFY)
## 1                                     0                               0
## 2                                     0                               0
## 3                                     0                               0
## 4                                     0                               0
## 5                                     0                               0
## 6                                     0                               0
##   Response_STIFFENED (DEAD WEIGHT) Response_FLED Response_GREAT BODILY HARM
## 1                                1             0                          0
## 2                                1             0                          0
## 3                                0             0                          0
## 4                                1             1                          0
## 5                                1             1                          0
## 6                                1             1                          0
##   Response_VERBAL THREATS Response_THROWN OBJECT Response_VERBAL COMMANDS
## 1                       0                      0                        0
## 2                       0                      0                        0
## 3                       0                      0                        0
## 4                       0                      0                        0
## 5                       0                      0                        0
## 6                       0                      0                        0
##   Response_WRISTLOCK Response_KICKS Response_PUNCH
## 1                  0              0              0
## 2                  1              0              0
## 3                  0              0              0
## 4                  0              0              0
## 5                  0              0              0
## 6                  0              0              0
##   Response_TASER (ARC CYLCLE) 2 Response_AUTHORIZATION
## 1                             0                      0
## 2                             0                      0
## 3                             0                      0
## 4                             0                      0
## 5                             0                      0
## 6                             0                      0
##   Response_TASER (CONTACT STUN) 2
## 1                               0
## 2                               0
## 3                               0
## 4                               0
## 5                               0
## 6                               0
##   Response_IMPACT MUNITION (DESCRIBE IN ADDITIONAL INFO)
## 1                                                      0
## 2                                                      0
## 3                                                      0
## 4                                                      0
## 5                                                      0
## 6                                                      0
##   Response_TASER (ARC CYLCLE) 1
## 1                             0
## 2                             0
## 3                             0
## 4                             0
## 5                             0
## 6                             0
##   Response_IMPACT WEAPON (DESCRIBE IN ADDITIONAL INFO) Response_KNEE STRIKE
## 1                                                    0                    0
## 2                                                    0                    0
## 3                                                    0                    0
## 4                                                    0                    0
## 5                                                    0                    0
## 6                                                    0                    0
##   Response_CHEMICAL WEAPON Response_EMERGENCY HANDCUFFING Response_O.C.
## 1                        0                              0             0
## 2                        0                              0             0
## 3                        0                              0             0
## 4                        0                              1             0
## 5                        0                              0             0
## 6                        0                              0             0
##   Response_CLOSED HAND STRIKE Response_MEMBER PRESENCE
## 1                           0                        0
## 2                           0                        0
## 3                           0                        0
## 4                           0                        0
## 5                           0                        0
## 6                           0                        0
##   Response_CONTROL INSTRUMENT Response_TASER (CONTACT STUN) 1
## 1                           0                               0
## 2                           0                               0
## 3                           0                               0
## 4                           0                               0
## 5                           0                               0
## 6                           0                               0
##   Response_PHYSICAL REDIRECTION Response_FIREARM
## 1                             0                0
## 2                             0                0
## 3                             1                0
## 4                             0                0
## 5                             0                0
## 6                             0                0
##   Response_TASER (PROBE DISCHARGE) 3 Response_TASER (PROBE DISCHARGE) 1
## 1                                  0                                  0
## 2                                  0                                  0
## 3                                  0                                  0
## 4                                  0                                  0
## 5                                  0                                  0
## 6                                  0                                  0
##   Response_ELBOW STRIKE Response_ARMBAR Response_TASER (SPARK DISPLAYED)
## 1                     0               0                                0
## 2                     0               0                                0
## 3                     0               0                                0
## 4                     0               0                                0
## 5                     0               0                                0
## 6                     0               0                                0
##   Response_TASER (PROBE DISCHARGE) Response_ESCORT HOLDS Response_CANINE
## 1                                0                     0               0
## 2                                0                     1               0
## 3                                0                     0               0
## 4                                0                     0               0
## 5                                0                     0               0
## 6                                0                     0               0
##   Response_TASER (PROBE DISCHARGE) 2 Response_TASER (SPARK DISPLAYED) 1
## 1                                  0                                  0
## 2                                  0                                  0
## 3                                  0                                  0
## 4                                  0                                  0
## 5                                  0                                  0
## 6                                  0                                  0
##   Response_TASER (CONTACT STUN) 3 Response_TASER (ARC CYLCLE)
## 1                               0                           0
## 2                               0                           0
## 3                               0                           0
## 4                               0                           0
## 5                               0                           0
## 6                               0                           0
##   Response_OPEN HAND STRIKE Response_TASER (ARC CYLCLE) 3 Response_TAKE DOWN
## 1                         0                             0                  0
## 2                         0                             0                  0
## 3                         0                             0                  0
## 4                         0                             0                  1
## 5                         0                             0                  0
## 6                         0                             0                  0
##   Response_TASER (CONTACT STUN) Response_PRESSURE SENSITIVE AREAS
## 1                             0                                 0
## 2                             0                                 0
## 3                             0                                 0
## 4                             0                                 0
## 5                             0                                 1
## 6                             0                                 0
##   Response_CHEMICAL WEAPON W Response_PUSH Response_TASER (LASER TARGETED)
## 1                          0             0                               0
## 2                          0             0                               0
## 3                          0             1                               0
## 4                          0             0                               0
## 5                          0             0                               0
## 6                          0             0                               0
##                             Subject_Conditions_List
## 1                      ['ALLEGES INJURY BY MEMBER']
## 2 ['ALLEGES INJURY BY MEMBER', 'INJURED BY MEMBER']
## 3                             ['APPARENTLY NORMAL']
## 4                             ['APPARENTLY NORMAL']
## 5                    ['INJURED UNRELATED TO FORCE']
## 6                    ['INJURED UNRELATED TO FORCE']
##   Condition_INJURED_UNRELATED_TO_FORCE Condition_EMOTIONAL_DISORDER
## 1                                    0                            0
## 2                                    0                            0
## 3                                    0                            0
## 4                                    0                            0
## 5                                    1                            0
## 6                                    1                            0
##   Condition_DISABILITY Condition_APPARENTLY_NORMAL
## 1                    0                           0
## 2                    0                           0
## 3                    0                           1
## 4                    0                           1
## 5                    0                           0
## 6                    0                           0
##   Condition_UNDER_INFLUENCE_OF_ALCOHOL Condition_INJURED_BY_MEMBER
## 1                                    0                           0
## 2                                    0                           1
## 3                                    0                           0
## 4                                    0                           0
## 5                                    0                           0
## 6                                    0                           0
##   Condition_MENTAL_ILL. Condition_UNDER_INFLUENCE_OF_DRUGS
## 1                     0                                  0
## 2                     0                                  0
## 3                     0                                  0
## 4                     0                                  0
## 5                     0                                  0
## 6                     0                                  0
##   Condition_ALLEGES_INJURY_BY_MEMBER Condition_OTHER Force_Level Escalation
## 1                                  1               0           1          0
## 2                                  1               0           1          0
## 3                                  0               0           1          0
## 4                                  0               0           1          0
## 5                                  0               0           1          0
## 6                                  0               0           1          0
##          datetime crime_7d violent_crime_7d arrest_7d cad_24h crime_7d.1
## 1  1/26/2022 7:57       29               10         6      11         29
## 2  1/26/2022 7:57       29               10         6      11         29
## 3 3/14/2022 16:31       21                8         2      27         21
## 4  5/2/2022 17:45       23                7         9       0         23
## 5   7/3/2022 0:57       31                7         6       0         31
## 6   7/3/2022 0:57       31                7         6       0         31
##   violent_7d arrest_7d.1 cad_24h.1  cad_rate crime_rate violent_ratio
## 1          8           6        11 0.4583333   4.142857     0.2758621
## 2          8           6        11 0.4583333   4.142857     0.2758621
## 3          8           2        27 1.1250000   3.000000     0.3809524
## 4          7           9         0 0.0000000   3.285714     0.3043478
## 5          7           6         0 0.0000000   4.428571     0.2258065
## 6          7           6         0 0.0000000   4.428571     0.2258065
##   beat_cad_mean cad_relative hour day_of_week month is_weekend
## 1      11.31148    0.9724638    7           2     1          0
## 2      11.31148    0.9724638    7           2     1          0
## 3      11.31148    2.3869565   16           0     3          0
## 4      11.31148    0.0000000   17           0     5          0
## 5      11.31148    0.0000000    0           6     7          1
## 6      11.31148    0.0000000    0           6     7          1
##   time_since_last_trr
## 1            752.6833
## 2              0.0000
## 3           1136.5667
## 4           1177.2333
## 5           1471.2000
## 6              0.0000
CPD2 <- CPD1 %>%
  mutate(
    INCIDENTDATETIME = mdy_hm(INCIDENTDATETIME),
    INCIDENT_DATE = as.Date(INCIDENTDATETIME),
    INCIDENT_TIME = format(INCIDENTDATETIME, "%H:%M"),
    DAY_OF_WEEK = factor(
      wday(INCIDENTDATETIME, label = TRUE),
      levels = c("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
    ),
    HOUR = hour(INCIDENTDATETIME),
    MONTH = factor(month(INCIDENTDATETIME, label = TRUE), levels = month.abb),
    YEAR = year(INCIDENTDATETIME),
    WEEKEND = ifelse(wday(INCIDENTDATETIME) %in% c(1, 7), 1, 0),
    TIME_OF_DAY = case_when(
      HOUR >= 5 & HOUR < 12 ~ "Morning",
      HOUR >= 12 & HOUR < 17 ~ "Afternoon",
      HOUR >= 17 & HOUR < 21 ~ "Evening",
      TRUE ~ "Night"
    )
  )
head(CPD2)
##    REPORT NO    INCIDENTDATETIME BEAT WARD COMMUNITY STREET NAME ZIP CODE
## 1 2022-00165 2022-01-26 07:57:00  111   42      LOOP    STATE ST    60601
## 2 2022-00164 2022-01-26 07:57:00  111   42      LOOP    STATE ST    60601
## 3 2022-00602 2022-03-14 16:31:00  111   34      LOOP RANDOLPH ST    60601
## 4 2022-01055 2022-05-02 17:45:00  111   34      LOOP RANDOLPH ST    60601
## 5 2022-01942 2022-07-03 00:57:00  111   34      LOOP  WABASH AVE    60602
## 6 2022-01943 2022-07-03 00:57:00  111   34      LOOP  WABASH AVE    60602
##   LOCATION CODE INDOOR_OR_OUTDOOR LIGHTING_CONDITION WEATHER_CONDITION
## 1     CTA TRAIN            INDOOR         ARTIFICIAL             CLEAR
## 2     CTA TRAIN            INDOOR           DAYLIGHT             CLEAR
## 3      SIDEWALK           OUTDOOR           DAYLIGHT             CLEAR
## 4      SIDEWALK           OUTDOOR           DAYLIGHT             CLEAR
## 5      SIDEWALK           OUTDOOR         ARTIFICIAL             CLEAR
## 6      SIDEWALK           OUTDOOR         ARTIFICIAL             CLEAR
##   MEM_WAS_ALONE_PARTNER ASSISTING_UNIT_ON_SCENE PATROL_TYPE INVOLVED_PURSUIT
## 1                  PART                       Y         CAR                 
## 2                  PART                       Y         CAR                 
## 3                 ALONE                       Y         CAR                 
## 4                  PART                       N         CAR             Foot
## 5                  PART                       Y         CAR             Foot
## 6                  PART                       N         CAR             Foot
##                                  MEMBER_INJURY SUBJSEX SUB_RACE
## 1                         NONE / NONE APPARENT    MALE    BLACK
## 2                         NONE / NONE APPARENT    MALE    BLACK
## 3                         NONE / NONE APPARENT    MALE    BLACK
## 4 MINOR CONTUSION / LACERATION, MINOR SWELLING    MALE    BLACK
## 5                         NONE / NONE APPARENT    MALE    BLACK
## 6 MINOR SWELLING, OTHER (EXPLAIN IN NARRATIVE)    MALE    BLACK
##                     SUBJECT_CONDITION_NEW_TRR SUBJECT_INJURED
## 1                    ALLEGES INJURY BY MEMBER              No
## 2 ALLEGES INJURY BY MEMBER, INJURED BY MEMBER             Yes
## 3                           APPARENTLY NORMAL              No
## 4                           APPARENTLY NORMAL              No
## 5                  INJURED UNRELATED TO FORCE              No
## 6                  INJURED UNRELATED TO FORCE              No
##   SUBJECT_ALLEGED_INJURY
## 1                     No
## 2                    Yes
## 3                     No
## 4                     No
## 5                     No
## 6                     No
##                                                                                            Subject Actions
## 1                                    DID NOT FOLLOW VERBAL DIRECTION, PULLED AWAY, STIFFENED (DEAD WEIGHT)
## 2                                    DID NOT FOLLOW VERBAL DIRECTION, PULLED AWAY, STIFFENED (DEAD WEIGHT)
## 3                                           DID NOT FOLLOW VERBAL DIRECTION, OTHER (DESCRIBE), PULLED AWAY
## 4                              DID NOT FOLLOW VERBAL DIRECTION, FLED, PULLED AWAY, STIFFENED (DEAD WEIGHT)
## 5                              DID NOT FOLLOW VERBAL DIRECTION, FLED, PULLED AWAY, STIFFENED (DEAD WEIGHT)
## 6 DID NOT FOLLOW VERBAL DIRECTION, FLED, PHYSICAL ATTACK WITH WEAPON, PULLED AWAY, STIFFENED (DEAD WEIGHT)
##   SUBJECT_ARMED SUBJECTARMEDWITH WEAPON_PERCEIVED_AS  Subject Weapon
## 1            No                                                     
## 2            No                                                     
## 3            No                                                     
## 4            No                                                     
## 5           Yes  CHEMICAL WEAPON                     CHEMICAL WEAPON
## 6           Yes  CHEMICAL WEAPON                     CHEMICAL WEAPON
##   SUBDRUGRELATED SUBGANGRELATED Assault-Batt Against PO
## 1             No             No                       N
## 2             No             No                       N
## 3             No             No                       N
## 4             No             No                       Y
## 5             No             No                       N
## 6             No             No                       Y
##      Officer Resp Control Tactics
## 1                                
## 2         ESCORT HOLDS, WRISTLOCK
## 3       PUSH/PHYSICAL REDIRECTION
## 4 TAKE DOWN/EMERGENCY HANDCUFFING
## 5        PRESSURE SENSITIVE AREAS
## 6                                
##                               Type Activity New TRR
## 1                                                  
## 2                     OTHER - DESCRIBE IN NARRATIVE
## 3 DISTURBANCE - OTHER, PURSUING / ARRESTING SUBJECT
## 4           DISTURBANCE - OTHER, INVESTIGATORY STOP
## 5 DISTURBANCE - OTHER, PURSUING / ARRESTING SUBJECT
## 6 DISTURBANCE - OTHER, PURSUING / ARRESTING SUBJECT
##                                                                                                               ReasonForResponse New TRR
## 1                                                                                                                                      
## 2                                                                                                                      OTHER (DESCRIBE)
## 3                                         DEFENSE OF MEMBER OF PUBLIC, DEFENSE OF SELF, FLEEING SUBJECT, OVERCOME RESISTANCE/AGGRESSION
## 4                                                                      DEFENSE OF SELF, FLEEING SUBJECT, OVERCOME RESISTANCE/AGGRESSION
## 5                                 DEFENSE OF DEPARTMENT MEMBER, DEFENSE OF MEMBER OF PUBLIC, FLEEING SUBJECT, SUBJECT ARMED WITH WEAPON
## 6 DEFENSE OF DEPARTMENT MEMBER, DEFENSE OF MEMBER OF PUBLIC, FLEEING SUBJECT, OVERCOME RESISTANCE/AGGRESSION, SUBJECT ARMED WITH WEAPON
##                                                                                     ForceMitigationEfforts New TRR
## 1                                                                                                                 
## 2 ADDITIONAL UNIT MEMBERS, MEMBER PRESENCE, TACTICAL POSITIONING, VERBAL DIR. / CONTROL TECHNIQUES, ZONE OF SAFETY
## 3                                       ADDITIONAL UNIT MEMBERS, MEMBER PRESENCE, VERBAL DIR. / CONTROL TECHNIQUES
## 4                                          MEMBER PRESENCE, TACTICAL POSITIONING, VERBAL DIR. / CONTROL TECHNIQUES
## 5                                                        ADDITIONAL UNIT MEMBERS, VERBAL DIR. / CONTROL TECHNIQUES
## 6                                       ADDITIONAL UNIT MEMBERS, MEMBER PRESENCE, VERBAL DIR. / CONTROL TECHNIQUES
##                                      ControlTactics New TRR
## 1                                                          
## 2  ESCORT HOLDS, HANDCUFFS / PHYSICAL RESTRAINTS, WRISTLOCK
## 3                           HANDCUFFS / PHYSICAL RESTRAINTS
## 4                           HANDCUFFS / PHYSICAL RESTRAINTS
## 5 HANDCUFFS / PHYSICAL RESTRAINTS, PRESSURE SENSITIVE AREAS
## 6                           HANDCUFFS / PHYSICAL RESTRAINTS
##   ResponseWithoutWeapons New TRR ResponseWithWeapon New TRR
## 1                                                          
## 2                                                          
## 3      PUSH/PHYSICAL REDIRECTION                           
## 4                      TAKE DOWN                           
## 5                                                          
## 6                                                          
##                                                                                                   Subject_Actions_List
## 1                                        ['DID NOT FOLLOW VERBAL DIRECTION', 'PULLED AWAY', 'STIFFENED (DEAD WEIGHT)']
## 2                                        ['DID NOT FOLLOW VERBAL DIRECTION', 'PULLED AWAY', 'STIFFENED (DEAD WEIGHT)']
## 3                                               ['DID NOT FOLLOW VERBAL DIRECTION', 'OTHER (DESCRIBE)', 'PULLED AWAY']
## 4                                ['DID NOT FOLLOW VERBAL DIRECTION', 'FLED', 'PULLED AWAY', 'STIFFENED (DEAD WEIGHT)']
## 5                                ['DID NOT FOLLOW VERBAL DIRECTION', 'FLED', 'PULLED AWAY', 'STIFFENED (DEAD WEIGHT)']
## 6 ['DID NOT FOLLOW VERBAL DIRECTION', 'FLED', 'PHYSICAL ATTACK WITH WEAPON', 'PULLED AWAY', 'STIFFENED (DEAD WEIGHT)']
##   Action_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM
## 1                                                            0
## 2                                                            0
## 3                                                            0
## 4                                                            0
## 5                                                            0
## 6                                                            0
##   Action_IMMINENT THREAT OF BATTERY-NO WPN Action_OTHER (DESCRIBE)
## 1                                        0                       0
## 2                                        0                       0
## 3                                        0                       1
## 4                                        0                       0
## 5                                        0                       0
## 6                                        0                       0
##   Action_DID NOT FOLLOW VERBAL DIRECTION Action_OTHER (SPECIFY)
## 1                                      1                      0
## 2                                      1                      0
## 3                                      1                      0
## 4                                      1                      0
## 5                                      1                      0
## 6                                      1                      0
##   Action_ATTACK WITHOUT WEAPON Action_WPN Action_ATTACK WITH WEAPON
## 1                            0          0                         0
## 2                            0          0                         0
## 3                            0          0                         0
## 4                            0          0                         0
## 5                            0          0                         0
## 6                            0          0                         0
##   Action_IMMINENT THREAT OF BATTERY Action_PHYSICAL ATTACK WITH WEAPON
## 1                                 0                                  0
## 2                                 0                                  0
## 3                                 0                                  0
## 4                                 0                                  0
## 5                                 0                                  0
## 6                                 0                                  1
##   Action_ATT. TO OBTAIN MEMBER'S WEAPON Action_PHYSICAL OBSTRUCTION
## 1                                     0                           0
## 2                                     0                           0
## 3                                     0                           0
## 4                                     0                           0
## 5                                     0                           0
## 6                                     0                           0
##   Action_FORCE LIKELY TO CAUSE DEATH Action_WEAPON(DESCRIBE IN ADDITIONAL INFO)
## 1                                  0                                          0
## 2                                  0                                          0
## 3                                  0                                          0
## 4                                  0                                          0
## 5                                  0                                          0
## 6                                  0                                          0
##   Action_UNABLE TO UNDERSTAND VERBAL DIRECTION
## 1                                            0
## 2                                            0
## 3                                            0
## 4                                            0
## 5                                            0
## 6                                            0
##   Action_PHYSICAL ATTACK WITHOUT WEAPON Action_PULLED AWAY
## 1                                     0                  1
## 2                                     0                  1
## 3                                     0                  1
## 4                                     0                  1
## 5                                     0                  1
## 6                                     0                  1
##   Action_IMMINENT THREAT OF BATTERY W Action_PERCEIVED AS (SPECIFY)
## 1                                   0                             0
## 2                                   0                             0
## 3                                   0                             0
## 4                                   0                             0
## 5                                   0                             0
## 6                                   0                             0
##   Action_STIFFENED (DEAD WEIGHT) Action_FLED Action_GREAT BODILY HARM
## 1                              1           0                        0
## 2                              1           0                        0
## 3                              0           0                        0
## 4                              1           1                        0
## 5                              1           1                        0
## 6                              1           1                        0
##   Action_VERBAL THREATS Action_THROWN OBJECT
## 1                     0                    0
## 2                     0                    0
## 3                     0                    0
## 4                     0                    0
## 5                     0                    0
## 6                     0                    0
##        Officer Resp Control Tactics_List
## 1                                     []
## 2          ['ESCORT HOLDS', 'WRISTLOCK']
## 3       ['PUSH', 'PHYSICAL REDIRECTION']
## 4 ['TAKE DOWN', 'EMERGENCY HANDCUFFING']
## 5           ['PRESSURE SENSITIVE AREAS']
## 6                                     []
##   Response_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM
## 1                                                              0
## 2                                                              0
## 3                                                              0
## 4                                                              0
## 5                                                              0
## 6                                                              0
##   Response_IMMINENT THREAT OF BATTERY-NO WPN Response_OTHER (DESCRIBE)
## 1                                          0                         0
## 2                                          0                         0
## 3                                          0                         1
## 4                                          0                         0
## 5                                          0                         0
## 6                                          0                         0
##   Response_DID NOT FOLLOW VERBAL DIRECTION Response_OTHER (SPECIFY)
## 1                                        1                        0
## 2                                        1                        0
## 3                                        1                        0
## 4                                        1                        0
## 5                                        1                        0
## 6                                        1                        0
##   Response_ATTACK WITHOUT WEAPON Response_WPN Response_ATTACK WITH WEAPON
## 1                              0            0                           0
## 2                              0            0                           0
## 3                              0            0                           0
## 4                              0            0                           0
## 5                              0            0                           0
## 6                              0            0                           0
##   Response_IMMINENT THREAT OF BATTERY Response_PHYSICAL ATTACK WITH WEAPON
## 1                                   0                                    0
## 2                                   0                                    0
## 3                                   0                                    0
## 4                                   0                                    0
## 5                                   0                                    0
## 6                                   0                                    1
##   Response_ATT. TO OBTAIN MEMBER'S WEAPON Response_PHYSICAL OBSTRUCTION
## 1                                       0                             0
## 2                                       0                             0
## 3                                       0                             0
## 4                                       0                             0
## 5                                       0                             0
## 6                                       0                             0
##   Response_FORCE LIKELY TO CAUSE DEATH
## 1                                    0
## 2                                    0
## 3                                    0
## 4                                    0
## 5                                    0
## 6                                    0
##   Response_WEAPON(DESCRIBE IN ADDITIONAL INFO)
## 1                                            0
## 2                                            0
## 3                                            0
## 4                                            0
## 5                                            0
## 6                                            0
##   Response_UNABLE TO UNDERSTAND VERBAL DIRECTION
## 1                                              0
## 2                                              0
## 3                                              0
## 4                                              0
## 5                                              0
## 6                                              0
##   Response_PHYSICAL ATTACK WITHOUT WEAPON Response_PULLED AWAY
## 1                                       0                    1
## 2                                       0                    1
## 3                                       0                    1
## 4                                       0                    1
## 5                                       0                    1
## 6                                       0                    1
##   Response_IMMINENT THREAT OF BATTERY W Response_PERCEIVED AS (SPECIFY)
## 1                                     0                               0
## 2                                     0                               0
## 3                                     0                               0
## 4                                     0                               0
## 5                                     0                               0
## 6                                     0                               0
##   Response_STIFFENED (DEAD WEIGHT) Response_FLED Response_GREAT BODILY HARM
## 1                                1             0                          0
## 2                                1             0                          0
## 3                                0             0                          0
## 4                                1             1                          0
## 5                                1             1                          0
## 6                                1             1                          0
##   Response_VERBAL THREATS Response_THROWN OBJECT Response_VERBAL COMMANDS
## 1                       0                      0                        0
## 2                       0                      0                        0
## 3                       0                      0                        0
## 4                       0                      0                        0
## 5                       0                      0                        0
## 6                       0                      0                        0
##   Response_WRISTLOCK Response_KICKS Response_PUNCH
## 1                  0              0              0
## 2                  1              0              0
## 3                  0              0              0
## 4                  0              0              0
## 5                  0              0              0
## 6                  0              0              0
##   Response_TASER (ARC CYLCLE) 2 Response_AUTHORIZATION
## 1                             0                      0
## 2                             0                      0
## 3                             0                      0
## 4                             0                      0
## 5                             0                      0
## 6                             0                      0
##   Response_TASER (CONTACT STUN) 2
## 1                               0
## 2                               0
## 3                               0
## 4                               0
## 5                               0
## 6                               0
##   Response_IMPACT MUNITION (DESCRIBE IN ADDITIONAL INFO)
## 1                                                      0
## 2                                                      0
## 3                                                      0
## 4                                                      0
## 5                                                      0
## 6                                                      0
##   Response_TASER (ARC CYLCLE) 1
## 1                             0
## 2                             0
## 3                             0
## 4                             0
## 5                             0
## 6                             0
##   Response_IMPACT WEAPON (DESCRIBE IN ADDITIONAL INFO) Response_KNEE STRIKE
## 1                                                    0                    0
## 2                                                    0                    0
## 3                                                    0                    0
## 4                                                    0                    0
## 5                                                    0                    0
## 6                                                    0                    0
##   Response_CHEMICAL WEAPON Response_EMERGENCY HANDCUFFING Response_O.C.
## 1                        0                              0             0
## 2                        0                              0             0
## 3                        0                              0             0
## 4                        0                              1             0
## 5                        0                              0             0
## 6                        0                              0             0
##   Response_CLOSED HAND STRIKE Response_MEMBER PRESENCE
## 1                           0                        0
## 2                           0                        0
## 3                           0                        0
## 4                           0                        0
## 5                           0                        0
## 6                           0                        0
##   Response_CONTROL INSTRUMENT Response_TASER (CONTACT STUN) 1
## 1                           0                               0
## 2                           0                               0
## 3                           0                               0
## 4                           0                               0
## 5                           0                               0
## 6                           0                               0
##   Response_PHYSICAL REDIRECTION Response_FIREARM
## 1                             0                0
## 2                             0                0
## 3                             1                0
## 4                             0                0
## 5                             0                0
## 6                             0                0
##   Response_TASER (PROBE DISCHARGE) 3 Response_TASER (PROBE DISCHARGE) 1
## 1                                  0                                  0
## 2                                  0                                  0
## 3                                  0                                  0
## 4                                  0                                  0
## 5                                  0                                  0
## 6                                  0                                  0
##   Response_ELBOW STRIKE Response_ARMBAR Response_TASER (SPARK DISPLAYED)
## 1                     0               0                                0
## 2                     0               0                                0
## 3                     0               0                                0
## 4                     0               0                                0
## 5                     0               0                                0
## 6                     0               0                                0
##   Response_TASER (PROBE DISCHARGE) Response_ESCORT HOLDS Response_CANINE
## 1                                0                     0               0
## 2                                0                     1               0
## 3                                0                     0               0
## 4                                0                     0               0
## 5                                0                     0               0
## 6                                0                     0               0
##   Response_TASER (PROBE DISCHARGE) 2 Response_TASER (SPARK DISPLAYED) 1
## 1                                  0                                  0
## 2                                  0                                  0
## 3                                  0                                  0
## 4                                  0                                  0
## 5                                  0                                  0
## 6                                  0                                  0
##   Response_TASER (CONTACT STUN) 3 Response_TASER (ARC CYLCLE)
## 1                               0                           0
## 2                               0                           0
## 3                               0                           0
## 4                               0                           0
## 5                               0                           0
## 6                               0                           0
##   Response_OPEN HAND STRIKE Response_TASER (ARC CYLCLE) 3 Response_TAKE DOWN
## 1                         0                             0                  0
## 2                         0                             0                  0
## 3                         0                             0                  0
## 4                         0                             0                  1
## 5                         0                             0                  0
## 6                         0                             0                  0
##   Response_TASER (CONTACT STUN) Response_PRESSURE SENSITIVE AREAS
## 1                             0                                 0
## 2                             0                                 0
## 3                             0                                 0
## 4                             0                                 0
## 5                             0                                 1
## 6                             0                                 0
##   Response_CHEMICAL WEAPON W Response_PUSH Response_TASER (LASER TARGETED)
## 1                          0             0                               0
## 2                          0             0                               0
## 3                          0             1                               0
## 4                          0             0                               0
## 5                          0             0                               0
## 6                          0             0                               0
##                             Subject_Conditions_List
## 1                      ['ALLEGES INJURY BY MEMBER']
## 2 ['ALLEGES INJURY BY MEMBER', 'INJURED BY MEMBER']
## 3                             ['APPARENTLY NORMAL']
## 4                             ['APPARENTLY NORMAL']
## 5                    ['INJURED UNRELATED TO FORCE']
## 6                    ['INJURED UNRELATED TO FORCE']
##   Condition_INJURED_UNRELATED_TO_FORCE Condition_EMOTIONAL_DISORDER
## 1                                    0                            0
## 2                                    0                            0
## 3                                    0                            0
## 4                                    0                            0
## 5                                    1                            0
## 6                                    1                            0
##   Condition_DISABILITY Condition_APPARENTLY_NORMAL
## 1                    0                           0
## 2                    0                           0
## 3                    0                           1
## 4                    0                           1
## 5                    0                           0
## 6                    0                           0
##   Condition_UNDER_INFLUENCE_OF_ALCOHOL Condition_INJURED_BY_MEMBER
## 1                                    0                           0
## 2                                    0                           1
## 3                                    0                           0
## 4                                    0                           0
## 5                                    0                           0
## 6                                    0                           0
##   Condition_MENTAL_ILL. Condition_UNDER_INFLUENCE_OF_DRUGS
## 1                     0                                  0
## 2                     0                                  0
## 3                     0                                  0
## 4                     0                                  0
## 5                     0                                  0
## 6                     0                                  0
##   Condition_ALLEGES_INJURY_BY_MEMBER Condition_OTHER Force_Level Escalation
## 1                                  1               0           1          0
## 2                                  1               0           1          0
## 3                                  0               0           1          0
## 4                                  0               0           1          0
## 5                                  0               0           1          0
## 6                                  0               0           1          0
##          datetime crime_7d violent_crime_7d arrest_7d cad_24h crime_7d.1
## 1  1/26/2022 7:57       29               10         6      11         29
## 2  1/26/2022 7:57       29               10         6      11         29
## 3 3/14/2022 16:31       21                8         2      27         21
## 4  5/2/2022 17:45       23                7         9       0         23
## 5   7/3/2022 0:57       31                7         6       0         31
## 6   7/3/2022 0:57       31                7         6       0         31
##   violent_7d arrest_7d.1 cad_24h.1  cad_rate crime_rate violent_ratio
## 1          8           6        11 0.4583333   4.142857     0.2758621
## 2          8           6        11 0.4583333   4.142857     0.2758621
## 3          8           2        27 1.1250000   3.000000     0.3809524
## 4          7           9         0 0.0000000   3.285714     0.3043478
## 5          7           6         0 0.0000000   4.428571     0.2258065
## 6          7           6         0 0.0000000   4.428571     0.2258065
##   beat_cad_mean cad_relative hour day_of_week month is_weekend
## 1      11.31148    0.9724638    7           2     1          0
## 2      11.31148    0.9724638    7           2     1          0
## 3      11.31148    2.3869565   16           0     3          0
## 4      11.31148    0.0000000   17           0     5          0
## 5      11.31148    0.0000000    0           6     7          1
## 6      11.31148    0.0000000    0           6     7          1
##   time_since_last_trr INCIDENT_DATE INCIDENT_TIME DAY_OF_WEEK HOUR MONTH YEAR
## 1            752.6833    2022-01-26         07:57         Wed    7   Jan 2022
## 2              0.0000    2022-01-26         07:57         Wed    7   Jan 2022
## 3           1136.5667    2022-03-14         16:31         Mon   16   Mar 2022
## 4           1177.2333    2022-05-02         17:45         Mon   17   May 2022
## 5           1471.2000    2022-07-03         00:57         Sun    0   Jul 2022
## 6              0.0000    2022-07-03         00:57         Sun    0   Jul 2022
##   WEEKEND TIME_OF_DAY
## 1       0     Morning
## 2       0     Morning
## 3       0   Afternoon
## 4       0     Evening
## 5       1       Night
## 6       1       Night
CPD3 <- CPD2 %>%
  filter(INCIDENT_DATE >= as.Date("2022-01-01"))

nrow(CPD3)
## [1] 15629
colSums(is.na(CPD3))
##                                                      REPORT NO 
##                                                              0 
##                                               INCIDENTDATETIME 
##                                                              0 
##                                                           BEAT 
##                                                              0 
##                                                           WARD 
##                                                            104 
##                                                      COMMUNITY 
##                                                              0 
##                                                    STREET NAME 
##                                                              0 
##                                                       ZIP CODE 
##                                                              0 
##                                                  LOCATION CODE 
##                                                              0 
##                                              INDOOR_OR_OUTDOOR 
##                                                              0 
##                                             LIGHTING_CONDITION 
##                                                              0 
##                                              WEATHER_CONDITION 
##                                                              0 
##                                          MEM_WAS_ALONE_PARTNER 
##                                                              0 
##                                        ASSISTING_UNIT_ON_SCENE 
##                                                              0 
##                                                    PATROL_TYPE 
##                                                              0 
##                                               INVOLVED_PURSUIT 
##                                                              0 
##                                                  MEMBER_INJURY 
##                                                              0 
##                                                        SUBJSEX 
##                                                              0 
##                                                       SUB_RACE 
##                                                              0 
##                                      SUBJECT_CONDITION_NEW_TRR 
##                                                              0 
##                                                SUBJECT_INJURED 
##                                                              0 
##                                         SUBJECT_ALLEGED_INJURY 
##                                                              0 
##                                                Subject Actions 
##                                                              0 
##                                                  SUBJECT_ARMED 
##                                                              0 
##                                               SUBJECTARMEDWITH 
##                                                              0 
##                                            WEAPON_PERCEIVED_AS 
##                                                              0 
##                                                 Subject Weapon 
##                                                              0 
##                                                 SUBDRUGRELATED 
##                                                              0 
##                                                 SUBGANGRELATED 
##                                                              0 
##                                        Assault-Batt Against PO 
##                                                              0 
##                                   Officer Resp Control Tactics 
##                                                              0 
##                                          Type Activity New TRR 
##                                                              0 
##                                      ReasonForResponse New TRR 
##                                                              0 
##                                 ForceMitigationEfforts New TRR 
##                                                              0 
##                                         ControlTactics New TRR 
##                                                              0 
##                                 ResponseWithoutWeapons New TRR 
##                                                              0 
##                                     ResponseWithWeapon New TRR 
##                                                              0 
##                                           Subject_Actions_List 
##                                                              0 
##   Action_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM 
##                                                              0 
##                       Action_IMMINENT THREAT OF BATTERY-NO WPN 
##                                                              0 
##                                        Action_OTHER (DESCRIBE) 
##                                                              0 
##                         Action_DID NOT FOLLOW VERBAL DIRECTION 
##                                                              0 
##                                         Action_OTHER (SPECIFY) 
##                                                              0 
##                                   Action_ATTACK WITHOUT WEAPON 
##                                                              0 
##                                                     Action_WPN 
##                                                              0 
##                                      Action_ATTACK WITH WEAPON 
##                                                              0 
##                              Action_IMMINENT THREAT OF BATTERY 
##                                                              0 
##                             Action_PHYSICAL ATTACK WITH WEAPON 
##                                                              0 
##                          Action_ATT. TO OBTAIN MEMBER'S WEAPON 
##                                                              0 
##                                    Action_PHYSICAL OBSTRUCTION 
##                                                              0 
##                             Action_FORCE LIKELY TO CAUSE DEATH 
##                                                              0 
##                     Action_WEAPON(DESCRIBE IN ADDITIONAL INFO) 
##                                                              0 
##                   Action_UNABLE TO UNDERSTAND VERBAL DIRECTION 
##                                                              0 
##                          Action_PHYSICAL ATTACK WITHOUT WEAPON 
##                                                              0 
##                                             Action_PULLED AWAY 
##                                                              0 
##                            Action_IMMINENT THREAT OF BATTERY W 
##                                                              0 
##                                  Action_PERCEIVED AS (SPECIFY) 
##                                                              0 
##                                 Action_STIFFENED (DEAD WEIGHT) 
##                                                              0 
##                                                    Action_FLED 
##                                                              0 
##                                       Action_GREAT BODILY HARM 
##                                                              0 
##                                          Action_VERBAL THREATS 
##                                                              0 
##                                           Action_THROWN OBJECT 
##                                                              0 
##                              Officer Resp Control Tactics_List 
##                                                              0 
## Response_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM 
##                                                              0 
##                     Response_IMMINENT THREAT OF BATTERY-NO WPN 
##                                                              0 
##                                      Response_OTHER (DESCRIBE) 
##                                                              0 
##                       Response_DID NOT FOLLOW VERBAL DIRECTION 
##                                                              0 
##                                       Response_OTHER (SPECIFY) 
##                                                              0 
##                                 Response_ATTACK WITHOUT WEAPON 
##                                                              0 
##                                                   Response_WPN 
##                                                              0 
##                                    Response_ATTACK WITH WEAPON 
##                                                              0 
##                            Response_IMMINENT THREAT OF BATTERY 
##                                                              0 
##                           Response_PHYSICAL ATTACK WITH WEAPON 
##                                                              0 
##                        Response_ATT. TO OBTAIN MEMBER'S WEAPON 
##                                                              0 
##                                  Response_PHYSICAL OBSTRUCTION 
##                                                              0 
##                           Response_FORCE LIKELY TO CAUSE DEATH 
##                                                              0 
##                   Response_WEAPON(DESCRIBE IN ADDITIONAL INFO) 
##                                                              0 
##                 Response_UNABLE TO UNDERSTAND VERBAL DIRECTION 
##                                                              0 
##                        Response_PHYSICAL ATTACK WITHOUT WEAPON 
##                                                              0 
##                                           Response_PULLED AWAY 
##                                                              0 
##                          Response_IMMINENT THREAT OF BATTERY W 
##                                                              0 
##                                Response_PERCEIVED AS (SPECIFY) 
##                                                              0 
##                               Response_STIFFENED (DEAD WEIGHT) 
##                                                              0 
##                                                  Response_FLED 
##                                                              0 
##                                     Response_GREAT BODILY HARM 
##                                                              0 
##                                        Response_VERBAL THREATS 
##                                                              0 
##                                         Response_THROWN OBJECT 
##                                                              0 
##                                       Response_VERBAL COMMANDS 
##                                                              0 
##                                             Response_WRISTLOCK 
##                                                              0 
##                                                 Response_KICKS 
##                                                              0 
##                                                 Response_PUNCH 
##                                                              0 
##                                  Response_TASER (ARC CYLCLE) 2 
##                                                              0 
##                                         Response_AUTHORIZATION 
##                                                              0 
##                                Response_TASER (CONTACT STUN) 2 
##                                                              0 
##         Response_IMPACT MUNITION (DESCRIBE IN ADDITIONAL INFO) 
##                                                              0 
##                                  Response_TASER (ARC CYLCLE) 1 
##                                                              0 
##           Response_IMPACT WEAPON (DESCRIBE IN ADDITIONAL INFO) 
##                                                              0 
##                                           Response_KNEE STRIKE 
##                                                              0 
##                                       Response_CHEMICAL WEAPON 
##                                                              0 
##                                 Response_EMERGENCY HANDCUFFING 
##                                                              0 
##                                                  Response_O.C. 
##                                                              0 
##                                    Response_CLOSED HAND STRIKE 
##                                                              0 
##                                       Response_MEMBER PRESENCE 
##                                                              0 
##                                    Response_CONTROL INSTRUMENT 
##                                                              0 
##                                Response_TASER (CONTACT STUN) 1 
##                                                              0 
##                                  Response_PHYSICAL REDIRECTION 
##                                                              0 
##                                               Response_FIREARM 
##                                                              0 
##                             Response_TASER (PROBE DISCHARGE) 3 
##                                                              0 
##                             Response_TASER (PROBE DISCHARGE) 1 
##                                                              0 
##                                          Response_ELBOW STRIKE 
##                                                              0 
##                                                Response_ARMBAR 
##                                                              0 
##                               Response_TASER (SPARK DISPLAYED) 
##                                                              0 
##                               Response_TASER (PROBE DISCHARGE) 
##                                                              0 
##                                          Response_ESCORT HOLDS 
##                                                              0 
##                                                Response_CANINE 
##                                                              0 
##                             Response_TASER (PROBE DISCHARGE) 2 
##                                                              0 
##                             Response_TASER (SPARK DISPLAYED) 1 
##                                                              0 
##                                Response_TASER (CONTACT STUN) 3 
##                                                              0 
##                                    Response_TASER (ARC CYLCLE) 
##                                                              0 
##                                      Response_OPEN HAND STRIKE 
##                                                              0 
##                                  Response_TASER (ARC CYLCLE) 3 
##                                                              0 
##                                             Response_TAKE DOWN 
##                                                              0 
##                                  Response_TASER (CONTACT STUN) 
##                                                              0 
##                              Response_PRESSURE SENSITIVE AREAS 
##                                                              0 
##                                     Response_CHEMICAL WEAPON W 
##                                                              0 
##                                                  Response_PUSH 
##                                                              0 
##                                Response_TASER (LASER TARGETED) 
##                                                              0 
##                                        Subject_Conditions_List 
##                                                              0 
##                           Condition_INJURED_UNRELATED_TO_FORCE 
##                                                              0 
##                                   Condition_EMOTIONAL_DISORDER 
##                                                              0 
##                                           Condition_DISABILITY 
##                                                              0 
##                                    Condition_APPARENTLY_NORMAL 
##                                                              0 
##                           Condition_UNDER_INFLUENCE_OF_ALCOHOL 
##                                                              0 
##                                    Condition_INJURED_BY_MEMBER 
##                                                              0 
##                                          Condition_MENTAL_ILL. 
##                                                              0 
##                             Condition_UNDER_INFLUENCE_OF_DRUGS 
##                                                              0 
##                             Condition_ALLEGES_INJURY_BY_MEMBER 
##                                                              0 
##                                                Condition_OTHER 
##                                                              0 
##                                                    Force_Level 
##                                                              0 
##                                                     Escalation 
##                                                              0 
##                                                       datetime 
##                                                              0 
##                                                       crime_7d 
##                                                              0 
##                                               violent_crime_7d 
##                                                              0 
##                                                      arrest_7d 
##                                                              0 
##                                                        cad_24h 
##                                                              0 
##                                                     crime_7d.1 
##                                                            103 
##                                                     violent_7d 
##                                                            103 
##                                                    arrest_7d.1 
##                                                            103 
##                                                      cad_24h.1 
##                                                              0 
##                                                       cad_rate 
##                                                              0 
##                                                     crime_rate 
##                                                              0 
##                                                  violent_ratio 
##                                                              0 
##                                                  beat_cad_mean 
##                                                              0 
##                                                   cad_relative 
##                                                              7 
##                                                           hour 
##                                                              0 
##                                                    day_of_week 
##                                                              0 
##                                                          month 
##                                                              0 
##                                                     is_weekend 
##                                                              0 
##                                            time_since_last_trr 
##                                                              1 
##                                                  INCIDENT_DATE 
##                                                              0 
##                                                  INCIDENT_TIME 
##                                                              0 
##                                                    DAY_OF_WEEK 
##                                                              0 
##                                                           HOUR 
##                                                              0 
##                                                          MONTH 
##                                                              0 
##                                                           YEAR 
##                                                              0 
##                                                        WEEKEND 
##                                                              0 
##                                                    TIME_OF_DAY 
##                                                              0
CPD4 <- CPD3 %>%
  drop_na(crime_rate, cad_relative)
nrow(CPD3)
## [1] 15629
nrow(CPD4)
## [1] 15622
CPD5 <- CPD4

nrow(CPD5)
## [1] 15622
library(ggplot2)
library(scales)
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
ggplot(CPD5, aes(
  x = factor(Force_Level),
  fill = factor(`Action_STIFFENED (DEAD WEIGHT)`)
)) +
  geom_bar(position = "fill", color = "black") +
  scale_y_continuous(labels = percent) +
  scale_fill_manual(
    values = c("0" = "#fddbc7", "1" = "#d73027"),
    labels = c("No", "Yes")
  ) +
  labs(
    title = "Subject Body Stiffening by Force Level",
    x = "Force Level",
    y = "Proportion of Incidents",
    fill = "Stiffened"
  ) +
  theme_minimal(base_size = 14)

2. Weapon present by force level

ggplot(CPD5, aes(
  x = factor(Force_Level),
  fill = factor(Action_WPN)
)) +
  geom_bar(position = "fill", color = "black") +
  scale_y_continuous(labels = percent) +
  scale_fill_manual(
    values = c("0" = "#fddbc7", "1" = "#d73027"),
    labels = c("No", "Yes")
  ) +
  labs(
    title = "Weapon Indicator by Force Level",
    x = "Force Level",
    y = "Proportion of Incidents",
    fill = "Weapon Present"
  ) +
  theme_minimal(base_size = 14)

3. Incidents by time of day

CPD5$TIME_OF_DAY <- factor(
  CPD5$TIME_OF_DAY,
  levels = c("Morning", "Afternoon", "Evening", "Night")
)

ggplot(CPD5, aes(x = TIME_OF_DAY, fill = TIME_OF_DAY)) +
  geom_bar(color = "black", show.legend = FALSE) +
  labs(
    title = "Incidents by Time of Day",
    x = "Time of Day",
    y = "Incident Count"
  ) +
  theme_minimal(base_size = 14)

4. Force level by time of day

ggplot(CPD5, aes(
  x = TIME_OF_DAY,
  fill = factor(Force_Level)
)) +
  geom_bar(position = "fill", color = "black") +
  scale_y_continuous(labels = percent) +
  labs(
    title = "Force Level Distribution by Time of Day",
    x = "Time of Day",
    y = "Proportion of Incidents",
    fill = "Force Level"
  ) +
  theme_minimal(base_size = 14)

5. Weekend vs force level

ggplot(CPD5, aes(
  x = factor(WEEKEND),
  fill = factor(Force_Level)
)) +
  geom_bar(position = "fill", color = "black") +
  scale_y_continuous(labels = percent) +
  scale_x_discrete(labels = c("0" = "Weekday", "1" = "Weekend")) +
  labs(
    title = "Force Level Distribution by Weekend",
    x = "Day Type",
    y = "Proportion of Incidents",
    fill = "Force Level"
  ) +
  theme_minimal(base_size = 14)

6. Recent crime rate by force level

ggplot(CPD5, aes(
  x = factor(Force_Level),
  y = crime_rate
)) +
  geom_boxplot(fill = "#fddbc7", color = "black") +
  labs(
    title = "Recent Crime Rate by Force Level",
    x = "Force Level",
    y = "Recent Crime Rate"
  ) +
  theme_minimal(base_size = 14)

7. Beat plot

top_beats <- CPD5 %>%
  count(BEAT, sort = TRUE) %>%
  slice_head(n = 15)

ggplot(top_beats, aes(
  x = reorder(factor(BEAT), n),
  y = n
)) +
  geom_col(fill = "#d73027", color = "black") +
  coord_flip() +
  labs(
    title = "Top Beats by Incident Count",
    x = "Beat",
    y = "Incident Count"
  ) +
  theme_minimal(base_size = 14)

c("Force_Level", "Escalation", "crime_rate", "cad_relative") %in% names(CPD5)
## [1] TRUE TRUE TRUE TRUE
glimpse(CPD5)
## Rows: 15,622
## Columns: 166
## $ `REPORT NO`                                                      <chr> "2022…
## $ INCIDENTDATETIME                                                 <dttm> 2022…
## $ BEAT                                                             <int> 111, …
## $ WARD                                                             <int> 42, 4…
## $ COMMUNITY                                                        <chr> "LOOP…
## $ `STREET NAME`                                                    <chr> "STAT…
## $ `ZIP CODE`                                                       <int> 60601…
## $ `LOCATION CODE`                                                  <chr> "CTA …
## $ INDOOR_OR_OUTDOOR                                                <chr> "INDO…
## $ LIGHTING_CONDITION                                               <chr> "ARTI…
## $ WEATHER_CONDITION                                                <chr> "CLEA…
## $ MEM_WAS_ALONE_PARTNER                                            <chr> "PART…
## $ ASSISTING_UNIT_ON_SCENE                                          <chr> "Y", …
## $ PATROL_TYPE                                                      <chr> "CAR"…
## $ INVOLVED_PURSUIT                                                 <chr> "", "…
## $ MEMBER_INJURY                                                    <chr> "NONE…
## $ SUBJSEX                                                          <chr> "MALE…
## $ SUB_RACE                                                         <chr> "BLAC…
## $ SUBJECT_CONDITION_NEW_TRR                                        <chr> "ALLE…
## $ SUBJECT_INJURED                                                  <chr> "No",…
## $ SUBJECT_ALLEGED_INJURY                                           <chr> "No",…
## $ `Subject Actions`                                                <chr> "DID …
## $ SUBJECT_ARMED                                                    <chr> "No",…
## $ SUBJECTARMEDWITH                                                 <chr> "", "…
## $ WEAPON_PERCEIVED_AS                                              <chr> "", "…
## $ `Subject Weapon`                                                 <chr> "", "…
## $ SUBDRUGRELATED                                                   <chr> "No",…
## $ SUBGANGRELATED                                                   <chr> "No",…
## $ `Assault-Batt Against PO`                                        <chr> "N", …
## $ `Officer Resp Control Tactics`                                   <chr> "", "…
## $ `Type Activity New TRR`                                          <chr> "", "…
## $ `ReasonForResponse New TRR`                                      <chr> "", "…
## $ `ForceMitigationEfforts New TRR`                                 <chr> "", "…
## $ `ControlTactics New TRR`                                         <chr> "", "…
## $ `ResponseWithoutWeapons New TRR`                                 <chr> "", "…
## $ `ResponseWithWeapon New TRR`                                     <chr> "", "…
## $ Subject_Actions_List                                             <chr> "['DI…
## $ `Action_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM`   <int> 0, 0,…
## $ `Action_IMMINENT THREAT OF BATTERY-NO WPN`                       <int> 0, 0,…
## $ `Action_OTHER (DESCRIBE)`                                        <int> 0, 0,…
## $ `Action_DID NOT FOLLOW VERBAL DIRECTION`                         <int> 1, 1,…
## $ `Action_OTHER (SPECIFY)`                                         <int> 0, 0,…
## $ `Action_ATTACK WITHOUT WEAPON`                                   <int> 0, 0,…
## $ Action_WPN                                                       <int> 0, 0,…
## $ `Action_ATTACK WITH WEAPON`                                      <int> 0, 0,…
## $ `Action_IMMINENT THREAT OF BATTERY`                              <int> 0, 0,…
## $ `Action_PHYSICAL ATTACK WITH WEAPON`                             <int> 0, 0,…
## $ `Action_ATT. TO OBTAIN MEMBER'S WEAPON`                          <int> 0, 0,…
## $ `Action_PHYSICAL OBSTRUCTION`                                    <int> 0, 0,…
## $ `Action_FORCE LIKELY TO CAUSE DEATH`                             <int> 0, 0,…
## $ `Action_WEAPON(DESCRIBE IN ADDITIONAL INFO)`                     <int> 0, 0,…
## $ `Action_UNABLE TO UNDERSTAND VERBAL DIRECTION`                   <int> 0, 0,…
## $ `Action_PHYSICAL ATTACK WITHOUT WEAPON`                          <int> 0, 0,…
## $ `Action_PULLED AWAY`                                             <int> 1, 1,…
## $ `Action_IMMINENT THREAT OF BATTERY W`                            <int> 0, 0,…
## $ `Action_PERCEIVED AS (SPECIFY)`                                  <int> 0, 0,…
## $ `Action_STIFFENED (DEAD WEIGHT)`                                 <int> 1, 1,…
## $ Action_FLED                                                      <int> 0, 0,…
## $ `Action_GREAT BODILY HARM`                                       <int> 0, 0,…
## $ `Action_VERBAL THREATS`                                          <int> 0, 0,…
## $ `Action_THROWN OBJECT`                                           <int> 0, 0,…
## $ `Officer Resp Control Tactics_List`                              <chr> "[]",…
## $ `Response_USES FORCE LIKELY TO CAUSE DEATH OR GREAT BODILY HARM` <int> 0, 0,…
## $ `Response_IMMINENT THREAT OF BATTERY-NO WPN`                     <int> 0, 0,…
## $ `Response_OTHER (DESCRIBE)`                                      <int> 0, 0,…
## $ `Response_DID NOT FOLLOW VERBAL DIRECTION`                       <int> 1, 1,…
## $ `Response_OTHER (SPECIFY)`                                       <int> 0, 0,…
## $ `Response_ATTACK WITHOUT WEAPON`                                 <int> 0, 0,…
## $ Response_WPN                                                     <int> 0, 0,…
## $ `Response_ATTACK WITH WEAPON`                                    <int> 0, 0,…
## $ `Response_IMMINENT THREAT OF BATTERY`                            <int> 0, 0,…
## $ `Response_PHYSICAL ATTACK WITH WEAPON`                           <int> 0, 0,…
## $ `Response_ATT. TO OBTAIN MEMBER'S WEAPON`                        <int> 0, 0,…
## $ `Response_PHYSICAL OBSTRUCTION`                                  <int> 0, 0,…
## $ `Response_FORCE LIKELY TO CAUSE DEATH`                           <int> 0, 0,…
## $ `Response_WEAPON(DESCRIBE IN ADDITIONAL INFO)`                   <int> 0, 0,…
## $ `Response_UNABLE TO UNDERSTAND VERBAL DIRECTION`                 <int> 0, 0,…
## $ `Response_PHYSICAL ATTACK WITHOUT WEAPON`                        <int> 0, 0,…
## $ `Response_PULLED AWAY`                                           <int> 1, 1,…
## $ `Response_IMMINENT THREAT OF BATTERY W`                          <int> 0, 0,…
## $ `Response_PERCEIVED AS (SPECIFY)`                                <int> 0, 0,…
## $ `Response_STIFFENED (DEAD WEIGHT)`                               <int> 1, 1,…
## $ Response_FLED                                                    <int> 0, 0,…
## $ `Response_GREAT BODILY HARM`                                     <int> 0, 0,…
## $ `Response_VERBAL THREATS`                                        <int> 0, 0,…
## $ `Response_THROWN OBJECT`                                         <int> 0, 0,…
## $ `Response_VERBAL COMMANDS`                                       <int> 0, 0,…
## $ Response_WRISTLOCK                                               <int> 0, 1,…
## $ Response_KICKS                                                   <int> 0, 0,…
## $ Response_PUNCH                                                   <int> 0, 0,…
## $ `Response_TASER (ARC CYLCLE) 2`                                  <int> 0, 0,…
## $ Response_AUTHORIZATION                                           <int> 0, 0,…
## $ `Response_TASER (CONTACT STUN) 2`                                <int> 0, 0,…
## $ `Response_IMPACT MUNITION (DESCRIBE IN ADDITIONAL INFO)`         <int> 0, 0,…
## $ `Response_TASER (ARC CYLCLE) 1`                                  <int> 0, 0,…
## $ `Response_IMPACT WEAPON (DESCRIBE IN ADDITIONAL INFO)`           <int> 0, 0,…
## $ `Response_KNEE STRIKE`                                           <int> 0, 0,…
## $ `Response_CHEMICAL WEAPON`                                       <int> 0, 0,…
## $ `Response_EMERGENCY HANDCUFFING`                                 <int> 0, 0,…
## $ Response_O.C.                                                    <int> 0, 0,…
## $ `Response_CLOSED HAND STRIKE`                                    <int> 0, 0,…
## $ `Response_MEMBER PRESENCE`                                       <int> 0, 0,…
## $ `Response_CONTROL INSTRUMENT`                                    <int> 0, 0,…
## $ `Response_TASER (CONTACT STUN) 1`                                <int> 0, 0,…
## $ `Response_PHYSICAL REDIRECTION`                                  <int> 0, 0,…
## $ Response_FIREARM                                                 <int> 0, 0,…
## $ `Response_TASER (PROBE DISCHARGE) 3`                             <int> 0, 0,…
## $ `Response_TASER (PROBE DISCHARGE) 1`                             <int> 0, 0,…
## $ `Response_ELBOW STRIKE`                                          <int> 0, 0,…
## $ Response_ARMBAR                                                  <int> 0, 0,…
## $ `Response_TASER (SPARK DISPLAYED)`                               <int> 0, 0,…
## $ `Response_TASER (PROBE DISCHARGE)`                               <int> 0, 0,…
## $ `Response_ESCORT HOLDS`                                          <int> 0, 1,…
## $ Response_CANINE                                                  <int> 0, 0,…
## $ `Response_TASER (PROBE DISCHARGE) 2`                             <int> 0, 0,…
## $ `Response_TASER (SPARK DISPLAYED) 1`                             <int> 0, 0,…
## $ `Response_TASER (CONTACT STUN) 3`                                <int> 0, 0,…
## $ `Response_TASER (ARC CYLCLE)`                                    <int> 0, 0,…
## $ `Response_OPEN HAND STRIKE`                                      <int> 0, 0,…
## $ `Response_TASER (ARC CYLCLE) 3`                                  <int> 0, 0,…
## $ `Response_TAKE DOWN`                                             <int> 0, 0,…
## $ `Response_TASER (CONTACT STUN)`                                  <int> 0, 0,…
## $ `Response_PRESSURE SENSITIVE AREAS`                              <int> 0, 0,…
## $ `Response_CHEMICAL WEAPON W`                                     <int> 0, 0,…
## $ Response_PUSH                                                    <int> 0, 0,…
## $ `Response_TASER (LASER TARGETED)`                                <int> 0, 0,…
## $ Subject_Conditions_List                                          <chr> "['AL…
## $ Condition_INJURED_UNRELATED_TO_FORCE                             <int> 0, 0,…
## $ Condition_EMOTIONAL_DISORDER                                     <int> 0, 0,…
## $ Condition_DISABILITY                                             <int> 0, 0,…
## $ Condition_APPARENTLY_NORMAL                                      <int> 0, 0,…
## $ Condition_UNDER_INFLUENCE_OF_ALCOHOL                             <int> 0, 0,…
## $ Condition_INJURED_BY_MEMBER                                      <int> 0, 1,…
## $ Condition_MENTAL_ILL.                                            <int> 0, 0,…
## $ Condition_UNDER_INFLUENCE_OF_DRUGS                               <int> 0, 0,…
## $ Condition_ALLEGES_INJURY_BY_MEMBER                               <int> 1, 1,…
## $ Condition_OTHER                                                  <int> 0, 0,…
## $ Force_Level                                                      <int> 1, 1,…
## $ Escalation                                                       <int> 0, 0,…
## $ datetime                                                         <chr> "1/26…
## $ crime_7d                                                         <int> 29, 2…
## $ violent_crime_7d                                                 <int> 10, 1…
## $ arrest_7d                                                        <int> 6, 6,…
## $ cad_24h                                                          <int> 11, 1…
## $ crime_7d.1                                                       <int> 29, 2…
## $ violent_7d                                                       <int> 8, 8,…
## $ arrest_7d.1                                                      <int> 6, 6,…
## $ cad_24h.1                                                        <int> 11, 1…
## $ cad_rate                                                         <dbl> 0.458…
## $ crime_rate                                                       <dbl> 4.142…
## $ violent_ratio                                                    <dbl> 0.275…
## $ beat_cad_mean                                                    <dbl> 11.31…
## $ cad_relative                                                     <dbl> 0.972…
## $ hour                                                             <int> 7, 7,…
## $ day_of_week                                                      <int> 2, 2,…
## $ month                                                            <int> 1, 1,…
## $ is_weekend                                                       <int> 0, 0,…
## $ time_since_last_trr                                              <dbl> 7.526…
## $ INCIDENT_DATE                                                    <date> 2022…
## $ INCIDENT_TIME                                                    <chr> "07:5…
## $ DAY_OF_WEEK                                                      <ord> Wed, …
## $ HOUR                                                             <int> 7, 7,…
## $ MONTH                                                            <ord> Jan, …
## $ YEAR                                                             <dbl> 2022,…
## $ WEEKEND                                                          <dbl> 0, 0,…
## $ TIME_OF_DAY                                                      <fct> Morni…
cor_data <- CPD5 %>%
  select(
    Force_Level,
    Escalation,
    
    # Operational tempo
    crime_rate,
    cad_relative,
    violent_ratio,
    time_since_last_trr,
    
    # Time
    HOUR,
    WEEKEND,
    
    # Behavior
    Action_WPN,
    Response_WPN,
    `Action_STIFFENED (DEAD WEIGHT)`,
    `Response_STIFFENED (DEAD WEIGHT)`
  )
cor_matrix <- cor(cor_data, use = "complete.obs")

corrplot::corrplot(
  cor_matrix,
  method = "color",
  type = "upper",
  tl.cex = 0.7
)

action_data <- CPD5 %>%
  select(
    Escalation,
    starts_with("Action_")
  )

action_data_clean <- action_data %>%
  select(where(~ sd(.) != 0))
cor_matrix_action <- cor(action_data_clean, use = "complete.obs")
escalation_corr <- cor_matrix_action["Escalation", ]
escalation_corr <- escalation_corr[names(escalation_corr) != "Escalation"]

# Sort from strongest to weakest
escalation_corr_sorted <- sort(escalation_corr, decreasing = TRUE)

escalation_corr_sorted
##                                   Action_WPN 
##                                 1.746327e-01 
##          Action_IMMINENT THREAT OF BATTERY W 
##                                 1.746327e-01 
##           Action_FORCE LIKELY TO CAUSE DEATH 
##                                 1.643859e-01 
##                     Action_GREAT BODILY HARM 
##                                 1.643859e-01 
##     Action_IMMINENT THREAT OF BATTERY-NO WPN 
##                                 1.149219e-01 
##           Action_PHYSICAL ATTACK WITH WEAPON 
##                                 8.800267e-02 
##        Action_PHYSICAL ATTACK WITHOUT WEAPON 
##                                 7.977130e-02 
##        Action_ATT. TO OBTAIN MEMBER'S WEAPON 
##                                 6.729007e-02 
##                        Action_VERBAL THREATS 
##                                 5.109784e-02 
##                                  Action_FLED 
##                                 4.122677e-02 
##                  Action_PHYSICAL OBSTRUCTION 
##                                 3.254905e-02 
##                      Action_OTHER (DESCRIBE) 
##                                 3.070574e-02 
##       Action_DID NOT FOLLOW VERBAL DIRECTION 
##                                 1.823038e-02 
##                         Action_THROWN OBJECT 
##                                 1.662106e-02 
## Action_UNABLE TO UNDERSTAND VERBAL DIRECTION 
##                                -9.087583e-05 
##                           Action_PULLED AWAY 
##                                -6.875154e-02 
##               Action_STIFFENED (DEAD WEIGHT) 
##                                -7.250134e-02
library(ggplot2)

# Take top 10 for clarity
top_corr <- head(sort(escalation_corr, decreasing = TRUE), 10)

df_plot <- data.frame(
  Variable = names(top_corr),
  Correlation = as.numeric(top_corr)
)

ggplot(df_plot, aes(x = reorder(Variable, Correlation), 
                    y = Correlation, 
                    fill = Correlation)) +
  geom_col(color = "black") +
  coord_flip() +
   geom_text(aes(label = round(Correlation, 2)),
          hjust = -0.2,
          size = 4) +
  # Color gradient (blue → white → red)

  expand_limits(y = max(df_plot$Correlation) * 1.2) +

  scale_fill_gradient2(
    low = "#4575b4",
    mid = "white",
    high = "#d73027",
    midpoint = 0
  ) +
  
  labs(
    title = "Top Subject Actions Associated with Escalation",
    x = "Action Variable",
    y = "Correlation with Escalation",
    fill = "Correlation"
  ) +
  
  theme_minimal(base_size = 14) +
  
  theme(
    plot.title = element_text(face = "bold"),
    axis.text.y = element_text(size = 10)
  )

response_data <- CPD5 %>%
  select(
    Escalation,
    starts_with("Response_")
  )
response_data_clean <- response_data %>%
  select(where(~ sd(.) > 0))
cor_matrix_response <- cor(response_data_clean, use = "complete.obs")
response_corr <- cor_matrix_response["Escalation", ]
response_corr <- response_corr[names(response_corr) != "Escalation"]

response_corr_sorted <- sort(response_corr, decreasing = TRUE)

response_corr_sorted
##                                         Response_PUNCH 
##                                           5.660273e-01 
##                            Response_CLOSED HAND STRIKE 
##                                           5.660273e-01 
##                       Response_TASER (PROBE DISCHARGE) 
##                                           4.634943e-01 
##                              Response_OPEN HAND STRIKE 
##                                           3.876975e-01 
##                                       Response_FIREARM 
##                                           3.067386e-01 
##   Response_IMPACT WEAPON (DESCRIBE IN ADDITIONAL INFO) 
##                                           2.758842e-01 
##                                   Response_KNEE STRIKE 
##                                           2.437945e-01 
##                                          Response_O.C. 
##                                           2.212817e-01 
##                               Response_CHEMICAL WEAPON 
##                                           1.866452e-01 
##                                           Response_WPN 
##                                           1.746327e-01 
##                  Response_IMMINENT THREAT OF BATTERY W 
##                                           1.746327e-01 
##                            Response_CONTROL INSTRUMENT 
##                                           1.735460e-01 
##                   Response_FORCE LIKELY TO CAUSE DEATH 
##                                           1.643859e-01 
##                             Response_GREAT BODILY HARM 
##                                           1.643859e-01 
##                                         Response_KICKS 
##                                           1.502800e-01 
##                                  Response_ELBOW STRIKE 
##                                           1.502800e-01 
##                                 Response_AUTHORIZATION 
##                                           1.209832e-01 
##                             Response_CHEMICAL WEAPON W 
##                                           1.209832e-01 
##             Response_IMMINENT THREAT OF BATTERY-NO WPN 
##                                           1.149219e-01 
##                   Response_PHYSICAL ATTACK WITH WEAPON 
##                                           8.800267e-02 
##                Response_PHYSICAL ATTACK WITHOUT WEAPON 
##                                           7.977130e-02 
##                Response_ATT. TO OBTAIN MEMBER'S WEAPON 
##                                           6.729007e-02 
##                                Response_VERBAL THREATS 
##                                           5.109784e-02 
##                      Response_PRESSURE SENSITIVE AREAS 
##                                           5.044409e-02 
## Response_IMPACT MUNITION (DESCRIBE IN ADDITIONAL INFO) 
##                                           4.935955e-02 
##                                          Response_FLED 
##                                           4.122677e-02 
##                          Response_PHYSICAL OBSTRUCTION 
##                                           3.254905e-02 
##                              Response_OTHER (DESCRIBE) 
##                                           3.070574e-02 
##               Response_DID NOT FOLLOW VERBAL DIRECTION 
##                                           1.823038e-02 
##                                 Response_THROWN OBJECT 
##                                           1.662106e-02 
##         Response_UNABLE TO UNDERSTAND VERBAL DIRECTION 
##                                          -9.087583e-05 
##                                     Response_WRISTLOCK 
##                                          -1.080005e-02 
##                                        Response_ARMBAR 
##                                          -1.645538e-02 
##                          Response_PHYSICAL REDIRECTION 
##                                          -2.552683e-02 
##                                          Response_PUSH 
##                                          -2.552683e-02 
##                         Response_EMERGENCY HANDCUFFING 
##                                          -3.630243e-02 
##                                     Response_TAKE DOWN 
##                                          -3.630243e-02 
##                               Response_OTHER (SPECIFY) 
##                                          -5.500526e-02 
##                                  Response_ESCORT HOLDS 
##                                          -6.397144e-02 
##                                   Response_PULLED AWAY 
##                                          -6.875154e-02 
##                       Response_STIFFENED (DEAD WEIGHT) 
##                                          -7.250134e-02
library(ggplot2)

# Clean variable names
df_plot$Variable <- gsub("Response_", "", df_plot$Variable)
df_plot$Variable <- gsub("_", " ", df_plot$Variable)

# Optional: shorten long label
df_plot$Variable[df_plot$Variable == 
  "IMPACT WEAPON (DESCRIBE IN ADDITIONAL INFO)"] <- "IMPACT WEAPON"

ggplot(df_plot, aes(x = reorder(Variable, Correlation), 
                    y = Correlation, 
                    fill = Correlation)) +
  
  geom_col(color = "black", width = 0.7) +
  
  geom_text(aes(label = round(Correlation, 2)),
            hjust = -0.15,
            size = 4) +
  
  coord_flip(clip = "off") +
  
  expand_limits(y = max(df_plot$Correlation) * 1.15) +
  
  scale_fill_gradient(
    low = "#fddbc7",
    high = "#d73027"
  ) +
  
  labs(
    title = "Top Officer Responses Associated with Escalation",
    x = "Response Type",
    y = "Correlation"
  ) +
  
  theme_minimal(base_size = 14) +
  
  theme(
    plot.title.position = "plot",  # <-- critical for left alignment
    plot.title = element_text(
      face = "bold",
      size = 16,
      hjust = 0
    ),
    axis.text.y = element_text(size = 11),
    legend.position = "none",
    plot.margin = margin(10, 10, 10, 10)
  )

#convert gang variable to numeric

CPD5$GANG <- ifelse(CPD5$SUBGANGRELATED == "Yes", 1, 0)

condition_data <- CPD5 %>%
  select(
    Escalation,
    GANG,
    starts_with("Condition_")
  )

#remove zero variance columns

condition_data_clean <- condition_data %>%
  select(where(~ sd(.) > 0))
cor_matrix_condition <- cor(condition_data_clean, use = "complete.obs")
condition_corr <- cor_matrix_condition["Escalation", ]
condition_corr <- condition_corr[names(condition_corr) != "Escalation"]

condition_corr_sorted <- sort(condition_corr, decreasing = TRUE)

condition_corr_sorted
##          Condition_INJURED_BY_MEMBER   Condition_UNDER_INFLUENCE_OF_DRUGS 
##                          0.262701879                          0.027650328 
##         Condition_EMOTIONAL_DISORDER                Condition_MENTAL_ILL. 
##                          0.021763983                          0.021763983 
##                      Condition_OTHER                                 GANG 
##                          0.012675490                          0.008815698 
##                 Condition_DISABILITY Condition_INJURED_UNRELATED_TO_FORCE 
##                         -0.008102721                         -0.012493879 
## Condition_UNDER_INFLUENCE_OF_ALCOHOL   Condition_ALLEGES_INJURY_BY_MEMBER 
##                         -0.019464950                         -0.027926775 
##          Condition_APPARENTLY_NORMAL 
##                         -0.068758593
library(ggplot2)

top_corr <- head(condition_corr_sorted, 8)

df_plot <- data.frame(
  Variable = names(top_corr),
  Correlation = as.numeric(top_corr)
)

# Clean labels
df_plot$Variable <- gsub("Condition_", "", df_plot$Variable)
df_plot$Variable <- gsub("_", " ", df_plot$Variable)

ggplot(df_plot, aes(x = reorder(Variable, Correlation), 
                    y = Correlation, 
                    fill = Correlation)) +
  
  geom_col(color = "black", width = 0.7) +
  
  geom_text(aes(label = round(Correlation, 2)),
            hjust = -0.15,
            size = 4) +
  
  coord_flip(clip = "off") +
  
  expand_limits(y = max(df_plot$Correlation) * 1.15) +
  
  scale_fill_gradient(
    low = "#fddbc7",
    high = "#d73027"
  ) +
  
  labs(
  title = "Subject Conditions Associated with Escalation",
  subtitle = "Includes gang affiliation",
  x = "Subject Condition / Context",
  y = "Correlation"
) +
  theme_minimal(base_size = 14) +
  
  theme(
  plot.title.position = "plot",
  plot.title = element_text(face = "bold", size = 16, hjust = 0),
  plot.subtitle = element_text(size = 12, hjust = 0),
  axis.text.y = element_text(size = 11),
  legend.position = "none",
  plot.margin = margin(10, 10, 10, 10)
)

y <- CPD5$Escalation
X <- CPD5 %>%
  select(
    crime_rate,
    cad_relative,
    violent_ratio,
    WEEKEND,
    HOUR,
    MONTH,
    TIME_OF_DAY,
    Action_WPN,
    Response_WPN,
    `Action_STIFFENED (DEAD WEIGHT)`,
    `Response_STIFFENED (DEAD WEIGHT)`
  )
X$MONTH <- as.factor(X$MONTH)
X$TIME_OF_DAY <- as.factor(X$TIME_OF_DAY)
X$WEEKEND <- as.factor(X$WEEKEND)
model_data <- data.frame(Escalation = y, X)
nrow(model_data)
## [1] 15622
colSums(is.na(model_data))
##                       Escalation                       crime_rate 
##                                0                                0 
##                     cad_relative                    violent_ratio 
##                                0                                0 
##                          WEEKEND                             HOUR 
##                                0                                0 
##                            MONTH                      TIME_OF_DAY 
##                                0                                0 
##                       Action_WPN                     Response_WPN 
##                                0                                0 
##   Action_STIFFENED..DEAD.WEIGHT. Response_STIFFENED..DEAD.WEIGHT. 
##                                0                                0
set.seed(887)

train_index <- sample(1:nrow(model_data), 0.7 * nrow(model_data))

train <- model_data[train_index, ]
test  <- model_data[-train_index, ]
model_logit <- glm(Escalation ~ ., data = train, family = "binomial")

summary(model_logit)
## 
## Call:
## glm(formula = Escalation ~ ., family = "binomial", data = train)
## 
## Coefficients: (2 not defined because of singularities)
##                                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                      -1.7443888  0.1562214 -11.166  < 2e-16 ***
## crime_rate                       -0.0120957  0.0241171  -0.502  0.61599    
## cad_relative                     -0.1159895  0.0401277  -2.891  0.00385 ** 
## violent_ratio                    -0.4443808  0.2508529  -1.771  0.07648 .  
## WEEKEND1                          0.1029958  0.0711849   1.447  0.14793    
## HOUR                             -0.0052293  0.0053059  -0.986  0.32435    
## MONTH.L                          -0.0975543  0.1500484  -0.650  0.51559    
## MONTH.Q                          -0.0008557  0.1258959  -0.007  0.99458    
## MONTH.C                          -0.0563974  0.1234429  -0.457  0.64776    
## MONTH^4                          -0.1854210  0.1250791  -1.482  0.13823    
## MONTH^5                           0.1069470  0.1190928   0.898  0.36918    
## MONTH^6                           0.1006534  0.1195421   0.842  0.39979    
## MONTH^7                          -0.0715472  0.1186431  -0.603  0.54648    
## MONTH^8                          -0.2395256  0.1181922  -2.027  0.04271 *  
## MONTH^9                           0.1054259  0.1155461   0.912  0.36155    
## MONTH^10                          0.0370972  0.1109233   0.334  0.73805    
## MONTH^11                          0.1259248  0.1112636   1.132  0.25773    
## TIME_OF_DAYAfternoon             -0.2767276  0.1086560  -2.547  0.01087 *  
## TIME_OF_DAYEvening               -0.2707034  0.1174868  -2.304  0.02122 *  
## TIME_OF_DAYNight                 -0.1824541  0.0944686  -1.931  0.05344 .  
## Action_WPN                        1.3447398  0.0822103  16.357  < 2e-16 ***
## Response_WPN                             NA         NA      NA       NA    
## Action_STIFFENED..DEAD.WEIGHT.   -0.3806701  0.0678570  -5.610 2.02e-08 ***
## Response_STIFFENED..DEAD.WEIGHT.         NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 6781.0  on 10934  degrees of freedom
## Residual deviance: 6457.2  on 10913  degrees of freedom
## AIC: 6501.2
## 
## Number of Fisher Scoring iterations: 5
prob <- predict(model_logit, newdata = test, type = "response")

pred <- ifelse(prob > 0.5, 1, 0)
mean(pred == test$Escalation)
## [1] 0.9005761
table(Predicted = pred, Actual = test$Escalation)
##          Actual
## Predicted    0    1
##         0 4221  466
summary(model_logit)
## 
## Call:
## glm(formula = Escalation ~ ., family = "binomial", data = train)
## 
## Coefficients: (2 not defined because of singularities)
##                                    Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                      -1.7443888  0.1562214 -11.166  < 2e-16 ***
## crime_rate                       -0.0120957  0.0241171  -0.502  0.61599    
## cad_relative                     -0.1159895  0.0401277  -2.891  0.00385 ** 
## violent_ratio                    -0.4443808  0.2508529  -1.771  0.07648 .  
## WEEKEND1                          0.1029958  0.0711849   1.447  0.14793    
## HOUR                             -0.0052293  0.0053059  -0.986  0.32435    
## MONTH.L                          -0.0975543  0.1500484  -0.650  0.51559    
## MONTH.Q                          -0.0008557  0.1258959  -0.007  0.99458    
## MONTH.C                          -0.0563974  0.1234429  -0.457  0.64776    
## MONTH^4                          -0.1854210  0.1250791  -1.482  0.13823    
## MONTH^5                           0.1069470  0.1190928   0.898  0.36918    
## MONTH^6                           0.1006534  0.1195421   0.842  0.39979    
## MONTH^7                          -0.0715472  0.1186431  -0.603  0.54648    
## MONTH^8                          -0.2395256  0.1181922  -2.027  0.04271 *  
## MONTH^9                           0.1054259  0.1155461   0.912  0.36155    
## MONTH^10                          0.0370972  0.1109233   0.334  0.73805    
## MONTH^11                          0.1259248  0.1112636   1.132  0.25773    
## TIME_OF_DAYAfternoon             -0.2767276  0.1086560  -2.547  0.01087 *  
## TIME_OF_DAYEvening               -0.2707034  0.1174868  -2.304  0.02122 *  
## TIME_OF_DAYNight                 -0.1824541  0.0944686  -1.931  0.05344 .  
## Action_WPN                        1.3447398  0.0822103  16.357  < 2e-16 ***
## Response_WPN                             NA         NA      NA       NA    
## Action_STIFFENED..DEAD.WEIGHT.   -0.3806701  0.0678570  -5.610 2.02e-08 ***
## Response_STIFFENED..DEAD.WEIGHT.         NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 6781.0  on 10934  degrees of freedom
## Residual deviance: 6457.2  on 10913  degrees of freedom
## AIC: 6501.2
## 
## Number of Fisher Scoring iterations: 5
library(tidyverse)
library(caret)
## Warning: package 'caret' was built under R version 4.5.2
## Loading required package: lattice
## Warning: package 'lattice' was built under R version 4.5.2
## 
## Attaching package: 'caret'
## The following object is masked from 'package:purrr':
## 
##     lift
library(ranger)
## Warning: package 'ranger' was built under R version 4.5.2
library(rpart)
library(pROC)
## Warning: package 'pROC' was built under R version 4.5.3
## Type 'citation("pROC")' for a citation.
## 
## Attaching package: 'pROC'
## The following objects are masked from 'package:stats':
## 
##     cov, smooth, var
set.seed(123)

# -------------------------------------------------
# 1. Create grouped/domain predictors
# -------------------------------------------------

model_grouped <- CPD5 %>%
  mutate(
    ACTION_WEAPON = rowSums(
  select(., starts_with("Action_")) %>%
    select(where(is.numeric)) %>%
    select(matches("WPN|WEAPON")),
  na.rm = TRUE
),

ACTION_RESIST = rowSums(
  select(., starts_with("Action_")) %>%
    select(where(is.numeric)) %>%
    select(matches("STIFFENED|PULLED|RESIST")),
  na.rm = TRUE
),

ACTION_AGGRESSIVE = rowSums(
  select(., starts_with("Action_")) %>%
    select(where(is.numeric)) %>%
    select(matches("ATTACK|STRIKE|KICK|PUNCH")),
  na.rm = TRUE
),

    CONDITION_SUBSTANCE = rowSums(
  select(., starts_with("Condition_")) %>%
    select(where(is.numeric)) %>%
    select(matches("ALCOHOL|DRUG")),
  na.rm = TRUE
),

CONDITION_MENTAL = rowSums(
  select(., starts_with("Condition_")) %>%
    select(where(is.numeric)) %>%
    select(matches("MENTAL|EMOTIONAL")),
  na.rm = TRUE
),

CONDITION_PHYSICAL = rowSums(
  select(., starts_with("Condition_")) %>%
    select(where(is.numeric)) %>%
    select(matches("INJUR|DISAB")),
  na.rm = TRUE
),

    CONDITION_GANG = GANG,

    OP_TEMPO = crime_rate + cad_relative + violent_ratio,
    TRR_RECENCY = time_since_last_trr,
    TIME_FACTOR = HOUR + WEEKEND
  ) %>%
  select(
    Force_Level,
    ACTION_WEAPON,
    ACTION_RESIST,
    ACTION_AGGRESSIVE,
    CONDITION_SUBSTANCE,
    CONDITION_MENTAL,
    CONDITION_PHYSICAL,
    CONDITION_GANG,
    OP_TEMPO,
    TRR_RECENCY,
    TIME_FACTOR
  ) %>%
  drop_na()

names(model_grouped) <- make.names(names(model_grouped), unique = TRUE)


# -------------------------------------------------
# 2. Build pairwise datasets
# KEEP ONLY 1→2 and 2→3
# DROP 1→3 because it is too rare and unstable
# -------------------------------------------------

make_pair_data <- function(data, low_level, high_level) {
  data %>%
    filter(Force_Level %in% c(low_level, high_level)) %>%
    mutate(
      Escalation_Target = ifelse(Force_Level == high_level, "Higher", "Lower"),
      Escalation_Target = factor(Escalation_Target, levels = c("Higher", "Lower"))
    ) %>%
    select(-Force_Level)
}

data_12 <- make_pair_data(model_grouped, 1, 2)
data_23 <- make_pair_data(model_grouped, 2, 3)

table(data_12$Escalation_Target)
## 
## Higher  Lower 
##   1332  14136
table(data_23$Escalation_Target)
## 
## Higher  Lower 
##    153   1332
ctrl_smote <- trainControl(
  method = "cv",
  number = 5,
  classProbs = TRUE,
  summaryFunction = twoClassSummary,
  sampling = "smote",
  savePredictions = "final"
)
run_simple_models <- function(data) {
  
  predictors <- data %>%
    select(-Escalation_Target)
  
  nzv <- nearZeroVar(predictors)
  
  if(length(nzv) > 0) {
    predictors <- predictors[, -nzv, drop = FALSE]
  }
  
  data_clean <- bind_cols(
    Escalation_Target = data$Escalation_Target,
    predictors
  )
  
  tree_model <- train(
    Escalation_Target ~ .,
    data = data_clean,
    method = "rpart",
    metric = "ROC",
    trControl = ctrl_smote
  )
  
  rf_model <- train(
    Escalation_Target ~ .,
    data = data_clean,
    method = "ranger",
    metric = "ROC",
    trControl = ctrl_smote,
    tuneGrid = expand.grid(
      mtry = 2,
      splitrule = "gini",
      min.node.size = 10
    ),
    importance = "impurity",
    num.trees = 200
  )
  
  list(
    decision_tree = tree_model,
    random_forest = rf_model
  )
}
models_12 <- run_simple_models(data_12)
## Warning: package 'themis' was built under R version 4.5.2
## Loading required package: recipes
## 
## Attaching package: 'recipes'
## The following object is masked from 'package:Matrix':
## 
##     update
## The following object is masked from 'package:stringr':
## 
##     fixed
## The following object is masked from 'package:stats':
## 
##     step
models_23 <- run_simple_models(data_23)

resamples_12 <- resamples(models_12)
resamples_23 <- resamples(models_23)

summary(resamples_12)
## 
## Call:
## summary.resamples(object = resamples_12)
## 
## Models: decision_tree, random_forest 
## Number of resamples: 5 
## 
## ROC 
##                    Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## decision_tree 0.6716431 0.6961788 0.6972467 0.6990724 0.6982445 0.7320488    0
## random_forest 0.6857584 0.6882039 0.6941292 0.6923323 0.6956589 0.6979110    0
## 
## Sens 
##                     Min.    1st Qu.     Median       Mean    3rd Qu.      Max.
## decision_tree 0.14981273 0.15413534 0.20300752 0.18919771 0.21722846 0.2218045
## random_forest 0.07142857 0.07865169 0.08270677 0.08708851 0.09363296 0.1090226
##               NA's
## decision_tree    0
## random_forest    0
## 
## Spec 
##                    Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## decision_tree 0.9359745 0.9448178 0.9589671 0.9522489 0.9596746 0.9618105    0
## random_forest 0.9840821 0.9844358 0.9886806 0.9875494 0.9890382 0.9915104    0
summary(resamples_23)
## 
## Call:
## summary.resamples(object = resamples_23)
## 
## Models: decision_tree, random_forest 
## Number of resamples: 5 
## 
## ROC 
##                    Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## decision_tree 0.8418627 0.8486771 0.8544486 0.8628872 0.8553683 0.9140796    0
## random_forest 0.8687970 0.8749697 0.9000846 0.8997976 0.9002497 0.9548872    0
## 
## Sens 
##                    Min.   1st Qu.    Median      Mean 3rd Qu.      Max. NA's
## decision_tree 0.8666667 0.8709677 0.8709677 0.8888172     0.9 0.9354839    0
## random_forest 0.5000000 0.5161290 0.6129032 0.6206452     0.7 0.7741935    0
## 
## Spec 
##                    Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## decision_tree 0.8157895 0.8345865 0.8389513 0.8475965 0.8576779 0.8909774    0
## random_forest 0.8913858 0.9248120 0.9398496 0.9324491 0.9513109 0.9548872    0
bwplot(resamples_12, metric = "ROC", main = "Model Comparison: Level 1 to Level 2")

bwplot(resamples_23, metric = "ROC", main = "Model Comparison: Level 2 to Level 3")

2. Level 1 → Level 2 model comparison plot

Run this after resamples_12 is created.

bwplot(
  resamples_12,
  metric = "ROC",
  main = "Model Comparison: Level 1 to Level 2"
)

3. Level 2 → Level 3 model comparison plot

Run this after resamples_23 is created.

bwplot(
  resamples_23,
  metric = "ROC",
  main = "Model Comparison: Level 2 to Level 3"
)

get_importance <- function(model, scenario_name) {
  
  imp <- varImp(model)$importance
  
  imp %>%
    rownames_to_column("Factor_Group") %>%
    rename(Importance = Overall) %>%
    mutate(Scenario = scenario_name)
}

imp_12 <- get_importance(models_12$random_forest, "Level 1 to Level 2")
imp_23 <- get_importance(models_23$random_forest, "Level 2 to Level 3")

group_importance <- bind_rows(imp_12, imp_23) %>%
  group_by(Factor_Group) %>%
  summarise(
    Avg_Importance = mean(Importance, na.rm = TRUE),
    .groups = "drop"
  ) %>%
  mutate(
    Percent_Contribution = round(Avg_Importance / sum(Avg_Importance) * 100, 1)
  ) %>%
  arrange(desc(Percent_Contribution))

group_importance
## # A tibble: 9 × 3
##   Factor_Group        Avg_Importance Percent_Contribution
##   <chr>                        <dbl>                <dbl>
## 1 ACTION_RESIST                65.0                  32.5
## 2 ACTION_WEAPON                53.0                  26.5
## 3 CONDITION_PHYSICAL           32.4                  16.2
## 4 ACTION_AGGRESSIVE            19.8                   9.9
## 5 CONDITION_SUBSTANCE          16.2                   8.1
## 6 TRR_RECENCY                   6.57                  3.3
## 7 TIME_FACTOR                   3.21                  1.6
## 8 CONDITION_MENTAL              2.46                  1.2
## 9 OP_TEMPO                      1.15                  0.6
ggplot(group_importance, aes(x = reorder(Factor_Group, Percent_Contribution),
                             y = Percent_Contribution,
                             fill = Percent_Contribution)) +
  geom_col(color = "black", width = 0.7) +
  geom_text(aes(label = paste0(Percent_Contribution, "%")),
            hjust = -0.15,
            size = 4) +
  coord_flip(clip = "off") +
  expand_limits(y = max(group_importance$Percent_Contribution) * 1.15) +
  scale_fill_gradient(
    low = "#fddbc7",
    high = "#d73027"
  ) +
  labs(
    title = "Grouped Factors Contributing to Force Escalation",
    subtitle = "Random Forest with SMOTE; Level 1→2 and Level 2→3 scenarios",
    x = "Factor Group",
    y = "Relative Contribution (%)"
  ) +
  theme_minimal(base_size = 14) +
  theme(
    plot.title.position = "plot",
    plot.title = element_text(face = "bold", size = 16, hjust = 0),
    plot.subtitle = element_text(size = 12, hjust = 0),
    legend.position = "none",
    plot.margin = margin(10, 10, 10, 10)
  )

8. Grouped contributing factors plot

Use after your model runs and group_importance exists:

ggplot(group_importance, aes(
  x = reorder(Factor_Group, Percent_Contribution),
  y = Percent_Contribution,
  fill = Percent_Contribution
)) +
  geom_col(color = "black", width = 0.7) +
  geom_text(
    aes(label = paste0(Percent_Contribution, "%")),
    hjust = -0.15,
    size = 4
  ) +
  coord_flip(clip = "off") +
  expand_limits(y = max(group_importance$Percent_Contribution) * 1.15) +
  scale_fill_gradient(
    low = "#fddbc7",
    high = "#d73027"
  ) +
  labs(
    title = "Grouped Factors Contributing to Force Escalation",
    subtitle = "Random Forest with SMOTE; Level 1→2 and Level 2→3 scenarios",
    x = "Factor Group",
    y = "Relative Contribution (%)"
  ) +
  theme_minimal(base_size = 14) +
  theme(
    plot.title.position = "plot",
    plot.title = element_text(face = "bold", size = 16, hjust = 0),
    plot.subtitle = element_text(size = 12, hjust = 0),
    legend.position = "none",
    plot.margin = margin(10, 10, 10, 10)
  )

library(ggplot2)

ggplot(group_importance, aes(
  x = reorder(Factor_Group, Percent_Contribution),
  y = Percent_Contribution,
  fill = Percent_Contribution
)) +
  geom_col(color = "black", width = 0.7) +
  geom_text(
    aes(label = paste0(Percent_Contribution, "%")),
    hjust = -0.15,
    size = 4
  ) +
  coord_flip(clip = "off") +
  expand_limits(y = max(group_importance$Percent_Contribution) * 1.15) +
  scale_fill_gradient(
    low = "#fddbc7",
    high = "#d73027"
  ) +
  labs(
    title = "Grouped Factors Contributing to Force Escalation",
    subtitle = "Random Forest with SMOTE",
    x = "Factor Group",
    y = "Relative Contribution (%)"
  ) +
  theme_minimal(base_size = 14) +
  theme(
    plot.title.position = "plot",
    plot.title = element_text(face = "bold", size = 16, hjust = 0),
    plot.subtitle = element_text(size = 12, hjust = 0),
    legend.position = "none",
    plot.margin = margin(10, 10, 10, 10)
  )

2. Level 1 → Level 2 model comparison plot

Run this after resamples_12 is created.

bwplot(
  resamples_12,
  metric = "ROC",
  main = "Model Comparison: Level 1 to Level 2"
)

cross-validation metrics

library(caret)
library(dplyr)
library(tibble)
library(pROC)
library(PRROC)
## Warning: package 'PRROC' was built under R version 4.5.2
## Loading required package: rlang
## 
## Attaching package: 'rlang'
## The following objects are masked from 'package:purrr':
## 
##     %@%, flatten, flatten_chr, flatten_dbl, flatten_int, flatten_lgl,
##     flatten_raw, invoke, splice
extract_metrics <- function(pred, prob, actual, scenario, model_name, validation_type) {
  
  actual <- factor(actual, levels = c("Higher", "Lower"))
  pred   <- factor(pred, levels = c("Higher", "Lower"))
  
  cm <- caret::confusionMatrix(pred, actual, positive = "Higher")
  
  accuracy  <- cm$overall["Accuracy"]
  recall    <- cm$byClass["Sensitivity"]
  precision <- cm$byClass["Precision"]
  f1 <- 2 * (precision * recall) / (precision + recall)
  
  roc_obj <- pROC::roc(
    response = actual,
    predictor = prob[, "Higher"],
    levels = c("Lower", "Higher"),
    direction = "<"
  )
  
  roc_auc <- pROC::auc(roc_obj)
  
  # --- Precision-Recall AUC (Average Precision) ---
pr_obj <- PRROC::pr.curve(
  scores.class0 = prob[actual == "Higher", "Higher"],  # positives
  scores.class1 = prob[actual == "Lower", "Higher"],   # negatives
  curve = FALSE
)

avg_precision <- pr_obj$auc.integral
  
  data.frame(
  Scenario = scenario,
  Model = model_name,
  Validation = validation_type,
  Accuracy = round(as.numeric(accuracy), 3),
  Recall = round(as.numeric(recall), 3),
  Precision = round(as.numeric(precision), 3),
  F1_Score = round(as.numeric(f1), 3),
  ROC_AUC = round(as.numeric(roc_auc), 3),
  Avg_Precision = round(as.numeric(avg_precision), 3)
)
}

get_cv_metrics <- function(model, scenario, model_name) {
  
  preds <- model$pred
  
  tune_cols <- names(model$bestTune)
  
  if(length(tune_cols) > 0) {
    for(col in tune_cols) {
      preds <- preds[preds[[col]] == model$bestTune[[col]], ]
    }
  }
  
  extract_metrics(
    pred = preds$pred,
    prob = preds[, c("Higher", "Lower")],
    actual = preds$obs,
    scenario = scenario,
    model_name = model_name,
    validation_type = "Cross-validation"
  )
}

cv_results <- bind_rows(
  get_cv_metrics(models_12$random_forest, "Level 1 → Level 2", "Random Forest"),
  get_cv_metrics(models_12$decision_tree, "Level 1 → Level 2", "Decision Tree"),
  get_cv_metrics(models_23$random_forest, "Level 2 → Level 3", "Random Forest"),
  get_cv_metrics(models_23$decision_tree, "Level 2 → Level 3", "Decision Tree")
)

cv_results
##            Scenario         Model       Validation Accuracy Recall Precision
## 1 Level 1 → Level 2 Random Forest Cross-validation    0.910  0.087     0.397
## 2 Level 1 → Level 2 Decision Tree Cross-validation    0.887  0.189     0.272
## 3 Level 2 → Level 3 Random Forest Cross-validation    0.900  0.621     0.514
## 4 Level 2 → Level 3 Decision Tree Cross-validation    0.852  0.889     0.401
##   F1_Score ROC_AUC Avg_Precision
## 1    0.143   0.692         0.218
## 2    0.223   0.700         0.190
## 3    0.562   0.897         0.536
## 4    0.553   0.853         0.346

train_test_split

Then add this chunk for the true held-out test split:

set.seed(123)

run_train_test_models <- function(data, scenario_name) {
  
  # Split into train/test
  train_index <- createDataPartition(
    data$Escalation_Target,
    p = 0.80,
    list = FALSE
  )
  
  train_data <- data[train_index, ]
  test_data  <- data[-train_index, ]
  
  # Remove near-zero variance predictors using training data only
  predictors_train <- train_data %>%
    select(-Escalation_Target)
  
  nzv <- nearZeroVar(predictors_train)
  
  if(length(nzv) > 0) {
    predictors_train <- predictors_train[, -nzv, drop = FALSE]
    predictors_test <- test_data %>%
      select(-Escalation_Target) %>%
      select(names(predictors_train))
  } else {
    predictors_test <- test_data %>%
      select(-Escalation_Target)
  }
  
  train_clean <- bind_cols(
    Escalation_Target = train_data$Escalation_Target,
    predictors_train
  )
  
  test_clean <- bind_cols(
    Escalation_Target = test_data$Escalation_Target,
    predictors_test
  )
  
  # Train Random Forest
  rf_model <- train(
    Escalation_Target ~ .,
    data = train_clean,
    method = "ranger",
    metric = "ROC",
    trControl = ctrl_smote,
    tuneGrid = expand.grid(
      mtry = 3,
      splitrule = "gini",
      min.node.size = 10
    ),
    importance = "impurity",
    num.trees = 200
  )
  
  # Train Decision Tree
  tree_model <- train(
    Escalation_Target ~ .,
    data = train_clean,
    method = "rpart",
    metric = "ROC",
    trControl = ctrl_smote
  )
  
 # Predict on held-out test set
rf_pred <- predict(rf_model, newdata = test_clean)
tree_pred <- predict(tree_model, newdata = test_clean)

rf_prob <- predict(rf_model, newdata = test_clean, type = "prob")
tree_prob <- predict(tree_model, newdata = test_clean, type = "prob")

bind_rows(
  extract_metrics(
    pred = rf_pred,
    prob = rf_prob,
    actual = test_clean$Escalation_Target,
    scenario = scenario_name,
    model_name = "Random Forest",
    validation_type = "Held-out test set"
  ),
  extract_metrics(
    pred = tree_pred,
    prob = tree_prob,
    actual = test_clean$Escalation_Target,
    scenario = scenario_name,
    model_name = "Decision Tree",
    validation_type = "Held-out test set"
  )
)
}

test_results <- bind_rows(
  run_train_test_models(data_12, "Level 1 → Level 2"),
  run_train_test_models(data_23, "Level 2 → Level 3")
)

test_results
##            Scenario         Model        Validation Accuracy Recall Precision
## 1 Level 1 → Level 2 Random Forest Held-out test set    0.912  0.090     0.453
## 2 Level 1 → Level 2 Decision Tree Held-out test set    0.879  0.211     0.255
## 3 Level 2 → Level 3 Random Forest Held-out test set    0.909  0.500     0.556
## 4 Level 2 → Level 3 Decision Tree Held-out test set    0.892  0.933     0.483
##   F1_Score ROC_AUC Avg_Precision
## 1    0.150   0.677         0.205
## 2    0.230   0.684         0.180
## 3    0.526   0.922         0.564
## 4    0.636   0.911         0.463

#tables to compare both tests

Then combine both into one table:

final_validation_results <- bind_rows(
  cv_results,
  test_results
) %>%
  arrange(Scenario, Model, Validation)

final_validation_results
##            Scenario         Model        Validation Accuracy Recall Precision
## 1 Level 1 → Level 2 Decision Tree  Cross-validation    0.887  0.189     0.272
## 2 Level 1 → Level 2 Decision Tree Held-out test set    0.879  0.211     0.255
## 3 Level 1 → Level 2 Random Forest  Cross-validation    0.910  0.087     0.397
## 4 Level 1 → Level 2 Random Forest Held-out test set    0.912  0.090     0.453
## 5 Level 2 → Level 3 Decision Tree  Cross-validation    0.852  0.889     0.401
## 6 Level 2 → Level 3 Decision Tree Held-out test set    0.892  0.933     0.483
## 7 Level 2 → Level 3 Random Forest  Cross-validation    0.900  0.621     0.514
## 8 Level 2 → Level 3 Random Forest Held-out test set    0.909  0.500     0.556
##   F1_Score ROC_AUC Avg_Precision
## 1    0.223   0.700         0.190
## 2    0.230   0.684         0.180
## 3    0.143   0.692         0.218
## 4    0.150   0.677         0.205
## 5    0.553   0.853         0.346
## 6    0.636   0.911         0.463
## 7    0.562   0.897         0.536
## 8    0.526   0.922         0.564