# Attach cvms
library(cvms)
# \donttest{
# Create a tibble with 5 classes and 10 observations
# Apply softmax to make sure the probabilities sum to 1
multiclass_probability_tibble(
num_classes = 5,
num_observations = 10,
apply_softmax = TRUE
)
# Using the rnorm function to generate the random numbers
multiclass_probability_tibble(
num_classes = 5,
num_observations = 10,
apply_softmax = TRUE,
FUN = rnorm
)
# Add targets and predicted classes
multiclass_probability_tibble(
num_classes = 5,
num_observations = 10,
apply_softmax = TRUE,
FUN = rnorm,
add_predicted_classes = TRUE,
add_targets = TRUE
)
# Creating a custom generator function that
# exponentiates the numbers to create more "certain" predictions
rcertain <- function(n) {
(runif(n, min = 1, max = 100)^1.4) / 100
}
multiclass_probability_tibble(
num_classes = 5,
num_observations = 10,
apply_softmax = TRUE,
FUN = rcertain
)
# }
Run the code above in your browser using DataLab