Skip to content

Commit

Permalink
Merge pull request #125 from hneth/master
Browse files Browse the repository at this point in the history
Prepare for CRAN release
  • Loading branch information
hneth authored Jan 5, 2023
2 parents 257fd12 + 32601fe commit 4bc0670
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## 1.8.0

**FFTrees** version 1.8.0 is to be released [on CRAN](https://CRAN.R-project.org/package=FFTrees) [on 2023-01-06].
**FFTrees** version 1.8.0 was released [on CRAN](https://CRAN.R-project.org/package=FFTrees) [on 2023-01-06].
This version mostly extends and improves existing functionality.

<!-- Log of changes: -->
Expand Down Expand Up @@ -359,6 +359,6 @@ Thus, the main tree building function is now `FFTrees()` and the new tree object

------

[File `NEWS.md` last updated on 2023-01-04.]
[File `NEWS.md` last updated on 2023-01-06.]

<!-- eof. -->
4 changes: 3 additions & 1 deletion R/fftrees_cuerank.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ fftrees_cuerank <- function(x = NULL,

if (!x$params$quiet) {

pb <- progress::progress_bar$new(total = cue_n, clear = FALSE, show_after = .500)
pb <- progress::progress_bar$new(format = u_f_msg("[:bar] :percent"),
width = 70,
total = cue_n, clear = FALSE, show_after = .200)

# cli::cli_progress_bar("Ranking cues", total = cue_n)

Expand Down
2 changes: 2 additions & 0 deletions R/helper_col.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ in_red <- cli::make_ansi_style("firebrick3", colors = 256) # "red4" "darkred
in_green <- cli::make_ansi_style("forestgreen", colors = 256) # "green4" "darkgreen"
in_blue <- cli::make_ansi_style("dodgerblue4", colors = 256) # "steelblue4" "darkblue"

in_dpnk <- cli::make_ansi_style("deeppink", colors = 256)
in_dsbl <- cli::make_ansi_style("deepskyblue", colors = 256)

# User feedback messages:

Expand Down
18 changes: 9 additions & 9 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Final steps:

# Feedback message (on console):
# .onAttach (from R base): Feedback message (on console) ------

.onAttach <- function(libname, pkgname) {

version_nr <- utils::packageVersion("FFTrees")

packageStartupMessage(" ")
packageStartupMessage(" O ")
packageStartupMessage(" / \\ ")
packageStartupMessage(" F O ")
packageStartupMessage(" / \\ ")
packageStartupMessage(" F Trees ")
packageStartupMessage(" ")
packageStartupMessage(in_grey(" "))
packageStartupMessage(in_grey(" O "))
packageStartupMessage(in_grey(" / \\ "))
packageStartupMessage(in_grey(" F O "))
packageStartupMessage(in_grey(" / \\ "))
packageStartupMessage(in_grey(" F Trees "))
packageStartupMessage(in_grey(" "))
packageStartupMessage(in_grey("Welcome to ", in_blue(paste("FFTrees ", version_nr, sep = "")), "!", sep = ""))
packageStartupMessage(in_lightgrey(paste(in_darkgrey("FFTrees.guide()"), "opens the main guide."), sep = ""))
packageStartupMessage(in_grey(paste(in_darkgrey("FFTrees.guide()"), "opens the main guide."), sep = ""))

} # .onAttach().

Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
output: github_document
---


<!-- README.md is generated from README.Rmd. Please only edit the .Rmd file! -->

```{r setup, include = FALSE}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,6 @@ for the full list):

------------------------------------------------------------------------

\[File `README.Rmd` last updated on 2023-01-04.\]
\[File `README.Rmd` last updated on 2023-01-06.\]

<!-- eof. -->
22 changes: 17 additions & 5 deletions vignettes/FFTrees_examples.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ library(FFTrees)
```



## Examples of FFTs with **FFTrees**

This vignette illustrates how to construct fast-and-frugal trees (FFTs) for additional datasets included in the **FFTrees** package.
[See @phillips2017FFTrees for a comparison across 10\ real-world datasets.]


### Mushrooms data

```{r image-mushrooms, fig.align = "center", out.width = "225px", echo = FALSE}
Expand All @@ -58,6 +60,7 @@ knitr::kable(head(mushrooms_sub))

Table: **Table 1**: Binary criterion variable\ `poisonous` and 10\ potential predictors in the `mushrooms` data.


#### Creating FFTs

Let's create some trees using `FFTrees()`!
Expand All @@ -81,7 +84,8 @@ Here's basic information about the best performing FFT (Tree\ #1):
mushrooms.fft
```

[Cool beans.](https://goo.gl/B7YDuC)
[Cool beans](https://goo.gl/B7YDuC).


#### Visualizing cue accuracies

Expand All @@ -96,22 +100,26 @@ It looks like the cues `oder` and `sporepc` are the best predictors.
In fact, the single cue `odor` has a hit rate of\ $97$% and a false alarm rate of nearly\ $0$%!
Based on this, we should expect the final trees to use just these cues.


#### Visualizing FFT performance

Now let's plot the performance of the best training tree when applied to the test dataset:
Now let's plot the performance of the best training tree when applied to the test data:

```{r fft-mushrooms-1-plot}
# Plot the best FFT for the mushrooms test data:
plot(mushrooms.fft, data = "test")
```

Indeed, it looks like the best tree only uses the\ `odor` and\ `sporepc` cues.
In our test dataset, the tree had a _false alarm rate_ of\ $0$% ($1 -$\ specificity), and a _sensitivity_ (aka. hit rate) of\ $85$%.
In our test dataset, the tree had a _false alarm rate_ of\ $0$% ($1 -$\ specificity), and a _sensitivity_ (aka. hit rate) of\ $85$%.
When considering the implications of our decisions, the fact that our FFT incurs many misses, but no false alarms, is problematic (as failing to detect poisonous mushrooms typically has more serious consequences than falsely classifying some as poisonous).
To change this balance, we could increase the sensitivity weight parameter (e.g., setting `sens.w = .67`) and optimize the tree's weighted accuracy\ `wacc`.


#### An alternative FFT

Now, let's say that we talk to a mushroom expert who says that we are using the wrong cues.
According to her, the best predictors for poisonous mushrooms are `ringtype` and `ringnum`.
But let's assume that a mushroom expert insists that we are using the wrong cues.
According to her, the best predictors for poisonous mushrooms are\ `ringtype` and\ `ringnum`.
Let's build a set of trees with these cues and see how they perform relative to our initial tree:

```{r fft-mushrooms-2-seed, include = FALSE}
Expand Down Expand Up @@ -141,6 +149,7 @@ As we can see, this tree (in `mushrooms.ring.fft`) has both a sensitivity and a
This suggests that we should discard the expert's advice and primarily rely on the\ `odor` and\ `sporepc` cues.



### Iris.v data

```{r iris-image, fig.align = "center", out.width = "225px", echo = FALSE}
Expand All @@ -167,6 +176,7 @@ iris.fft

However, let's take a look at the individual training cue accuracies instead...


#### Visualizing cue accuracies

We can plot the training cue accuracies during training by specifying `what = "cues"`:
Expand All @@ -179,6 +189,7 @@ plot(iris.fft, what = "cues")
It looks like the two cues\ `pet.wid` and\ `pet.len` are the best predictors for this dataset.
Based on this, we should expect the final trees will likely use one or both of these cues.


#### Visualizing FFT performance

Now let's examine the best tree:
Expand All @@ -191,6 +202,7 @@ plot(iris.fft)
Indeed, it turns out that the best tree only uses the\ `pet.wid` and\ `pet.len` cues.
In our test data, the tree had a sensitivity of\ 100% and a specificity of\ 94%.


#### Alternative FFTs

Now, this tree did quite well, but what if someone wanted a tree with the lowest possible false alarm rate?
Expand Down

0 comments on commit 4bc0670

Please sign in to comment.