Skip to content

Commit

Permalink
Fix plotting and printing of SurvLIME for the coxph model (#73)
Browse files Browse the repository at this point in the history
* Fix issue #72

* Bump version for development and update NEWS
  • Loading branch information
mikolajsp authored Mar 24, 2023
1 parent 76993e0 commit 4292856
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: survex
Title: Explainable Machine Learning in Survival Analysis
Version: 1.0.0
Version: 1.0.0.9000
Authors@R:
c(
person("Mikołaj", "Spytek", email = "mikolajspytek@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7111-2286")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# survex (development)

* Fix not being able to plot or print SurvLIME results for the cph model sometimes. ([#72](https://github.com/ModelOriented/survex/issues/72))

# survex 1.0.0

* *breaking change:* refactored the structure of `model_performance_survival` object - calculated metrics are now in a `$result` list.
Expand Down
2 changes: 1 addition & 1 deletion R/plot_surv_lime.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ plot.surv_lime <- function(x,
if (!type %in% c("coefficients", "local_importance"))
stop("Type should be one of `coefficients`, `local_importance`")

local_importance <- as.numeric(x$result * x$variable_values)
local_importance <- as.numeric(x$result) * as.numeric(x$variable_values)
df <- data.frame(variable_names = names(x$variable_values),
variable_values = as.numeric(x$variable_values),
beta = as.numeric(x$result),
Expand Down
2 changes: 1 addition & 1 deletion R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ print.surv_feature_importance <- function(x, ...) {
print.surv_lime <- function(x, ...) {
res <- x$result

print_result <- rbind(beta = res, `X` = x$variable_values, `local importance (X*beta)` = res * x$variable_values)
print_result <- rbind(beta = res, `X` = x$variable_values, `local importance (X*beta)` = res * as.numeric(x$variable_values))
cat("SurvLIME for observation:\n\n")
print.data.frame(x$variable_values, row.names = FALSE)
cat("\n")
Expand Down

0 comments on commit 4292856

Please sign in to comment.