In the exercises below, we will work with FFTree pacakge which lets us use fast and frugal decision tree to model the data
Please install the package and load the library before starting
Answers to these exercises are available here.
If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.
FFTree package comes with heart.train,heart.test data .Check the heart.train data and see the diagnosis column .This is our response variable .
Create a FFTree model using heart.test,heart.train and check the summary of the model
Now FFTree is understood better by plotting it ,uuse the plot function to see the plot and check the probability of heart attack and the probability of stable heart .
Create your own custom tree using simple if else blocks ,this allows us to compare different tree with the default tree .
The custom tree should follow the logic
“if trestbps >180 predict attack
if chol>300 decide hear attack
if thal equals fd or rd predict attack else stable”
Plot and summarize the new model and check the confusion matrix . Did you improve the result
Now rather than plotting everything ,Plot just the cues and see how the cues stack up in the FFTree methods
Plot the same FFTree without the stats,This will show the tree for better understanding and without too much information
You can also print the best training tree to see how its different and how the confusion matrix is different from the tree that is chosen as the default .
Related exercise sets:
R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more…
Source:: R News