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. Although the idea for this analysis is mine, this was done as part of work for 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")  

Comments

Popular posts from this blog

Charting Correlation Matrices in R

Developers in New York City by Zip Code

Cultural Dimensions and Coffee Consumption