Last active
February 12, 2020 00:59
-
-
Save gweissman/1c977a4cf57c7118887a4c6d1a699ca7 to your computer and use it in GitHub Desktop.
Calculate the entropy of a set of predictions and estimate 95% confidence intervals.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Libraries | |
library(gmish) # devtools::install_github('gweissman/gmish') | |
# Size | |
N <- 1000 | |
# Softmax helper function | |
sm <- function(x) exp(x)/sum(exp(x)) | |
# Make some predictions | |
preds <- data.frame(runif(N), runif(N), runif(N)) | |
preds_sm <- t(apply(preds, 1, sm)) | |
# Calculate entropy | |
ent(preds_sm) | |
# Get bias-corrected, accelerated bootstrap confidence intervals | |
bs_ci(preds_sm, metric = ent, btype = 'bca') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment