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  
 # read from data frame  
 BigFivByState.df <- read.table("BigFiveScoresByState.csv", header = TRUE, sep = ",")  
 # Run Analysis  
 # Load package,   
 install.packages('party', dependencies = TRUE)  
 # 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 in R (Part 2 of 4) - caret and nnet on State 'Personality' and Political Outcomes

Neural Networks in R (Part 1 of 4) - Logistic Regression and neuralnet on State 'Personality' and Political Outcomes