Hostname: page-component-77f85d65b8-v2srd Total loading time: 0 Render date: 2026-04-21T12:16:46.819Z Has data issue: false hasContentIssue false

FFTrees: A toolbox to create, visualize, and evaluate fast-and-frugal decision trees

Published online by Cambridge University Press:  01 January 2023

Nathaniel D. Phillips*
Affiliation:
Department of Economic Psychology, Basel, Switzerland
Hansjörg Neth
Affiliation:
Department of Social Psychology and Decision Sciences, University of Konstanz, Konstanz, Germany
Jan K. Woike
Affiliation:
Center for Adaptive Rationality, Max Planck Institute for Human Development, Berlin, Germany DIW Berlin, Germany
Wolfgang Gaissmaier
Affiliation:
Department of Social Psychology and Decision Sciences, University of Konstanz, Konstanz, Germany
Rights & Permissions [Opens in a new window]

Abstract

Fast-and-frugal trees (FFTs) are simple algorithms that facilitate efficient and accurate decisions based on limited information. But despite their successful use in many applied domains, there is no widely available toolbox that allows anyone to easily create, visualize, and evaluate FFTs. We fill this gap by introducing the R package FFTrees. In this paper, we explain how FFTs work, introduce a new class of algorithms called fan for constructing FFTs, and provide a tutorial for using the FFTrees package. We then conduct a simulation across ten real-world datasets to test how well FFTs created by FFTrees can predict data. Simulation results show that FFTs created by FFTrees can predict data as well as popular classification algorithms such as regression and random forests, while remaining simple enough for anyone to understand and use.

Information

Type
Research Article
Creative Commons
Creative Common License - CCCreative Common License - BY
The authors license this article under the terms of the Creative Commons Attribution 3.0 License.
Copyright
Copyright © The Authors [2017] This is an Open Access article, distributed under the terms of the Creative Commons Attribution license (http://creativecommons.org/licenses/by/3.0/), which permits unrestricted re-use, distribution, and reproduction in any medium, provided the original work is properly cited.
Figure 0

Figure 1: The structure of a binary classification task. The data underlying the task are arranged as a combination of cases (e.g., patients) and each case’s values on several cues (e.g., age, sex, and various medical tests indicated by the labels trestbps, thal, slope, cp, and ca). Classification accuracy is evaluated by comparing the algorithm’s decisions to the true criterion values. The goal of the algorithm is to maximize correct decisions (hits and correct rejections), while minimizing errors (misses and false-alarms).

Figure 1

Figure 2: A fast-and-frugal tree (FFT) for classifying patients as either low or high-risk for heart disease based on up to three cues. Each cue is contained in a node, represented as rectangles. Decisions are made in leafs, represented as circles. Branches represent answers to questions to cue–based questions. Branches connecting nodes to leafs are called exit branches. One can use this tree to make a decision as follows: If a patient’s thal (thallium scintigraphy result) value is rd (reversible defect) or fd (fixed defect), classify her as high-risk. If not, check her cp (chest pain type) value. If this is aa (atypical angina), np (non-anginal pain), or ta (typical angina), classify her low-risk. If not, check her ca (number of major vessels colored by flourosopy) value. If this is positive, classify her as high-risk, otherwise classify her as low-risk. Note: After creating the heart.fft object in the tutorial section “Using the FFTrees package”, this plot can be generated by running plot(heart.fft, stats = FALSE, decision.labels = c("Low-Risk", "High-Risk").

Figure 2

Figure 3: A 2 x 2 confusion table and accuracy statistics used to evaluate a decision algorithm. Rows refer to the frequencies of algorithm decisions (predictions) and columns refer to the frequencies of criterion values (the truth). Cells hi and cr refer to correct decisions, whereas cells fa and mi refer to errors of different types. Five measures of decision accuracy are defined in terms of cell frequencies.

Figure 3

Figure 4: A receiver operating characteristic (ROC) curve illustrating the trade-off between sensitivity (sens) and specificity (spec) in classification algorithms. As sensitivity increases, specificity decreases (i.e., 1 − spec increases). Balanced accuracy (bacc) is the average of sensitivity and specificity. Ideal performance (bacc = 1.0), is represented by the cross in the upper-left corner. The numbered circles in the plot represent the accuracy of 7 different algorithms with different trade-offs between sensitivity and specificity. Their numbers represent the rank order of algorithm performance in terms of their bacc values. (Note: The circles correspond to the fan of 7 FFTs that will be created by the ifan algorithm for the heart disease dataset in the tutorial.)

Figure 4

Figure 5: Complete, reproducible code showing four basic steps to create, visualize, and evaluate FFTs predicting heart disease with FFTrees. The datasets used for training (heart.train) and testing (heart.test) are included in FFTrees and an expanded tutorial for this code is available in the package by evaluating vignette("FFTrees_heart"). A link to a video tutorial corresponding to this code is also available at https://osf.io/m726x/ (Phillips et al., 2017a).

Figure 5

Table 1: Printing an FFTrees object provides summary statistics on the created FFTs, selects the FFT with the highest weighted accuracy (wacc) in training and shows its performance measures for training and testing data.

Figure 6

Figure 6: Visualization of an FFTrees object created by plot(heart.fft, data = "test"). The top panel shows information about the dataset, including the frequencies and base rates of negative and positive criterion classes. The middle panel contains the FFT and icon arrays showing the the number and accuracy of cases classified at each node. This particular FFT’s interpretation has been described above (on p. 346 and in Figure 2). The bottom panel shows the FFT’s cumulative classification performance, including a confusion table and levels for a range of statistics. The bottom right plot shows the performance of all seven FFTs created by the FFTrees() function in ROC space (green circles with numbers correspond to FFTs). The FFT currently being plotted is highlighted (here, FFT #1, with the highest weighted accuracy in training). Additional points in this plot correspond to the performance of competing classification algorithms (see Simulation section): standard decision trees (CART), logistic regression (LR), random forests (RF), and support vector machines (SVM). In this case, FFT #1 has a higher sensitivity than competing algorithms, but at the cost of a lower specificity. Additionally, FFT #1 dominates CART in this example by having a higher sensitivity and comparable specificity.

Figure 7

Figure 7: Visualizing marginal (training) cue accuracies from the heart.fft object by running plot(heart.fft, what = ‘‘cues’’, data = ‘‘train’’). Accuracy statistics are calculated for each cue using the threshold that maximizes bacc. Numbers indicate a cue’s ranked accuracy across all cues in terms of bacc. The top five cues are colored and described in the legend. All other cues in the data are shown as black points.

Figure 8

Figure 8: Network plot of relationships between cues in the heart disease data created by plotting an FFForest object. The object represents a bootstrap simulation of 100 FFTs trained on different random subsets of the heart disease data. The size of a node reflects how often it occurs across different FFTs in the forest (i.e., its importance), while the weight of the connection between two nodes reflects how often they co-occur within individual FFTs.

Figure 9

Table 2: Dataset descriptions, FFT efficiency, and prediction accuracy measured in balanced accuracy (bacc) in the prediction simulations. All FFTs were constructed using the ifan algorithm. The efficiency measures apply only to FFTs.

Figure 10

Figure 9: Comparisons of the four different fast-and-frugal tree construction algorithms collapsed across all simulations and datasets. For the left panel (speed, measured by mean cues used, mcu), lower values are better. For the middle and right panels (measuring frugality by percent cues ignored, pci, and balanced accuracy, bacc) higher values are better. Horizontal lines in distributions represent means. Plots were created using the yarrr package (Phillips, 2016).

Figure 11

Figure 10: Distributions of prediction performance, measured as balanced accuracy (bacc) in testing across datasets. FFT results are for FFTs built with the ifan construction algorithm. The SVM results do not include data for the arrhythmia or audiology datasets due to repeated crashing. Wide horizontal lines represent means and vertical lines represent the 25th and 75th percentiles. Credible intervals for means are not shown because they are virtually identical to the sample means. Distributions for individual datasets are presented in Figure 11.

Figure 12

Figure 11: Distributions of prediction balanced accuracy (bacc) for each model and dataset in the prediction simulation. Horizontal lines within plots represent means. FFT results are for FFTs built with the ifan construction algorithm. The support vector machines (SVM) algorithm could not make predictions in the arrhythmia and audiology datasets due to repeated crashes. Next to each simulation is a 100% training FFT produced by the ifan algorithm applied to the full dataset.

Figure 13

Figure 12: An FFT to decide whether to consider an FFT or use an alternative algorithm for classifying cases for a decision task. The list of cues in this FFT are meant to be illustrative and not exhaustive.