Description Usage Arguments Details Value Examples
View source: R/add_noise_to_outcomes.R
This function can be used to flip a set proportion of match outcomes. Useful for testing models under varying levels of signal to noise ratios.
1 | add_noise_to_outcomes(outcome, error_prob = 0.1)
|
outcome |
Original match outcome. Must be one of 0, 0.5, or 1. |
error_prob |
The probability an outcome switches from a 0 to 1 or vice-versa |
Input outcomes of 0.5 will be randomy rounded to either 0 or 1.
a numeric vector.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Create some sample outcomes
set.seed(1)
test_df <- data.frame(
true_outcome = sample(c(0,1), 1000, replace=TRUE)
)
# No noise
test_df$noisy_outcome = add_noise_to_outcomes(test_df$true_outcome, error_prob = 0)
table(test_df)
# Test different noise levels
test_df$noisy_outcome = add_noise_to_outcomes(test_df$true_outcome, error_prob = 0.1)
table(test_df)
test_df$noisy_outcome = add_noise_to_outcomes(test_df$true_outcome, error_prob = 0.5)
table(test_df)
test_df$noisy_outcome = add_noise_to_outcomes(test_df$true_outcome, error_prob = 1)
table(test_df)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.