Movatterモバイル変換


[0]ホーム

URL:


FFTrees 2.1.0FFTrees

CRAN statusTotal downloads

The R packageFFTrees creates, visualizes andevaluatesfast-and-frugal decision trees (FFTs) for solvingbinary classification tasks, using the algorithms and methods describedin Phillips, Neth, Woike & Gaissmaier (2017,10.1017/S1930297500006239).

What are fast-and-frugaltrees (FFTs)?

Fast-and-frugal trees (FFTs) are simple and transparentdecision algorithms for solving binary classification problems. The keyfeature making FFTs faster and more frugal than other decision trees isthat every node allows making a decision. When predicting novel cases,the performance of FFTs competes with more complex algorithms andmachine learning techniques, such as logistic regression (LR),support-vector machines (SVM), and random forests (RF). Apart from beingfaster and requiring less information, FFTs tend to be robust againstoverfitting, and are easy to interpret, use, and communicate.

Installation

The latest release ofFFTrees is available fromCRAN athttps://CRAN.R-project.org/package=FFTrees:

install.packages("FFTrees")

The current development version can be installed from itsGitHub repository athttps://github.com/ndphillips/FFTrees:

# install.packages("devtools")devtools::install_github("ndphillips/FFTrees",build_vignettes =TRUE)

Getting started

As an example, let’s create a FFT predicting patients’ heart diseasestatus (Healthy vs. Disease) based on theheartdisease dataset included inFFTrees:

library(FFTrees)# load package

Using data

Theheartdisease data provides medical information for303 patients that were examined for heart disease. The full datacontains a binary criterion variable describing the true state of eachpatient and were split into two subsets: Aheart.train setfor fitting decision trees, andheart.test set for atesting these trees. Here are the first rows and columns of both subsetsof theheartdisease data:

diagnosisagesexcptrestbpscholfbsrestecgthalachexangoldpeakslopecathal
FALSE440np1081410normal17500.6flat0normal
FALSE510np1403080hypertrophy14201.5up1normal
FALSE521np1382230normal16900.0up1normal
TRUE481aa1102290normal16801.0down0rd
FALSE591aa1402210normal16410.0up0normal
FALSE581np1052400hypertrophy15410.6flat0rd

Table 1: Beginning of theheart.trainsubset (using the data of 150 patients for fitting/training FFTs).

diagnosisagesexcptrestbpscholfbsrestecgthalachexangoldpeakslopecathal
FALSE510np1202950hypertrophy15700.6up0normal
TRUE451ta1102640normal13201.2flat0rd
TRUE531a1232820normal9512.0flat2rd
TRUE451a1423090hypertrophy14710.0flat3rd
FALSE661a1203020hypertrophy15100.4flat0normal
TRUE481a1302561hypertrophy15010.0up2rd

Table 2: Beginning of theheart.testsubset (used to predictdiagnosis for 153 newpatients).

Our challenge is to predict each patient’sdiagnosis — acolumn of logical values indicating the true state of each patient(i.e.,TRUE or FALSE, based on the patientsuffering or not suffering from heart disease) — from the values ofpotential predictors.

Questions answered by FFTs

To solve binary classification problems by FFTs, we must answer twokey questions:

Once we have created some FFTs, additional questions include:

TheFFTrees package answers these questions bycreating, evaluating, and visualizing FFTs.

Creating fast-and-frugaltrees (FFTs)

We use the mainFFTrees() function to create FFTs fortheheart.train data and evaluate their predictiveperformance on theheart.test data:

# Create an FFTrees object from the heartdisease data:heart_fft<-FFTrees(formula = diagnosis~.,data = heart.train,data.test = heart.test,decision.labels =c("Healthy","Disease"))

EvaluatingFFTrees() analyzes the training data, createsseveral FFTs, and applies them to the test data. The results are storedin an objectheart_fft, which can be printed, plotted andsummarized (with options for selecting specific data or trees).

# Plot the best tree applied to the test data:plot(heart_fft,data ="test",main ="Heart Disease")

Figure 1: A fast-and-frugal tree (FFT) predictingheart disease fortest data and its performancecharacteristics.

Building FFTs fromverbal descriptions

FFTs are so simple that we even can create them ‘from words’ and thenapply them to data.
For example, let’s create a tree with the following three nodes andevaluate its performance on theheart.test data:

  1. Ifsex = 1, predictDisease.
  2. Ifage < 45, predictHealthy.
  3. Ifthal = {fd, normal}, predictHealthy,
    otherwise, predictDisease.

These conditions can directly be supplied to themy.treeargument ofFFTrees():

# Create custom FFT 'in words' and apply it to test data:# 1. Create my own FFT (from verbal description):my_fft<-FFTrees(formula = diagnosis~.,data = heart.train,data.test = heart.test,decision.labels =c("Healthy","Disease"),my.tree ="If sex = 1, predict Disease.                             If age < 45, predict Healthy.                             If thal = {fd, normal}, predict Healthy,                             Otherwise, predict Disease.")# 2. Plot and evaluate my custom FFT (for test data):plot(my_fft,data ="test",main ="My custom FFT")

Figure 2: An FFT predicting heart disease createdfrom a verbal description.

The performance measures (in the bottom panel ofFigure 2) show that this particular tree is somewhatbiased: It has nearly perfectsensitivity (i.e., is good atidentifying cases ofDisease) but suffers from lowspecificity (i.e., performs poorly in identifyingHealthy cases). Expressed in terms of its errors,my_fft incurs few misses at the expense of many falsealarms. Although theaccuracy of our custom tree still exceedsthe data’s baseline by a fair amount, the FFTs inheart_fft(created above) strike a better balance.

Overall, what counts as the “best” tree for a particular problemdepends on many factors (e.g., the goal of fitting vs. predicting dataand the trade-offs between maximizing accuracy vs. incorporating thecosts of cues or errors). To explore this range of options, theFFTrees package enables us to design and evaluate arange of FFTs.

Resources

The following versions ofFFTrees and correspondingresources are available:

Type:Version:URL:
A.FFTrees (Rpackage):Releaseversionhttps://CRAN.R-project.org/package=FFTrees
 Developmentversionhttps://github.com/ndphillips/FFTrees
B. Other resources:Onlinedocumentationhttps://www.nathanieldphillips.co/FFTrees/
 Online demo(running v1.3.3)https://econpsychbasel.shinyapps.io/shinyfftrees/

References

We had fun creating theFFTrees package and hope youlike it too! As a comprehensive, yet accessible introduction to FFTs, werecommend our article in the journalJudgment and DecisionMaking (2017), entitledFFTrees: A toolbox to create, visualize,and evaluate fast-and-frugaldecision trees (available inhtml |PDF ).

Citation (in APA format):

We encourage you to read the article to learn more about the historyof FFTs and how theFFTrees package creates,visualizes, and evaluates them. When usingFFTrees inyour own work, please cite us and share your experiences (e.g.,on GitHub) so wecan continue developing the package.

By 2025, over 150 scientific publications have used or citedFFTrees (seeGoogleScholar for the full list). Examples include:


[FileREADME.Rmd last updated on 2025-09-03.]


[8]ページ先頭

©2009-2025 Movatter.jp