Skip to content
Snippets Groups Projects
Unverified Commit fd30c19d authored by Gärber, Florian's avatar Gärber, Florian Committed by GitHub
Browse files

fix: Set mean adjusted agreement with same variable to NA (#6)

#4 Fixed the issue of writing past the end of the vector, however
neglected use-cases where `candidates` was not equal to `variables`.
This patch removes setting NA in `mean.index()` entirely, and applies
the colname/rowname-wise fix to the created matrix instead.
This fixes the issue where in the README example, the MAA of X7 with X2
would be set to NA, instead of with X7.
This should also keep things stable against shuffled columns, or
supplying variables in a different order than candidates, and should not
encounter the issue of extra NAs.
parents 56136bd7 fbab4790
No related branches found
Tags v0.3.3
No related merge requests found
Type: Package
Package: RFSurrogates
Title: Surrogate Minimal Depth Variable Importance
Version: 0.3.2
Version: 0.3.3
Authors@R: c(
person("Stephan", "Seifert", , "stephan.seifert@uni-hamburg.de", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2567-5728")),
......
......@@ -2,6 +2,10 @@
<!-- News Style-guide: https://style.tidyverse.org/news.html -->
# RFSurrogates 0.3.3
* Fixed `meanAdjAgree()` bug which caused mean adjusted agreement pairings to be set to NA incorrectly when `variables` was a subset or differently ordered than `candidates`.
# RFSurrogates 0.3.2
* Moved to new repository: [AGSeifert/RFSurrogates](https://github.com/AGSeifert/RFSurrogates)
......
......@@ -45,6 +45,7 @@ meanAdjAgree <- function(trees, variables, allvariables, candidates, t, s.a, sel
)
colnames(results.allvar) <- candidates
rownames(results.allvar) <- variables
results.allvar[outer(rownames(results.allvar), colnames(results.allvar), "==")] <- NA
if (select.var) {
# calculate threshold and select variables according to it
......@@ -67,7 +68,6 @@ mean.index <- function(i, list.res, index.variables) {
list <- list.res[which(names(list.res) == index.variables[i])]
mean.list <- round(Reduce("+", list) / length(list), 2)
if (length(mean.list) > 0) {
mean.list[i] <- NA
return(mean.list)
} else {
return(rep(NA, length(index.variables)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment