Intro to FFTree Exercise

May 22, 2018

(This article was first published on R-exercises, and kindly contributed to R-bloggers)

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.

Exercise 1

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

Exercise 2

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 .
Exercise 3

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 age <35 predict stable
if thal equals fd or rd predict attack else stable"

Exercise 4

Plot and summarize the new model and check the confusion matrix . Did you improve the result
Exercise 5

Now rather than plotting everything ,Plot just the cues and see how the cues stack up in the FFTree methods

Exercise 6

Plot the same FFTree without the stats,This will show the tree for better understanding and without too much information
Exercise 7

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 .

To leave a comment for the author, please follow the link and comment on their blog: R-exercises. 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...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)