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

refactor loss_integrate #31

Closed
hbaniecki opened this issue Jan 17, 2023 · 0 comments · Fixed by #53
Closed

refactor loss_integrate #31

hbaniecki opened this issue Jan 17, 2023 · 0 comments · Fixed by #53
Assignees
Labels
maintenance 🔨 Code enhancements, tests and maintenance

Comments

@hbaniecki
Copy link
Member

change cumsum(c(0, x))[length(x)+1] to sum(x) in all three scenarios

survex/R/metrics.R

Lines 39 to 55 in 64e96d6

integrated_metric <- cumsum(c(0, tmp))[length(tmp)+1] / (max(times) - min(times))
return(integrated_metric)
}
else if (normalization == "t_max") {
tmp <- (loss_values[1:(n - 1)] + loss_values[2:n]) * diff(times) / 2
integrated_metric <- cumsum(c(0, tmp))[length(tmp)+1]
return(integrated_metric/max(times))
} else if (normalization == "survival"){
kaplan_meier <- survfit(y_true~1)
estimator <- transform_to_stepfunction(kaplan_meier, eval_times = sort(unique(y_true[,1])), type = "survival")
dwt <- 1 - estimator(times)
tmp <- (loss_values[1:(n - 1)] + loss_values[2:n]) * diff(dwt) / 2
integrated_metric <- cumsum(c(0, tmp))[length(tmp)+1]
return(integrated_metric/(1 - estimator(max(times))))

@hbaniecki hbaniecki added the maintenance 🔨 Code enhancements, tests and maintenance label Jan 17, 2023
@mikolajsp mikolajsp self-assigned this Feb 10, 2023
@mikolajsp mikolajsp linked a pull request Feb 16, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance 🔨 Code enhancements, tests and maintenance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants