# Intro to FFTree Exercise

**R-exercises**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 .

**leave a comment**for the author, please follow the link and comment on their blog:

**R-exercises**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.