Skip to content

Commit

Permalink
Merge pull request #214 from hneth/master
Browse files Browse the repository at this point in the history
Add a truth.labels argument to plotFFTrees_function()
  • Loading branch information
hneth committed May 8, 2024
2 parents edb4144 + a50411c commit 9c2adc9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# FFTrees (development version)

- `plot.FFTrees()` now has a `grayscale` argument which, if TRUE, creates a grayscale plot
- `plot.FFTrees()` now has a `truth.labels` argument which, if set, distinguishes labels of true (signal vs. noise) cases from decision outcomes.
- `plot.FFTrees()` now has a `grayscale` argument which, if TRUE, creates a grayscale plot.
- Added support for handling NA values.
- Increased value of `cost_cues_default` from 0 to 1, so that default cue costs correspond to `mcu`.
- Added `@aliases FFTrees-package` to documentation of main `FFTrees()` function.
- Removed redundant `data_old` folder.


## 2.0.0

**FFTrees** version 2.0.0 was released [on CRAN](https://CRAN.R-project.org/package=FFTrees) [on 2023-06-06].
Expand Down Expand Up @@ -480,6 +482,6 @@ Thus, the main tree building function is now `FFTrees()` and the new tree object

------

[File `NEWS.md` last updated on 2023-09-05.]
[File `NEWS.md` last updated on 2024-05-08.]

<!-- eof. -->
31 changes: 22 additions & 9 deletions R/plotFFTrees_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
#' @param main The main plot label (as a character string).
#'
#' @param cue.labels An optional string of labels for the cues / nodes (as character vector).
#' @param decision.labels A character vector of length 2 indicating the content-specific names for noise and signal predictions/exits.
#' @param decision.labels A character vector of length 2 indicating the content-specific names for noise vs. signal predictions/exits.
#' @param truth.labels A character vector of length 2 indicating the content-specific names for true noise vs. signal cases
#' (using `decision.labels` if unspecified).
#' @param cue.cex The size of the cue labels (as numeric).
#' @param threshold.cex The size of the threshold labels (as numeric).
#' @param decision.cex The size of the decision labels (as numeric).
Expand Down Expand Up @@ -117,8 +119,9 @@
#' plot(heart_fft, tree = 2, data = heart.test,
#' main = "Predicting heart disease",
#' cue.labels = c("1. thal?", "2. cp?", "3. ca?", "4. exang"),
#' decision.labels = c("ok", "sick"), n.per.icon = 2,
#' show.header = TRUE, show.confusion = FALSE, show.levels = FALSE, show.roc = FALSE,
#' decision.labels = c("ok", "treat"), truth.labels = c("Healthy", "Sick"),
#' n.per.icon = 2,
#' show.header = TRUE, show.confusion = TRUE, show.levels = TRUE, show.roc = TRUE,
#' hlines = FALSE, font = 3, col = "steelblue")
#'
#' # # For details, see
Expand Down Expand Up @@ -148,6 +151,7 @@ plot.FFTrees <- function(x = NULL,
main = NULL,
cue.labels = NULL,
decision.labels = NULL,
truth.labels = NULL,
#
cue.cex = NULL,
threshold.cex = NULL,
Expand Down Expand Up @@ -452,6 +456,15 @@ plot.FFTrees <- function(x = NULL,

}

# truth.labels:
if (is.null(truth.labels)) {

truth.labels <- decision.labels

# ToDo: Check for 2 cases, else use a default of c(0, 1).

}

# main: ----

if (is.null(main)) {
Expand Down Expand Up @@ -848,8 +861,8 @@ plot.FFTrees <- function(x = NULL,

# (a) N and labels:
text(x = .50, y = .78, paste("N = ", prettyNum(n_exemplars, big.mark = ","), "", sep = ""), cex = 1.25) # N
text(.50, .63, paste(decision.labels[1], sep = ""), pos = 2, cex = 1.2, adj = 1) # 1: False
text(.50, .63, paste(decision.labels[2], sep = ""), pos = 4, cex = 1.2, adj = 0) # 2: True
text(.50, .63, paste(truth.labels[1], sep = ""), pos = 2, cex = 1.2, adj = 1) # 1: False
text(.50, .63, paste(truth.labels[2], sep = ""), pos = 4, cex = 1.2, adj = 0) # 2: True

# (b) Show balls:
n_true_pos <- with(final_stats, hi + mi)
Expand Down Expand Up @@ -895,7 +908,7 @@ plot.FFTrees <- function(x = NULL,

text(
x = .80, y = p_rect_ylim[2],
labels = paste("p(", decision.labels[2], ")", sep = ""),
labels = paste("p(", truth.labels[2], ")", sep = ""),
pos = 3, cex = 1.2
)

Expand Down Expand Up @@ -933,7 +946,7 @@ plot.FFTrees <- function(x = NULL,

text(
x = .20, y = p_rect_ylim[2],
labels = paste("p(", decision.labels[1], ")", sep = ""),
labels = paste("p(", truth.labels[1], ")", sep = ""),
pos = 3, cex = 1.2
)

Expand Down Expand Up @@ -1658,13 +1671,13 @@ plot.FFTrees <- function(x = NULL,
text(
x = final_classtable_x[1] + .25 * diff(final_classtable_x),
y = subheader_y, pos = 1, cex = subheader_cex,
decision.labels[2]
truth.labels[2]
)

text(
x = final_classtable_x[1] + .75 * diff(final_classtable_x),
y = subheader_y, pos = 1, cex = subheader_cex,
decision.labels[1]
truth.labels[1]
)


Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ doi_JDM <- "10.1017/S1930297500006239"
[![R-CMD-check](https://github.com/ndphillips/FFTrees/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ndphillips/FFTrees/actions/workflows/R-CMD-check.yaml)
<!-- Devel badges end. -->


<!-- Release badges start: -->
<!-- [![CRAN status](https://www.r-pkg.org/badges/version/FFTrees)](https://CRAN.R-project.org/package=FFTrees) -->
<!-- [![Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/FFTrees?color='00a9e0')](https://www.r-pkg.org/pkg/FFTrees) -->
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ heart_fft$competition$test
#> 1 fftrees 153 64 19 9 61 0.877 0.762 0.238 0.771 0.871 0.817
#> 2 lr 153 55 13 18 67 0.753 0.838 0.162 0.809 0.788 0.797
#> 3 cart 153 50 19 23 61 0.685 0.762 0.238 0.725 0.726 0.725
#> 4 rf 153 59 5 14 75 0.808 0.938 0.0625 0.922 0.843 0.876
#> 4 rf 153 59 8 14 72 0.808 0.9 0.1 0.881 0.837 0.856
#> 5 svm 153 55 7 18 73 0.753 0.912 0.0875 0.887 0.802 0.837
#> # ℹ 6 more variables: bacc <dbl>, wacc <dbl>, dprime <dbl>, cost_dec <dbl>,
#> # cost_cue <dbl>, cost <dbl>
Expand Down Expand Up @@ -340,6 +340,6 @@ for the full list). Examples include:

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

\[File `README.Rmd` last updated on 2024-04-21.\]
\[File `README.Rmd` last updated on 2024-05-08.\]

<!-- eof. -->
11 changes: 8 additions & 3 deletions man/plot.FFTrees.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c2adc9

Please sign in to comment.