View source: R/make_class_pred.R
append_class_pred | R Documentation |
class_pred
columnThis function is similar to make_class_pred()
, but is useful when you have
a large number of class probability columns and want to use tidyselect
helpers. It appends the new class_pred
vector as a column on the original
data frame.
append_class_pred(
.data,
...,
levels,
ordered = FALSE,
min_prob = 1/length(levels),
name = ".class_pred"
)
.data |
A data frame or tibble. |
... |
One or more unquoted expressions separated by commas
to capture the columns of |
levels |
A character vector of class levels. The length should be the
same as the number of selections made through |
ordered |
A single logical to determine if the levels should be regarded
as ordered (in the order given). This results in a |
min_prob |
A single numeric value. If any probabilities are less than this value (by row), the row is marked as equivocal. |
name |
A single character value for the name of the appended
|
.data
with an extra class_pred
column appended onto it.
# The following two examples are equivalent and demonstrate
# the helper, append_class_pred()
library(dplyr)
species_probs %>%
mutate(
.class_pred = make_class_pred(
.pred_bobcat, .pred_coyote, .pred_gray_fox,
levels = levels(Species),
min_prob = .5
)
)
lvls <- levels(species_probs$Species)
append_class_pred(
.data = species_probs,
contains(".pred_"),
levels = lvls,
min_prob = .5
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.