Background

Given a dataset of some 7,000 registered voters, along with over 250 other variables, a classification tree was developed.

The tree was developed using only registered Democrats and Republicans, trained and validated using a 70/30 split.

Then the remaining voters were scored using the model. Now the party, (choose your favorite), has a prediction as to who leans one way or another. This will be used for local elections purposes.

Task

Develop the next steps for your party. How should they use the predicted leanings of the unafiliated residents. in other words, develop their call to action!.

Analysis Results

##     Democrat        Green  Independent  Libertarian        Other   Republican 
##         2791            5           82            9            9         1211 
## Unaffiliated 
##         2940

## [1] "Variable Importance:"
##                              CT_inflationbiden 
##                                     934.045112 
##                          CT_trumpsupportpolicy 
##                                     853.417048 
##                          CT_ideologyfiscalcons 
##                                     850.283127 
##                      2024_CTGOP_inflationbiden 
##                                     722.897354 
##                         2020_DJTOverperformers 
##                                     691.977403 
##           2024_CTGOP_connecticutwrongdirection 
##                                     658.290565 
##                                 CT_trumpoppose 
##                                      54.087008 
##           2024_CTGOP_connecticutrightdirection 
##                                      35.423181 
##                      2024_CTGOP_inflationcombo 
##                                      31.423790 
##                                       VoterKey 
##                                      29.900212 
##           2020_RNCUniv_Generic_GOP_In_The_Bank 
##                                      14.981631 
##                   2020_RNCUniv_GOP_In_The_Bank 
##                                      13.108927 
##                    2019_RNCUnivs_GOP_InTheBank 
##                                      10.299871 
##                           Uni14_10_GOPBase_ITB 
##                                       9.363520 
##                                CT_Non - Target 
##                                       8.379677 
##                              GeneralRegularity 
##                                       7.808336 
##                        2016_RNCUnivs_InTheBank 
##                                       7.490816 
##                                        CT_GOTV 
##                                       7.357580 
## 2024_CTGOP_GenericBallot_Low_TurnoutHardGOP_11 
##                                       6.306497 
##          2024_CTGOP_energyaffordabilityworried 
##                                       3.153248

## [1] "Confusion Matrix and Statistics:"
## Confusion Matrix and Statistics
## 
##             Reference
## Prediction   Democrat Republican
##   Democrat        824         21
##   Republican       13        342
##                                           
##                Accuracy : 0.9717          
##                  95% CI : (0.9606, 0.9803)
##     No Information Rate : 0.6975          
##     P-Value [Acc > NIR] : <2e-16          
##                                           
##                   Kappa : 0.9324          
##                                           
##  Mcnemar's Test P-Value : 0.2299          
##                                           
##             Sensitivity : 0.9845          
##             Specificity : 0.9421          
##          Pos Pred Value : 0.9751          
##          Neg Pred Value : 0.9634          
##              Prevalence : 0.6975          
##          Detection Rate : 0.6867          
##    Detection Prevalence : 0.7042          
##       Balanced Accuracy : 0.9633          
##                                           
##        'Positive' Class : Democrat        
## 
## Accuracy: 0.9716667
## quartz_off_screen 
##                 2
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  1200 
## 
##  
##                               | predictions 
## validation_data$OfficialParty |   Democrat | Republican |  Row Total | 
## ------------------------------|------------|------------|------------|
##                      Democrat |        824 |         13 |        837 | 
##                               |     93.390 |    222.295 |            | 
##                               |      0.984 |      0.016 |      0.698 | 
##                               |      0.975 |      0.037 |            | 
##                               |      0.687 |      0.011 |            | 
## ------------------------------|------------|------------|------------|
##                    Republican |         21 |        342 |        363 | 
##                               |    215.338 |    512.565 |            | 
##                               |      0.058 |      0.942 |      0.302 | 
##                               |      0.025 |      0.963 |            | 
##                               |      0.018 |      0.285 |            | 
## ------------------------------|------------|------------|------------|
##                  Column Total |        845 |        355 |       1200 | 
##                               |      0.704 |      0.296 |            | 
## ------------------------------|------------|------------|------------|
## 
## 

Scoring the unafiliated

## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  3045 
## 
##  
##                                               | pre_model_data_only_non_rep_dem$OfficialParty_Predicted 
## pre_model_data_only_non_rep_dem$OfficialParty |   Democrat | Republican |  Row Total | 
## ----------------------------------------------|------------|------------|------------|
##                                         Green |          3 |          2 |          5 | 
##                                               |      0.213 |      0.181 |            | 
##                                               |      0.600 |      0.400 |      0.002 | 
##                                               |      0.002 |      0.001 |            | 
##                                               |      0.001 |      0.001 |            | 
## ----------------------------------------------|------------|------------|------------|
##                                   Independent |         46 |         36 |         82 | 
##                                               |      1.814 |      1.546 |            | 
##                                               |      0.561 |      0.439 |      0.027 | 
##                                               |      0.033 |      0.022 |            | 
##                                               |      0.015 |      0.012 |            | 
## ----------------------------------------------|------------|------------|------------|
##                                   Libertarian |          4 |          5 |          9 | 
##                                               |      0.005 |      0.004 |            | 
##                                               |      0.444 |      0.556 |      0.003 | 
##                                               |      0.003 |      0.003 |            | 
##                                               |      0.001 |      0.002 |            | 
## ----------------------------------------------|------------|------------|------------|
##                                         Other |          7 |          2 |          9 | 
##                                               |      1.974 |      1.682 |            | 
##                                               |      0.778 |      0.222 |      0.003 | 
##                                               |      0.005 |      0.001 |            | 
##                                               |      0.002 |      0.001 |            | 
## ----------------------------------------------|------------|------------|------------|
##                                  Unaffiliated |       1341 |       1599 |       2940 | 
##                                               |      0.101 |      0.086 |            | 
##                                               |      0.456 |      0.544 |      0.966 | 
##                                               |      0.957 |      0.973 |            | 
##                                               |      0.440 |      0.525 |            | 
## ----------------------------------------------|------------|------------|------------|
##                                  Column Total |       1401 |       1644 |       3045 | 
##                                               |      0.460 |      0.540 |            | 
## ----------------------------------------------|------------|------------|------------|
## 
##