# FFTrees v1.4.0

Monthly downloads

## Generate, Visualise, and Evaluate Fast-and-Frugal Decision Trees

Create, visualize, and test fast-and-frugal decision trees (FFTs). FFTs are very simple decision trees for
binary classification problems. FFTs can be preferable to more complex algorithms because they are easy to communicate, require very little information, and are
robust against overfitting.

## Readme

# FFTrees

FFTrees is an R package to create and visualize fast-and-frugal decision trees (FFTs) like the one below that predicts heart disease.

Additional information about FFTs, and the FFTrees package can be found at Phillips, Neth, Woike & Gaissmaier, 2017. For seminal papers on FFTs, consult Martignon, Katsikopoulos & Woike, 2008 and Martignon, Vitouch, Takezawa & Forster, 2003

```
# Install FFTrees from CRAN
install.packages("FFTrees")
# Load package
library(FFTrees)
# Create an FFTrees object from the heartdisease data
heart.fft <- FFTrees(formula = diagnosis ~.,
data = heart.train,
data.test = heart.test)
# Plot the best tree applied to the test data
plot(heart.fft,
data = "test",
main = "Heart Disease",
decision.labels = c("Healthy", "Disease"))
```

### Package updates

1.4.0

- Big under the hood changes to make code more efficient (and prepare for c++). Code should be ~50% faster.
- Many inputs such as
`cost.cues`

and`cost.outcomes`

are now specified as named lists to avoid confusion. - New cost outputs separate costs from cues, outcomes, and total costs.
- Changes to input defaults for
`goal`

and`goal.chase`

.

1.3.6

- Bug fixes.

1.3.5

- Bug fixes.

1.3.4

Added class probability predictions with

`predict.FFTrees(type = "prob")`

Updated

`print.FFTrees()`

to display FFT #1 'in words' (from the`inwords(x)`

function)

1.3.3

Added

`show.X`

arguments to`plot.FFTrees()`

that allow you to selectively turn on or turn off elements when plotting an`FFTrees`

object.Added

`label.tree`

,`label.performance`

arguments to`plot.FFTrees()`

that allow you to specify plot (sub) labels.Bug fixes

- Issues when passing an existing FFTrees object to a new call to FFTrees().

1.3.0

Many additional vignettes (e.g.; Accuracy Statistics and Heart Disease Tutorial) and updates to existing vignettes.

Added

`cost.outcomes`

and`cost.cues`

to allow the user to specify specify the cost of outcomes and cues. Also added a new`cost`

statistic throughout outputs.Added

`inwords()`

, a function that converts an FFTrees object to words.Added

`my.tree`

argument to`FFTrees()`

that allows the user to specify an FFT verbally. E.g.,`my.tree = 'If age > 30, predict True. If sex = {m}, predict False. Otherwise, predict True'`

.Added positive predictive value

`ppv`

, negative predictive value`npv`

and balanced predictive value`bpv`

as primary accuracy statistics throughout.Added support for two FFT construction algorithms from Martignon et al. (2008):

`"zigzag"`

and`"max"`

. The algorithms are contained in the file`heuristic_algorithm.R`

and can be implemented in`FFTrees()`

as arguments to`algorithm`

.

1.2.3

Added

`sens.w`

argument to allow differential weighting of sensitivities and specificities when selecting and applying trees.Fixed bug in calculating importance weightings from

`FFForest()`

outputs.

1.2.0

Changed wording of statistics throughout package.

`hr`

(hit rate) and`far`

(false alarm rate) are now`sens`

for sensitivity, and`spec`

for specificity (1 - false alarm rate)The

`rank.method`

argument is now depricated. Use`algorithm`

instead.Added

`stats`

argument to`plot.FFTrees()`

. When`stats = FALSE`

, only the tree will be plotted without reference to any statistical output.Grouped all competitive algorithm results (regression, cart, random forests, support vector machines) to the new

`x.fft$comp`

slot rather than a separate first level list for each algorithm. Also replaced separate algorithm wrappers with one general`comp.pred()`

wrapper function.Added

`FFForest()`

, a function for creating forests of ffts, and`plot.FFForest()`

, for visualizing forests of ffts. This function is very much still in development.Added random forests and support vector machines for comparison in

`FFTrees()`

using the`randomForest`

and`e1071`

packages.Changed logistic regression algorithm from the default

`glm()`

version to`glmnet()`

for a regularized version.`predict.FFTrees()`

now returns a vector of predictions for a specific tree rather than creating an entirely new FFTrees object.You can now plot cue accuracies within the

`plot.FFTrees()`

function by including the`plot.FFTrees(what = 'cues')`

argument. This replaces the former`showcues()`

function.Many cosmetic changes to

`plot.FFTrees()`

(e.g.; gray levels, more distinct classification balls). You can also control whether the results from competing algorithms are displayed or not with the`comp`

argument.Bug-fixes

- Fixed a bug where levels with no classifications are not plotted correctly.

1.1.7

Trees can now use the same cue multiple times within a tree. To do this, set

`rank.method = "c"`

and`repeat.cues = TRUE`

.Bug-fixes

- You can (and should!) now have a column of NAs for the criterion in test datasets to represent data where the criterion is unknown.
`FFTrees()`

now supports a single predictor (e.g.;`formula = diagnosis ~ age`

) which previously did not work.

1.1.6

- Streamlined code to improve cohesion between functions. This may cause issues with FFTrees objects created with earlier versions of the package. They will need to be re-created.
- Updated, clearer
`print.FFTrees()`

method to see important info about an FFTrees object in matrix format. Training and testing statistics are now always in seperate objects (e.g.;

`data$train`

,`data$test`

) to avoid confusion.Bug-fixes

`predict.FFTrees()`

now works much better by passing a new dataset (`data.test`

) as a test dataset for an existing FFTrees object.

1.1.5

- Bug-fixes
- Plotting parameters
`mar`

and`layout`

are now reset after running`plot.FFTrees()`

- Plotting parameters

1.1.4

Bug-fixes

- Plotting no longer fails when there is only one branch in the tree.
- Changed
`which.tree`

argument in`plot.FFTrees()`

to`tree`

to conform to blog posts. `predict.FFTrees()`

now works better with`tibble`

inputs.

Changed the

`fft`

label to`FFTrees`

throughout the package to avoid confusion with fast fourier transform. Thus, the main tree building function is now`FFTrees()`

and the new tree object class is`FFTrees`

## Functions in FFTrees

Name | Description | |

FFForest | Creates a forest of fast and frugal decision trees | |

sonar | Sonar data set | |

classtable | Calculates several classification statistics from binary prediction and criterion (e.g.; truth) vectors | |

comp.pred | Wrapper for classfication algorithms | |

FFTrees | Creates a fast-and-frugal trees (FFTrees) object. | |

FFTrees.guide | Opens the FFTrees package guide | |

cuerank | Calculates thresholds that maximize a statistic (goal) for cues. | |

factclean | Does miscellaneous cleaning of prediction datasets | |

breastcancer | Dataset: Physiological dataset for 699 patients tested for breast cancer. | |

fan.algorithm | Grows fast-and-frugal trees using the fan algorithm | |

car | Car acceptability data | |

heart.cost | Cue costs for the heartdisease dataa | |

heartdisease | Heart disease dataset | |

forestfires | forestfires | |

heuristic.algorithm | Heuristic algorithms for building FFTs originally developed by Martignon, Katsikopoulos & Woike (2008) | |

heart.fff | An FFForest object trained on the heartdisease dataset. | |

threshold_factor_grid | Performs a grid search over factor and returns accuracy statistics for a given factor cue | |

grow.FFTrees | Grows fast-and-frugal trees using an algorithm specified by algorithm. | |

mushrooms | Mushrooms dataset | |

plot.FFForest | Creates a network plot. Code taken from Dirk Wulff (www.dirkwulff.org) | |

summary.FFTrees | Returns summary information about an FFTrees object | |

print.FFTrees | Prints summary information from an FFTrees object | |

fertility | Fertility data set | |

threshold_numeric_grid | Performs a grid search over thresholds and returns accuracy statistics for a given numeric cue | |

voting | Voting data set | |

showcues | Visualizes cue accuracies from an FFTrees object in a ROC space | |

inwords | Describes an FFT in words | |

apply.tree | Applies a fast-and-frugal tree to a dataset and generates several accuracy statistics | |

wine | Wine tasting dataset | |

blood | Blood donation dataset | |

contraceptive | Contraceptive use data | |

predict.FFTrees | Predict classifications from newdata using an FFTrees object | |

iris.v | Iris data set | |

creditapproval | Credit approval data | |

plot.FFTrees | Plots an FFTrees object. | |

print.FFForest | Prints summary information from an FFForest x | |

wordstoFFT | Converts text describing an FFT into an FFT definition. | |

predict.FFForest | Predict outcoms from a test dataset using an FFForest object | |

titanic | Titanic dataset | |

updateHistory | Update the history of decisions from trees in an FFTrees object | |

Add_Stats | Adds decision statistics to a dataframe containing hr, cr, mi and fa | |

heart.test | Heartdisease testing dataset | |

heart.train | Heartdisease training dataset. | |

No Results! |

## Vignettes of FFTrees

Name | ||

AccuracyStatistics.Rmd | ||

FFTrees_algorithm.Rmd | ||

FFTrees_examples.Rmd | ||

FFTrees_function.Rmd | ||

FFTrees_heart.Rmd | ||

FFTrees_mytree.Rmd | ||

FFTrees_plot.Rmd | ||

apa.csl | ||

fft.bib | ||

guide.Rmd | ||

No Results! |

## Last month downloads

## Details

Type | Package |

Date | 2018-08-18 |

LazyData | TRUE |

License | CC0 |

BugReports | https://github.com/ndphillips/FFTrees/issues |

RoxygenNote | 6.0.1 |

VignetteBuilder | knitr |

NeedsCompilation | no |

Packaged | 2018-09-14 22:59:14 UTC; phillin7 |

Repository | CRAN |

Date/Publication | 2018-09-15 07:20:09 UTC |

imports | caret , circlize , e1071 , graphics , igraph , parallel , pROC , progress , randomForest , rpart , stringr , yarrr |

suggests | knitr , rmarkdown |

depends | R (>= 2.10) |

Contributors | Hansjoerg Neth, Jan Woike, Wolfgang Gaissmaer |

#### Include our badge in your README

```
[![Rdoc](http://www.rdocumentation.org/badges/version/FFTrees)](http://www.rdocumentation.org/packages/FFTrees)
```