Revision ce82484948ede7069cb0876916e6f993db2decf9 authored by pat-s on 26 November 2019, 22:20:58 UTC, committed by pat-s on 26 November 2019, 22:20:58 UTC
1 parent 0645b98
checkPrediction.R
checkPrediction = function(pred, task.type = NULL, binary = FALSE, predict.type = NULL, check.truth = FALSE, no.na = TRUE) {
assertClass(pred, "Prediction")
if (!is.null(task.type) && pred$task.desc$type %nin% task.type) {
stopf("Prediction must be one of '%s', but is: '%s'", collapse(task.type), pred$task.desc$type)
}
if (binary) {
nlevs = length(pred$task.desc$class.levels)
if (nlevs != 2L) {
stopf("Prediction must be for binary classification, but has %i class levels!", nlevs)
}
}
if (!is.null(predict.type) && pred$predict.type %nin% predict.type) {
stopf("predict.type must be one of '%s', but is: '%s'", collapse(predict.type), pred$predict.type)
}
if (check.truth && is.null(pred$data$truth)) {
stopf("Prediction object does not contain ground truth column 'truth'!")
}
if (no.na) {
r = getPredictionResponse(pred)
if (anyMissing(r)) {
stopf("Prediction object contains NAs in response, this likely due to a prediction from a FailureModel!")
}
}
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...