Decision Trees (party) on Political Outcome Based on State-level Big Five Assessment

This decision tree demo is similar to a prior one I've done, but in this case it uses the party package, that produces much higher quality graphics than rpart, at least when used with plot.. This was done as part of a Pluralsight training presentation, Data Mining Algorithms in SSAS, Excel, and R.

Source data is here.

   
 #   
 # Load Data  
 #  
   
 # Set working directory  
 setwd("../Data")  
 getwd()  
   
 # read from data frame  
 BigFivByState.df <- read.table("BigFiveScoresByState.csv", header = TRUE, sep = ",")  
   
 #   
 # Run Analysis  
 #  
   
 # Load package,   
 install.packages('party', dependencies = TRUE)  
 library(party)  
   
 # train the model  
 BigFivByState.dt <- ctree(data = BigFivByState.df, Liberal ~ Openness + Conscientiousness + Extraversion + Neuroticism + Agreeableness)  
   
 # plot result  
 plot(BigFivByState.dt, uniform = TRUE, main = "Classification Tree for Politics on Big Five")  

Popular posts from this blog

Charting Correlation Matrices in R

Neural Networks (Part 4 of 4) - R Packages and Resources

Performance Improvements in R: Vectorization & Memoisation