feature_matrix_from_data <- function(df, formula) {
x <- model.matrix(formula, df)
# intercept name
colnames(x)[1] <- "[intercept]"
# fix cases when colnames are "fixed" by model.matrix
colnames(x) <- gsub("^`|`$", "", colnames(x))
# return matrix
x
}
response_var_from_data <- function(df, formula) {
y_name <- response_name_from_formula(formula)
y <- df[[y_name]]
stopifnot(all(y %in% c(-1L, 1L)))
y
}
response_name_from_formula <- function(formula) {
all.vars(formula)[1]
}
score_to_prob <- function(score) {
1/(1 + exp(-score))
}
prob_to_score <- function(prob) {
-log(1/prob - 1)
}
random_logfile <- function() {
tempfile(pattern = "riskslimr-", fileext = ".log")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.