Skip to content

Commit

Permalink
Merge pull request #476 from tidymodels/missing-cast
Browse files Browse the repository at this point in the history
Make all survival metrics work with case weights
  • Loading branch information
EmilHvitfeldt authored Jan 12, 2024
2 parents 53e1f1c + c7887c9 commit 81e2cc6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: yardstick
Title: Tidy Characterizations of Model Performance
Version: 1.2.0.9002
Version: 1.2.0.9003
Authors@R: c(
person("Max", "Kuhn", , "[email protected]", role = "aut"),
person("Davis", "Vaughan", , "[email protected]", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions R/surv-brier_survival.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ brier_survival_impl <- function(truth,
surv_status <- .extract_surv_status(truth)

if (!is.null(case_weights)) {
case_weights <- vec_cast(case_weights, to = double())
norm_const <- sum(case_weights)
} else {
case_weights <- rep(1, length(estimate))
Expand Down
2 changes: 2 additions & 0 deletions R/surv-concordance_survival.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ concordance_survival_vec <- function(truth,
concordance_survival_impl <- function(truth, estimate, case_weights) {
if (is.null(case_weights)) {
case_weights <- rep(1, length(estimate))
} else {
case_weights <- vec_cast(case_weights, to = double())
}

survival::concordance(truth ~ estimate, weights = case_weights)$concordance
Expand Down

0 comments on commit 81e2cc6

Please sign in to comment.