Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# lime (development version)

* Make package work with all versions of xgboost. (#202)

# lime 0.5.3

* Emil Hvitfelt is taking over maintenance
Expand Down
11 changes: 6 additions & 5 deletions R/models.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ predict_model.xgb.Booster <- function(x, newdata, type, ...) {
if (is.data.frame(newdata)) {
newdata <- xgboost::xgb.DMatrix(as.matrix(newdata))
}
p <- data.frame(
predict(x, newdata = newdata, reshape = TRUE, ...),
stringsAsFactors = FALSE
)
if (is.null(x$params)) {
p <- data.frame(predict(x, newdata = newdata, ...))
} else {
p <- data.frame(predict(x, newdata = newdata, reshape = TRUE, ...))
}
if (type == 'raw') {
names(p) <- 'Response'
} else if (type == 'prob') {
Expand Down Expand Up @@ -277,7 +278,7 @@ model_type.WrappedModel <- function(x, ...) {
}
#' @export
model_type.xgb.Booster <- function(x, ...) {
obj <- x$params$objective
obj <- x$params$objective %||% attr(x, "params")$objective
if (is.null(obj)) {
return('regression')
}
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-text.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ xgb_model <- xgb.train(
nrounds = 50
)


test_that("single sentence explanation", {
skip("xgboost: will fix soon")
to_explain <- "Since our motivation is an application in bioinformatics, our notation and terminology will be drawn from that area"
expect_gt(predict(xgb_model, get_matrix(to_explain)), 0.5)
explainer <- lime(x = to_explain, model = xgb_model, preprocess = get_matrix)
Expand Down