Skip to content

Commit

Permalink
potential fix for #93
Browse files Browse the repository at this point in the history
  • Loading branch information
hbaniecki committed Apr 2, 2021
1 parent f16d924 commit 2353a30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
iBreakDown (development)
iBreakDown 2.0.1
---------------------------------------------------------------
* add `reload` argument to `plotD3`, which by default is `FALSE` (behavior unchanged); `TRUE` reloads the plot on resize [#89](https://github.com/ModelOriented/iBreakDown/issues/89)
* fixes explanations when data has one column [#93](https://github.com/ModelOriented/iBreakDown/issues/93)

iBreakDown 1.3.1
---------------------------------------------------------------
Expand Down
8 changes: 5 additions & 3 deletions R/break_down_uncertainty.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ break_down_uncertainty.default <- function(x, data, predict_function = predict,
# average or selected path
if (head(path, 1) == "average") {
# let's calculate an average attribution
extracted_contributions <- sapply(result, function(chunk) {
extracted_contributions <- do.call(cbind, lapply(result, function(chunk) {
chunk[order(chunk$label, chunk$variable), "contribution"]
})
}))
result_average <- result[[1]]
result_average <- result_average[order(result_average$label, result_average$variable),]
result_average$contribution <- rowMeans(extracted_contributions)
Expand Down Expand Up @@ -206,7 +206,9 @@ get_single_random_path <- function(x, data, predict_function, new_observation, l
}

diffs <- apply(do.call(rbind, yhats), 2, diff)

if (is.vector(diffs)) { #93
diffs <- t(diffs)
}
#76
new_observation_vec <- sapply(as.data.frame(new_observation), nice_format) # same as in BD

Expand Down

0 comments on commit 2353a30

Please sign in to comment.