Skip to content

Commit e2fe27f

Browse files
authored
Merge pull request #15 from Yue-Jiang/master
prep for new cran release
2 parents b35f4da + 555a2f6 commit e2fe27f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1215
-3761
lines changed

.Rbuildignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ materials*
55
^_pkgdown\.yml$
66
^\.travis\.yml$
77
^cran-comments\.md$
8+
^doc$
9+
^Meta$

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.Rproj.user
22
.Rhistory
33
.RData
4+
doc
5+
Meta

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: randomForestExplainer
22
Title: Explaining and Visualizing Random Forests in Terms of Variable Importance
3-
Version: 0.9
3+
Version: 0.10.0
44
Authors@R: c(
55
person("Aleksandra", "Paluszynska", email = "ola.paluszynska@gmail.com", role = c("aut")),
66
person("Przemyslaw", "Biecek", email = "przemyslaw.biecek@gmail.com", role = c("aut","ths")),
@@ -18,13 +18,13 @@ Imports:
1818
GGally (>= 1.3.0),
1919
ggplot2 (>= 2.2.1),
2020
ggrepel (>= 0.6.5),
21-
MASS (>= 7.3.47),
2221
randomForest (>= 4.6.12),
2322
ranger(>= 0.9.0),
2423
reshape2 (>= 1.4.2),
2524
rmarkdown (>= 1.5)
2625
Suggests:
2726
knitr,
27+
MASS (>= 7.3.47),
2828
testthat
2929
VignetteBuilder: knitr
3030
RoxygenNote: 6.1.1

NEWS.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# randomForestExplainer 0.10.0
2+
## New features
3+
* Added support for ranger forests.
4+
* Added support for unsupervised randomForest.
5+
* Added tests for most functions.
6+
7+
## Bug fixes
8+
* Fixed bug for explain_forest not finding templates.
9+
* Added more intuitive error message for explain_forest when local importance is absent.

R/measure_importance.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ measure_importance.randomForest <- function(forest, mean_sample = "top_trees", m
148148
}
149149
forest_table <-
150150
lapply(1:forest$ntree, function(i) randomForest::getTree(forest, k = i, labelVar = T) %>%
151+
mutate_if(is.factor, as.character) %>%
151152
calculate_tree_depth() %>% cbind(tree = i)) %>% rbindlist()
152153
min_depth_frame <- dplyr::group_by(forest_table, tree, `split var`) %>%
153154
dplyr::summarize(min(depth))
@@ -245,7 +246,7 @@ measure_importance.ranger <- function(forest, mean_sample = "top_trees", measure
245246
#' @param importance_frame A result of using the function measure_importance() to a random forest or a randomForest object
246247
#' @param measures A character vector specifying the measures of importance to be used
247248
#' @param k The number of variables to extract
248-
#' @param ties_action One of three: c("none", "all", "draw"); specifies which variables to pick when ties occur. When set to "none" we may get less than k variables, when "all" whe may get more and "draw" makes us get exactly k.
249+
#' @param ties_action One of three: c("none", "all", "draw"); specifies which variables to pick when ties occur. When set to "none" we may get less than k variables, when "all" we may get more and "draw" makes us get exactly k.
249250
#'
250251
#' @return A character vector with names of k variables with highest sum of rankings
251252
#'

R/min_depth_distribution.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ calculate_tree_depth_ranger <- function(frame){
3939
#' @return A data frame with the value of minimal depth for every variable in every tree
4040
#'
4141
#' @examples
42-
#' min_depth_distribution(randomForest::randomForest(Species ~ ., data = iris))
43-
#' min_depth_distribution(ranger::ranger(Species ~ ., data = iris))
42+
#' min_depth_distribution(randomForest::randomForest(Species ~ ., data = iris, ntree = 100))
43+
#' min_depth_distribution(ranger::ranger(Species ~ ., data = iris, num.trees = 100))
4444
#'
4545
#' @export
4646
min_depth_distribution <- function(forest){
@@ -54,6 +54,7 @@ min_depth_distribution.randomForest <- function(forest){
5454
tree <- NULL; `split var` <- NULL; depth <- NULL
5555
forest_table <-
5656
lapply(1:forest$ntree, function(i) randomForest::getTree(forest, k = i, labelVar = T) %>%
57+
mutate_if(is.factor, as.character) %>%
5758
calculate_tree_depth() %>% cbind(tree = i)) %>% rbindlist()
5859
min_depth_frame <- dplyr::group_by(forest_table, tree, `split var`) %>%
5960
dplyr::summarize(min(depth))

R/min_depth_interactions.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ min_depth_interactions_values <- function(forest, vars){
6060
`.` <- NULL; .SD <- NULL; tree <- NULL; `split var` <- NULL
6161
interactions_frame <-
6262
lapply(1:forest$ntree, function(i) randomForest::getTree(forest, k = i, labelVar = T) %>%
63+
mutate_if(is.factor, as.character) %>%
6364
calculate_tree_depth() %>% cbind(., tree = i, number = 1:nrow(.))) %>%
6465
data.table::rbindlist() %>% as.data.frame()
6566
interactions_frame[vars] <- as.numeric(NA)
@@ -109,11 +110,11 @@ min_depth_interactions_values_ranger <- function(forest, vars){
109110
#' Calculate mean conditional minimal depth with respect to a vector of variables
110111
#'
111112
#' @param forest A randomForest object
112-
#' @param vars A character vector with variables with respect to which conditional minimal depth will be calculated; by defalt it is extracted by the important_variables function but this may be time consuming
113+
#' @param vars A character vector with variables with respect to which conditional minimal depth will be calculated; by default it is extracted by the important_variables function but this may be time consuming
113114
#' @param mean_sample The sample of trees on which conditional mean minimal depth is calculated, possible values are "all_trees", "top_trees", "relevant_trees"
114115
#' @param uncond_mean_sample The sample of trees on which unconditional mean minimal depth is calculated, possible values are "all_trees", "top_trees", "relevant_trees"
115116
#'
116-
#' @return A data frame with each observarion giving the means of conditional minimal depth and the size of sample for a given interaction
117+
#' @return A data frame with each observation giving the means of conditional minimal depth and the size of sample for a given interaction
117118
#'
118119
#' @examples
119120
#' forest <- randomForest::randomForest(Species ~ ., data = iris, ntree = 100)
@@ -164,6 +165,7 @@ min_depth_interactions.randomForest <- function(forest, vars = important_variabl
164165
interactions_frame$interaction <- paste(interactions_frame$root_variable, interactions_frame$variable, sep = ":")
165166
forest_table <-
166167
lapply(1:forest$ntree, function(i) randomForest::getTree(forest, k = i, labelVar = T) %>%
168+
mutate_if(is.factor, as.character) %>%
167169
calculate_tree_depth() %>% cbind(tree = i)) %>% rbindlist()
168170
min_depth_frame <- dplyr::group_by(forest_table, tree, `split var`) %>%
169171
dplyr::summarize(min(depth))

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
[![codecov](https://codecov.io/gh/ModelOriented/randomForestExplainer/branch/master/graph/badge.svg)](https://codecov.io/gh/ModelOriented/randomForestExplainer)
66
[![DOI](https://zenodo.org/badge/97007621.svg)](https://zenodo.org/badge/latestdoi/97007621)
77

8-
A set of tools to understand what is happening inside a Random Forest. A detailed discussion of the package and importance measures it implements can be found here: [Master thesis on randomForestExplainer](https://rawgit.com/geneticsMiNIng/BlackBoxOpener/master/randomForestExplainer_Master_thesis.pdf).
8+
A set of tools to understand what is happening inside a Random Forest. A detailed discussion of the package and importance measures it implements can be found here: [Master thesis on randomForestExplainer](https://cdn.staticaly.com/gh/geneticsMiNIng/BlackBoxOpener/master/randomForestExplainer_Master_thesis.pdf).
99

10-
## Instalation
10+
## Installation
1111

1212
randomForestExplainer can be installed from [CRAN](https://cran.r-project.org/package=randomForestExplainer) as follows:
1313

@@ -26,12 +26,12 @@ library(randomForestExplainer)
2626

2727
## Vignette
2828

29-
* [Understanding random forests with randomForestExplainer](https://rawgit.com/ModelOriented/randomForestExplainer/master/inst/doc/randomForestExplainer.html)
29+
* [Understanding random forests with randomForestExplainer](https://modeloriented.github.io/randomForestExplainer/articles/randomForestExplainer.html)
3030

3131
## Cheatsheets
3232

3333
* [A one-page summary](https://github.com/ModelOriented/randomForestExplainer/blob/master/materials/cheatsheet.pdf)
3434

3535
## Examples
3636

37-
* [Initial vignette for glioblastoma data](https://rawgit.com/geneticsMiNIng/BlackBoxOpener/master/randomForestExplainer/inst/doc/randomForestExplainer.html)
37+
* [Initial vignette for glioblastoma data](https://cdn.staticaly.com/gh/geneticsMiNIng/BlackBoxOpener/master/randomForestExplainer/inst/doc/randomForestExplainer.html)

cran-comments.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Test environments
2+
* local OS X install, R 3.6.1
3+
* ubuntu 16.04 (on travis-ci, devel and release)
4+
* win-builder (devel and release)
5+
6+
## R CMD check results
7+
There were no ERRORs or WARNINGs.
8+
9+
There was one NOTE:
10+
```
11+
* checking CRAN incoming feasibility ... NOTE
12+
Maintainer: 'Yue Jiang <rivehill@gmail.com>'
13+
14+
New maintainer:
15+
Yue Jiang <rivehill@gmail.com>
16+
Old maintainer(s):
17+
Aleksandra Paluszynska <ola.paluszynska@gmail.com>
18+
```
19+
The maintainer role has been passed along to Yue Jiang and this is correct.
20+
21+
## Downstream dependencies
22+
There are no downstream dependencies at this time.

docs/404.html

+13-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/index.html

+13-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)