Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all survival metrics work with case weights #476

Merged
merged 2 commits into from
Jan 12, 2024
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: 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
Loading