diff --git a/.Rbuildignore b/.Rbuildignore old mode 100644 new mode 100755 index 7ef3a46..9fd098b --- a/.Rbuildignore +++ b/.Rbuildignore @@ -10,4 +10,5 @@ tar.gz$ ^appveyor\.yml$ ^\.github$ .DS_Store -^revdep$ \ No newline at end of file +^revdep$ +^CRAN-SUBMISSION$ diff --git a/.github/.gitignore b/.github/.gitignore old mode 100644 new mode 100755 diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml old mode 100644 new mode 100755 diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION new file mode 100644 index 0000000..fbdcfac --- /dev/null +++ b/CRAN-SUBMISSION @@ -0,0 +1,3 @@ +Version: 2.5.5 +Date: 2025-06-08 18:57:19 UTC +SHA: 5f47d4cf5aa147c9f310e2917e566d2480ddd527 diff --git a/DESCRIPTION b/DESCRIPTION old mode 100644 new mode 100755 index dba61d1..4a23df2 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,11 +7,11 @@ Description: Estimate significance of importance metrics metrics for each predictor variable and p-value of observed. Provides summary and visualization functions for 'randomForest' results. -Version: 2.5.4 +Version: 2.5.6 Authors@R: c( - EA = person("Eric", "Archer", email = "eric.archer@noaa.gov", role = c("aut", "cre"))) -URL: https://github.com/EricArcher/rfPermute -BugReports: https://github.com/EricArcher/rfPermute/issues + EA = person("Eric", "Archer", email = "eric.ivan.archer@gmail.com", role = c("aut", "cre"))) +URL: https://github.com/SWFSC/rfPermute +BugReports: https://github.com/SWFSC/rfPermute/issues Depends: R (>= 4.1.0) Imports: @@ -20,9 +20,9 @@ Imports: ggplot2 (>= 3.3), grDevices, gridExtra, - magrittr (>= 2.0), methods, parallel, + pROC, randomForest (>= 4.6), rlang, scales, @@ -52,7 +52,8 @@ Collate: plotVotes.R balancedSampsize.R cleanRFdata.R + rfROC.R LazyData: TRUE License: GPL (>= 2) Encoding: UTF-8 -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 diff --git a/NAMESPACE b/NAMESPACE index d06f4cb..84aaec5 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,7 +27,7 @@ export(plotTrace) export(plotVotes) export(rfPermute) export(rfPermuteTutorial) -importFrom(magrittr,"%>%") +export(rfROC) importFrom(methods,new) importFrom(randomForest,importance) importFrom(randomForest,randomForest) diff --git a/R/balancedSampsize.R b/R/balancedSampsize.R old mode 100644 new mode 100755 diff --git a/R/casePredictions.R b/R/casePredictions.R old mode 100644 new mode 100755 diff --git a/R/classPriors.R b/R/classPriors.R old mode 100644 new mode 100755 diff --git a/R/cleanRFdata.R b/R/cleanRFdata.R old mode 100644 new mode 100755 diff --git a/R/confusionMatrix.R b/R/confusionMatrix.R old mode 100644 new mode 100755 index 3f7f731..c6ba31b --- a/R/confusionMatrix.R +++ b/R/confusionMatrix.R @@ -72,6 +72,7 @@ confusionMatrix <- function(x, conf.level = 0.95, threshold = NULL) { cm <- rbind(cm, Overall = rep(NA, ncol(cm))) pct.correct <- (correct.n / all.n) * 100 cbind( + n = all.n, cm, pct.correct = pct.correct[rownames(cm)], ci[rownames(cm), , drop = FALSE], @@ -88,8 +89,8 @@ plotConfMat <- function(x, title = NULL, plot = TRUE) { if(rf$type == "regression") stop("'rf' must be of a classification model") conf <- .confMat(rf) - pct.correct <- (100 * sum(diag(conf)) / sum(conf)) %>% - round(0) %>% + pct.correct <- (100 * sum(diag(conf)) / sum(conf)) |> + round(0) |> paste0("% correct") title <- if(is.null(title)) { pct.correct @@ -99,18 +100,18 @@ plotConfMat <- function(x, title = NULL, plot = TRUE) { freq <- rowSums(conf) rownames(conf) <- paste0(names(freq), " (", freq, ")") - p <- conf %>% - prop.table(1) %>% - as.data.frame %>% - tibble::rownames_to_column("observed") %>% - tidyr::gather("predicted", "prop", -.data$observed) %>% + p <- conf |> + prop.table(1) |> + as.data.frame() |> + tibble::rownames_to_column("observed") |> + tidyr::gather("predicted", "prop", -.data$observed) |> dplyr::mutate( observed = factor(.data$observed), observed = stats::reorder(.data$observed, dplyr::desc(.data$observed)), predicted = factor(.data$predicted) - ) %>% - ggplot2::ggplot(ggplot2::aes_string("predicted", "observed")) + - ggplot2::geom_raster(ggplot2::aes_string(fill = "prop")) + + ) |> + ggplot2::ggplot(ggplot2::aes(x = .data$predicted, y = .data$observed)) + + ggplot2::geom_raster(ggplot2::aes(fill = .data$prop)) + ggplot2::scale_fill_viridis_c( option = "magma", direction = -1, @@ -121,7 +122,8 @@ plotConfMat <- function(x, title = NULL, plot = TRUE) { ggplot2::guides(fill = ggplot2::guide_colorbar(title = "Proportion")) + ggplot2::theme( axis.text.x.top = ggplot2::element_text(angle = 45, hjust = 0), - panel.background = ggplot2::element_blank() + panel.background = ggplot2::element_blank(), + legend.key.height = ggplot2::unit(1, 'null') ) if(plot) print(p) diff --git a/R/dataSets.R b/R/dataSets.R old mode 100644 new mode 100755 diff --git a/R/importance.R b/R/importance.R old mode 100644 new mode 100755 index 25128a9..31c8f76 --- a/R/importance.R +++ b/R/importance.R @@ -137,12 +137,12 @@ plotImportance <- function(x, plot.type = c("bar", "heatmap"), imp.type = NULL, pval = if(inherits(x, "rfPermute")) { x$pval[rownames(imp.mat), i, sc] } else Inf - ) %>% - tibble::rownames_to_column("pred") %>% + ) |> + tibble::rownames_to_column("pred") |> dplyr::mutate( is.sig = .data$pval <= alpha, pred = stats::reorder(.data$pred, .data$imp) - ) %>% + ) |> dplyr::arrange(-.data$imp) if(sig.only) imp.df <- imp.df[imp.df$is.sig, ] n <- min(n, nrow(imp.df)) @@ -151,7 +151,7 @@ plotImportance <- function(x, plot.type = c("bar", "heatmap"), imp.type = NULL, ggplot2::ggplot( imp.df, - ggplot2::aes_string(x = "pred", y = "imp", fill = "is.sig") + ggplot2::aes(x = .data$pred, y = .data$imp, fill = .data$is.sig) ) + ggplot2::geom_bar(stat = "identity") + ggplot2::coord_flip() + @@ -174,17 +174,17 @@ plotImportance <- function(x, plot.type = c("bar", "heatmap"), imp.type = NULL, preds <- rev(rev(preds)[1:n]) imp.df <- data.frame(imp.mat[preds, imp.type, drop = FALSE], check.names = FALSE) if(ranks) for(i in imp.type) imp.df[[i]] <- rank(-imp.df[[i]]) - imp.df <- imp.df %>% - tibble::rownames_to_column("pred") %>% - tidyr::pivot_longer(-.data$pred, names_to = "type") %>% + imp.df <- imp.df |> + tibble::rownames_to_column("pred") |> + tidyr::pivot_longer(-.data$pred, names_to = "type") |> dplyr::mutate( type = factor(.data$type, levels = imp.type), pred = factor(.data$pred, levels = preds) ) # create plot - g <- ggplot2::ggplot(imp.df, ggplot2::aes_string("type", "pred")) + - ggplot2::geom_raster(ggplot2::aes_string(fill = "value")) + + g <- ggplot2::ggplot(imp.df, ggplot2::aes(x = .data$type, y = .data$pred)) + + ggplot2::geom_raster(ggplot2::aes(fill = .data$value)) + ggplot2::theme(panel.background = ggplot2::element_blank()) g <- g + if(ranks) { ggplot2::scale_fill_gradient2( @@ -236,4 +236,4 @@ plotImportance <- function(x, plot.type = c("bar", "heatmap"), imp.type = NULL, } } invisible(imp.plot) -} \ No newline at end of file +} diff --git a/R/internals.R b/R/internals.R old mode 100644 new mode 100755 diff --git a/R/pctCorrect.R b/R/pctCorrect.R old mode 100644 new mode 100755 diff --git a/R/plotImpPreds.R b/R/plotImpPreds.R old mode 100644 new mode 100755 index 31a34a5..603b922 --- a/R/plotImpPreds.R +++ b/R/plotImpPreds.R @@ -68,10 +68,10 @@ plotImpPreds <- function(x, df, class.col, imp.type = NULL, max.vars = 16, df$.class. <- factor(df[[class.col]]) df <- df[, c(".class.", imp.vars)] - p <- df %>% - tidyr::pivot_longer(-.data$.class., names_to = "var") %>% - dplyr::mutate(var = factor(.data$var, levels = imp.vars)) %>% - ggplot2::ggplot(ggplot2::aes_string(".class.", "value")) + + p <- df |> + tidyr::pivot_longer(-.data$.class., names_to = "var") |> + dplyr::mutate(var = factor(.data$var, levels = imp.vars)) |> + ggplot2::ggplot(ggplot2::aes(x = .data$.class., y = .data$value)) + ggplot2::geom_violin(alpha = violin.alpha) + ggplot2::geom_jitter(size = size, alpha = point.alpha, width = 0.25, height = 0) + ggplot2::facet_wrap(~ var, scales = "free_y") + @@ -80,4 +80,4 @@ plotImpPreds <- function(x, df, class.col, imp.type = NULL, max.vars = 16, if(plot) print(p) invisible(p) -} \ No newline at end of file +} diff --git a/R/plotInbag.R b/R/plotInbag.R old mode 100644 new mode 100755 index 8dc829f..3f39008 --- a/R/plotInbag.R +++ b/R/plotInbag.R @@ -72,7 +72,7 @@ plotInbag <- function(x, bins = 10, replace = TRUE, sampsize = NULL, pct <- ((rf$ntree - rf$oob.times) / rf$ntree) * 100 bins <- max(bins, floor(length(pct) / 5)) p <- data.frame(pct = pct) |> - ggplot2::ggplot(ggplot2::aes_string("pct")) + + ggplot2::ggplot(ggplot2::aes(x = .data$pct)) + ggplot2::geom_histogram(bins = bins) + ggplot2::labs( x = "Percent of trees where sample was inbag", diff --git a/R/plotNull.R b/R/plotNull.R old mode 100644 new mode 100755 index a1ef574..4c3eff4 --- a/R/plotNull.R +++ b/R/plotNull.R @@ -65,17 +65,17 @@ plotNull <- function(x, preds = NULL, imp.type = NULL, scale = TRUE, imp.type ) - df <- sapply(imp.type, function(i) x$null.dist[[sc]][pr, i, ]) %>% - as.data.frame() %>% - tidyr::gather("imp.type", "importance") %>% + df <- sapply(imp.type, function(i) x$null.dist[[sc]][pr, i, ]) |> + as.data.frame() |> + tidyr::gather("imp.type", "importance") |> dplyr::mutate(imp.type = factor(labels[imp.type], levels = labels)) - obs <- imp[pr, imp.type, drop = FALSE] %>% - as.data.frame() %>% - tibble::rownames_to_column("predictor") %>% - tidyr::gather("imp.type", "importance", -.data$predictor) %>% + obs <- imp[pr, imp.type, drop = FALSE] |> + as.data.frame() |> + tibble::rownames_to_column("predictor") |> + tidyr::gather("imp.type", "importance", -.data$predictor) |> dplyr::mutate(imp.type = factor(labels[imp.type], levels = labels)) - p <- ggplot2::ggplot(df, ggplot2::aes_string("importance")) + p <- ggplot2::ggplot(df, ggplot2::aes(x = .data$importance)) p <- if(plot.type == "hist") { p + ggplot2::geom_histogram() + ggplot2::ylab("Count") } else { @@ -85,7 +85,7 @@ plotNull <- function(x, preds = NULL, imp.type = NULL, scale = TRUE, ggplot2::xlab("Importance") + ggplot2::ggtitle(pr) + ggplot2::geom_vline( - ggplot2::aes_string(xintercept = "importance"), + ggplot2::aes(xintercept = .data$importance), color = "red", data = obs ) + ggplot2::facet_wrap(~ imp.type, scales = "free") @@ -93,4 +93,4 @@ plotNull <- function(x, preds = NULL, imp.type = NULL, scale = TRUE, if(plot) for(p in g) print(p) invisible(g) -} \ No newline at end of file +} diff --git a/R/plotPredictedProbs.R b/R/plotPredictedProbs.R old mode 100644 new mode 100755 index 39e6603..6a6c6af --- a/R/plotPredictedProbs.R +++ b/R/plotPredictedProbs.R @@ -25,16 +25,16 @@ plotPredictedProbs <- function(x, bins = 30, plot = TRUE) { rf <- as.randomForest(x) if(rf$type == "regression") stop("'rf' must be of a classification model") - p <- rf$votes %>% - as.data.frame %>% + p <- rf$votes |> + as.data.frame() |> cbind( class = as.character(rf$y), predicted = as.character(rf$predicted) - ) %>% - tidyr::gather("pred.class", "prob", -.data$class, -.data$predicted) %>% - dplyr::filter(.data$predicted == .data$pred.class) %>% - dplyr::mutate(correct = .data$class == .data$predicted) %>% - ggplot2::ggplot(ggplot2::aes_string("prob", fill = "class")) + + ) |> + tidyr::gather("pred.class", "prob", -.data$class, -.data$predicted) |> + dplyr::filter(.data$predicted == .data$pred.class) |> + dplyr::mutate(correct = .data$class == .data$predicted) |> + ggplot2::ggplot(ggplot2::aes(.data$prob, fill = .data$class)) + ggplot2::geom_histogram(bins = bins) + ggplot2::facet_wrap(~ predicted) + ggplot2::labs(x = "Assignment probability", y = "Frequency") + @@ -42,4 +42,4 @@ plotPredictedProbs <- function(x, bins = 30, plot = TRUE) { if(plot) print(p) invisible(p) -} \ No newline at end of file +} diff --git a/R/plotProximity.R b/R/plotProximity.R old mode 100644 new mode 100755 index edf2da6..1cf5770 --- a/R/plotProximity.R +++ b/R/plotProximity.R @@ -77,7 +77,7 @@ plotProximity <- function(x, dim.x = 1, dim.y = 2, class.cols = NULL, mds.df <- data.frame(prox.mds, class = rf$y, predicted = rf$predicted) colnames(mds.df)[1:2] <- c("x", "y") - g <- ggplot2::ggplot(mds.df, ggplot2::aes_(~x, ~y, color = ~class)) + g <- ggplot2::ggplot(mds.df, ggplot2::aes(.data$x, .data$y, color = .data$class)) # Origin axes g <- g + @@ -93,7 +93,7 @@ plotProximity <- function(x, dim.x = 1, dim.y = 2, class.cols = NULL, group.type, ellipse = { g <- g + ggplot2::stat_ellipse( - ggplot2::aes_(fill = ~class), + ggplot2::aes(fill = .data$class), geom = "polygon", alpha = group.alpha, level = ellipse.level, @@ -105,7 +105,7 @@ plotProximity <- function(x, dim.x = 1, dim.y = 2, class.cols = NULL, cl.df <- mds.df[mds.df$class == cl, ] i <- grDevices::chull(cl.df$x, cl.df$y) g <- g + ggplot2::geom_polygon( - ggplot2::aes_(fill = ~class), + ggplot2::aes(fill = .data$class), data = cl.df[c(i, i[1]), ], alpha = group.alpha, show.legend = legend.type == "legend" @@ -133,7 +133,7 @@ plotProximity <- function(x, dim.x = 1, dim.y = 2, class.cols = NULL, # Predicted circles if(!is.null(circle.size)) { g <- g + ggplot2::geom_point( - ggplot2::aes_(color = ~predicted), + ggplot2::aes(color = .data$predicted), shape = 21, size = circle.size, stroke = circle.border, @@ -152,13 +152,13 @@ plotProximity <- function(x, dim.x = 1, dim.y = 2, class.cols = NULL, # Class labels if(legend.type == "label") { g <- g + ggplot2::geom_label( - ggplot2::aes_(label = ~class), - data = mds.df %>% - dplyr::group_by(.data$class) %>% + ggplot2::aes(label = .data$class), + data = mds.df |> + dplyr::group_by(.data$class) |> dplyr::summarize( x = mean(.data$x), y = mean(.data$y) - ) %>% + ) |> dplyr::ungroup(), fill = "white", alpha = label.alpha, @@ -193,4 +193,4 @@ plotProximity <- function(x, dim.x = 1, dim.y = 2, class.cols = NULL, if(plot) print(g) invisible(list(prox.mds = prox.mds, g = g)) -} \ No newline at end of file +} diff --git a/R/plotTrace.R b/R/plotTrace.R old mode 100644 new mode 100755 index 7688a70..cf5f2c5 --- a/R/plotTrace.R +++ b/R/plotTrace.R @@ -28,15 +28,17 @@ plotTrace <- function(x, pct.correct = TRUE, plot = TRUE) { names(class.cols) <- names(class.lines) <- c("OOB", levels(rf$y)) df <- as.data.frame(rf$err.rate) - df %>% - dplyr::mutate(trees = 1:dplyr::n()) %>% - tidyr::gather("class", "error", -.data$trees) %>% + df |> + dplyr::mutate(trees = 1:dplyr::n()) |> + tidyr::gather("class", "error", -.data$trees) |> dplyr::mutate( class = factor(.data$class, levels = colnames(df)), error = if(pct.correct) (1 - .data$error) * 100 else .data$error * 100 - ) %>% - ggplot2::ggplot(ggplot2::aes_string("trees", "error", color = "class")) + - ggplot2::geom_line(ggplot2::aes_string(linetype = "class")) + + ) |> + ggplot2::ggplot( + ggplot2::aes(x = .data$trees, y = .data$error, color = .data$class) + ) + + ggplot2::geom_line(ggplot2::aes(linetype = .data$class)) + ggplot2::scale_color_manual(values = class.cols) + ggplot2::scale_linetype_manual(values = class.lines) + ggplot2::labs( @@ -45,8 +47,8 @@ plotTrace <- function(x, pct.correct = TRUE, plot = TRUE) { ) + ggplot2::theme(legend.title = ggplot2::element_blank()) } else if(utils::hasName(rf, "mse")) { - data.frame(trees = 1:length(rf$mse), error = rf$mse) %>% - ggplot2::ggplot(ggplot2::aes_string("trees", "error")) + + data.frame(trees = 1:length(rf$mse), error = rf$mse) |> + ggplot2::ggplot(ggplot2::aes(x = .data$trees, y = .data$error)) + ggplot2::geom_line() + ggplot2::labs(x = "Trees", y = "Mean Squared Error") } else NULL @@ -59,4 +61,4 @@ plotTrace <- function(x, pct.correct = TRUE, plot = TRUE) { } if(plot) print(p) invisible(p) -} \ No newline at end of file +} diff --git a/R/plotVotes.R b/R/plotVotes.R old mode 100644 new mode 100755 diff --git a/R/rfPermute-package.R b/R/rfPermute-package.R old mode 100644 new mode 100755 index ff7d5b6..4823b5a --- a/R/rfPermute-package.R +++ b/R/rfPermute-package.R @@ -8,7 +8,6 @@ #' #' @importFrom randomForest randomForest #' @importFrom rlang .data -#' @importFrom magrittr %>% #' @importFrom methods new #' .onAttach <- function(libname, pkgname) { diff --git a/R/rfPermute.R b/R/rfPermute.R index f0110eb..af4a3ef 100755 --- a/R/rfPermute.R +++ b/R/rfPermute.R @@ -270,7 +270,6 @@ predict.rfPermute <- function(object, ...) predict(as.randomForest(object), ...) #' @rdname rfPermute -#' @importFrom stats predict #' @export #' rfPermuteTutorial <- function() { diff --git a/R/rfROC.R b/R/rfROC.R new file mode 100644 index 0000000..ee47a42 --- /dev/null +++ b/R/rfROC.R @@ -0,0 +1,110 @@ +#' @title Receiver Operator Curve +#' @description Create a Receiver Operator Curve (ROC) for each class in a +#' Random Forest model and (optionally) plot them. +#' +#' @param x a \code{rfPermute} or \code{randomForest} model object. +#' @param plot logical? Plot the curve? +#' +#' @return \describe{ a list returned invisbly containing: +#' \item{\code{roc}}{a list containing ROC results from \code{\link[pROC]{roc}} for each class} +#' \item{\code{smry}}{a data fame summarizing the threshold and AUC for each class} +#' \item{\code{plot}}{the \code{ggplot} plot of the ROC curves} +#'} +#' +#' @author Eric Archer \email{eric.archer@@noaa.gov} +#' +#' @examples +#' library(randomForest) +#' data(mtcars) +#' +#' # random sampling with replacement +#' rf <- randomForest(factor(am) ~ ., mtcars) +#' +#' roc <- rfROC(rf) +#' +#' roc$smry +#' +#' @export +#' +rfROC <- function(x, plot = TRUE) { + rf <- as.randomForest(x) + if(rf$type != "classification") stop("'x' must be of a classification model") + + roc.list <- sapply(levels(rf$y), function(cls) { + class.roc <- pROC::roc( + as.numeric(rf$y == cls), + rf$votes[, cls], + direction = "<", + quiet = TRUE + ) + + df <- data.frame( + sensitivity = class.roc$sensitivities, + specificity = class.roc$specificities, + threshold = class.roc$thresholds + ) |> + dplyr::mutate( + class = cls, + threshold = ifelse(.data$threshold == -Inf, 0, .data$threshold), + threshold = ifelse(.data$threshold == Inf, 1, .data$threshold) + ) |> + dplyr::arrange(dplyr::desc(.data$specificity), .data$sensitivity, .data$threshold) + + list(roc = class.roc, df = df) + }, simplify = FALSE) + + smry <- do.call( + rbind, + lapply(roc.list, function(r) { + pROC::coords( + roc = r$roc, + x = "best", + ret = c("threshold", "sensitivity", "specificity") + ) |> + dplyr::mutate( + auc = as.vector(pROC::auc(r$roc)), + class = unique(r$df$class) + ) |> + dplyr::select(.data$class, dplyr::everything()) + }) + ) |> + tibble::remove_rownames() + + p <- do.call( + rbind, + lapply(roc.list, function(x) x$df) + ) |> + ggplot2::ggplot(ggplot2::aes(.data$specificity, .data$sensitivity)) + + ggplot2::annotate( + 'segment', + x = 1, + y = 0, + xend = 0, + yend = 1, + linetype = 'dashed', + color = 'gray' + ) + + ggplot2::geom_line(ggplot2::aes(color = .data$threshold), linewidth = 2) + + ggplot2::geom_text(data = smry, label = 'T') + + ggplot2::labs(x = 'Specificity', y = 'Sensitivity') + + ggplot2::scale_color_distiller( + name = 'Threshold', + palette = 'Spectral', + limits = c(0, 1), + rescaler = ~scales::rescale_mid(., mid = 0.5), + direction = -1 + ) + + ggplot2::scale_x_reverse() + + ggplot2::facet_wrap('class') + + ggplot2::theme_minimal() + + ggplot2::theme(legend.key.height = ggplot2::unit(1, "null")) + if(plot) plot(p) + + print(smry) + + invisible(list( + roc = sapply(roc.list, function(x) x$roc, simplify = FALSE), + smry = smry, + p = p + )) +} \ No newline at end of file diff --git a/R/summary.R b/R/summary.R old mode 100644 new mode 100755 diff --git a/README.md b/README.md index 8aa827c..4f4be7c 100755 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ devtools::install_github('EricArcher/rfPermute') * `plotProximity` Plot Random Forest Proximity Scores * `plotTrace` Trace of cumulative error rates in forest * `plotVotes` Vote Distribution +* `rfROC` Receiver Operator Curve ### Miscellaneous functions * `combineRP` Combine rfPermute models @@ -59,7 +60,16 @@ devtools::install_github('EricArcher/rfPermute') ## Changelog -### version 2.5.4 (on CRAN) +### version 2.5.6 (devel) + +* switched aes_string() and aes_() for aes() in ggplot plots +* added rfROC() + +### version 2.5.5 (on CRAN) + +* move of package to SWFSC/rfPermute as main GitHub repository + +### version 2.5.4 * fixed print.rfPermute output for regression models. diff --git a/appveyor.yml b/appveyor.yml old mode 100644 new mode 100755 diff --git a/data/symb.metab.rda b/data/symb.metab.rda old mode 100644 new mode 100755 diff --git a/inst/rfPermute_Tutorial.html b/inst/rfPermute_Tutorial.html old mode 100644 new mode 100755 diff --git a/man/balancedSampsize.Rd b/man/balancedSampsize.Rd old mode 100644 new mode 100755 diff --git a/man/casePredictions.Rd b/man/casePredictions.Rd old mode 100644 new mode 100755 diff --git a/man/classPriors.Rd b/man/classPriors.Rd old mode 100644 new mode 100755 diff --git a/man/cleanRFdata.Rd b/man/cleanRFdata.Rd old mode 100644 new mode 100755 diff --git a/man/combineRP.Rd b/man/combineRP.Rd old mode 100644 new mode 100755 diff --git a/man/confusionMatrix.Rd b/man/confusionMatrix.Rd old mode 100644 new mode 100755 diff --git a/man/importance.Rd b/man/importance.Rd old mode 100644 new mode 100755 diff --git a/man/pctCorrect.Rd b/man/pctCorrect.Rd old mode 100644 new mode 100755 diff --git a/man/plotImpPreds.Rd b/man/plotImpPreds.Rd old mode 100644 new mode 100755 diff --git a/man/plotInbag.Rd b/man/plotInbag.Rd old mode 100644 new mode 100755 diff --git a/man/plotNull.Rd b/man/plotNull.Rd old mode 100644 new mode 100755 diff --git a/man/plotPredictedProbs.Rd b/man/plotPredictedProbs.Rd old mode 100644 new mode 100755 diff --git a/man/plotProximity.Rd b/man/plotProximity.Rd old mode 100644 new mode 100755 diff --git a/man/plotTrace.Rd b/man/plotTrace.Rd old mode 100644 new mode 100755 diff --git a/man/plotVotes.Rd b/man/plotVotes.Rd old mode 100644 new mode 100755 diff --git a/man/rfPermute-package.Rd b/man/rfPermute-package.Rd old mode 100644 new mode 100755 index 67f3e2e..8f34525 --- a/man/rfPermute-package.Rd +++ b/man/rfPermute-package.Rd @@ -10,13 +10,13 @@ Random Forest Predictor Importance Significance and Model Diagnostics. \seealso{ Useful links: \itemize{ - \item \url{https://github.com/EricArcher/rfPermute} - \item Report bugs at \url{https://github.com/EricArcher/rfPermute/issues} + \item \url{https://github.com/SWFSC/rfPermute} + \item Report bugs at \url{https://github.com/SWFSC/rfPermute/issues} } } \author{ -\strong{Maintainer}: Eric Archer \email{eric.archer@noaa.gov} +\strong{Maintainer}: Eric Archer \email{eric.ivan.archer@gmail.com} } \keyword{internal} diff --git a/man/rfROC.Rd b/man/rfROC.Rd new file mode 100644 index 0000000..19c2b90 --- /dev/null +++ b/man/rfROC.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rfROC.R +\name{rfROC} +\alias{rfROC} +\title{Receiver Operator Curve} +\usage{ +rfROC(x, plot = TRUE) +} +\arguments{ +\item{x}{a \code{rfPermute} or \code{randomForest} model object.} + +\item{plot}{logical? Plot the curve?} +} +\value{ +\describe{ a list returned invisbly containing: + \item{\code{roc}}{a list containing ROC results from \code{\link[pROC]{roc}} for each class} + \item{\code{smry}}{a data fame summarizing the threshold and AUC for each class} + \item{\code{plot}}{the \code{ggplot} plot of the ROC curves} +} +} +\description{ +Create a Receiver Operator Curve (ROC) for each class in a + Random Forest model and (optionally) plot them. +} +\examples{ +library(randomForest) +data(mtcars) + +# random sampling with replacement +rf <- randomForest(factor(am) ~ ., mtcars) + +roc <- rfROC(rf) + +roc$smry + +} +\author{ +Eric Archer \email{eric.archer@noaa.gov} +} diff --git a/man/summary.Rd b/man/summary.Rd old mode 100644 new mode 100755 diff --git a/man/symb.metab.Rd b/man/symb.metab.Rd old mode 100644 new mode 100755