View source: R/verb-evaluate.R
| evaluate | R Documentation |
Scores survival predictions in one of three ways:
evaluate(fit) or evaluate(formula, data, model) refits
the learner on each training split of resampling and scores it on the
held-out split (internal validation).
evaluate(fit, newdata = test) scores a fitted learner on
data it was not trained on (external or temporal validation).
evaluate(S, y = Surv(time, status)) scores an
n x length(times) matrix of survival probabilities produced elsewhere,
for example by another package.
evaluate(object, ...)
## S3 method for class 'survalis_fit'
evaluate(
object,
newdata = NULL,
times = NULL,
resampling = cv(),
metrics = c("cindex", "ibs"),
ncores = 1,
...
)
## S3 method for class 'formula'
evaluate(
object,
data,
model,
spec = list(),
times = NULL,
resampling = cv(),
metrics = c("cindex", "ibs"),
ncores = 1,
...
)
## S3 method for class 'matrix'
evaluate(object, y, times = NULL, metrics = c("cindex", "ibs"), ...)
object |
A |
... |
Unused. |
newdata |
When |
times |
Evaluation grid. |
resampling |
A resampling spec from |
metrics |
Character vector from |
ncores |
Cores for the split loop (default |
data |
When |
model |
When |
spec |
When |
y |
When |
A survalis_eval object: per_split (long data frame), summary
(mean / sd / se / 95% interval per metric), times, resampling (NULL
when scored once), metrics, model.
m <- fit(Surv(time, status) ~ age + karno + celltype, veteran, "ranger",
spec = list(num.trees = 100))
evaluate(m, times = c(90, 180, 365), resampling = cv(3))
# train / test split
idx <- seq_len(100)
m_tr <- fit(Surv(time, status) ~ age + karno, veteran[idx, ], "coxph")
evaluate(m_tr, newdata = veteran[-idx, ], times = c(90, 180))
# predictions from anywhere
S <- predict(m_tr, veteran[-idx, ], times = c(90, 180))
evaluate(S, y = Surv(veteran$time[-idx], veteran$status[-idx]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.