Spruce up predictionsSource:
The family of
spruce_*() functions convert predictions into a
standardized format. They are generally called from a prediction
implementation function for the specific
type of prediction to return.
type = "numeric") A numeric vector of predictions.
type = "class") A factor of "hard" class predictions.
- pred_levels, prob_matrix
type = "prob")
pred_levelsshould be a character vector of the original levels of the outcome used in training.
prob_matrixshould be a numeric matrix of class probabilities with as many columns as levels in
pred_levels, and in the same order.
A tibble, ideally with the same number of rows as the
predict(). The column names and number of columns vary based on the
function used, but are standardized.
After running a
spruce_*() function, you should always use the validation
validate_prediction_size() to ensure that the number of rows
being returned is the same as the number of rows in the input (