Description Usage Arguments Value Examples
View source: R/make_class_pred.R
These functions can be used to convert class probability estimates to
class_pred
objects with an optional equivocal zone.
1 2 3 4 5 6 7 8 9 
... 
Numeric vectors corresponding to class probabilities. There should
be one for each level in 
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. 
estimate 
A single numeric vector corresponding to the class
probabilities of the first level in 
threshold 
A single numeric value for the threshold to call a row to
be labeled as the first value of 
buffer 
A numeric vector of length 1 or 2 for the buffer around

A vector of class class_pred
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32  library(dplyr)
good < segment_logistic$.pred_good
lvls < levels(segment_logistic$Class)
# Equivocal zone of .5 +/ .15
make_two_class_pred(good, lvls, buffer = 0.15)
# Equivocal zone of c(.5  .05, .5 + .15)
make_two_class_pred(good, lvls, buffer = c(0.05, 0.15))
# These functions are useful alongside dplyr::mutate()
segment_logistic %>%
mutate(
.class_pred = make_two_class_pred(
estimate = .pred_good,
levels = levels(Class),
buffer = 0.15
)
)
# Multiclass example
# Note that we provide class probability columns in the same
# order as the levels
species_probs %>%
mutate(
.class_pred = make_class_pred(
.pred_bobcat, .pred_coyote, .pred_gray_fox,
levels = levels(Species),
min_prob = .5
)
)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.