This file contains 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
library(tidymodels) | |
library(probably) | |
set.seed(12) | |
example <- | |
two_class_example %>% | |
mutate( | |
model = sample(c("logistic", "xgboost"), size = nrow(two_class_example), replace = TRUE) | |
) %>% | |
rename(`$@#!` = Class1, cls_2.5 = Class2) |
This file contains 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
smooth_ph_linear_pred <- function(formula, data, deg_free = 5, grid_size = 500) { | |
require(rlang) | |
rlang::is_installed("survival") | |
rlang::is_installed("ggplot2") | |
rlang::is_installed("splines2") | |
rlang::is_installed("cli") | |
require(ggplot2) | |
# check 1 pred and continuous | |
pred_sym <- rlang::f_rhs(formula) |
This file contains 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
# pak::pak(c("tidymodels/finetune@nested"), ask = FALSE) | |
library(tidymodels) | |
library(finetune) | |
library(rlang) | |
library(sfd) | |
library(doMC) | |
# ------------------------------------------------------------------------------ | |
tidymodels_prefer() |
This file contains 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
library(tidymodels) | |
library(doMC) | |
# ------------------------------------------------------------------------------ | |
tidymodels_prefer() | |
theme_set(theme_bw()) | |
options(pillar.advice = FALSE, pillar.min_title_chars = Inf) | |
registerDoMC(cores = parallel::detectCores()) |
This file contains 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
# Allow fuser functions to work in tidymodels | |
# See https://stackoverflow.com/questions/75871678/how-can-i-pass-an-extra-variable-to-a-tidymodels-fit-function | |
# Create a function that can parse a formula that uses a special (non-existant) | |
# `groups()` function. This returns a list of character vectors that has the | |
# columns and their roles based on the formula. It works with '.'. | |
fuser_variables <- function(f, data) { | |
cl <- match.call() | |
trms <- terms(f, data = data, specials = "groups") |
This file contains 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
extract_code <- function(file) { | |
# TODO we could put in an argument for the pattern | |
# or something more sophisticated... | |
target <- tempfile() | |
knitr::purl(file, output = target, quiet = TRUE) | |
code <- readLines(target) | |
code <- gsub("^##.*", "", code) | |
r_file <- gsub("[Rq]md$", "R", file) | |
writeLines(code, r_file) | |
invisible(TRUE) |
This file contains 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
#' Check to see if a repo has remote dependencies. | |
#' @param repos A character vector of repos to query (e.g. `tidyverse/dplyr`). | |
#' @param hard_depend Should only depends and imports be included in the query. | |
#' Using `FALSE` will include suggests and others. | |
#' @details Packages listed in `Config/Needs/*` will not be returned. | |
#' Requires dplyr, pak, and purrr. | |
#' @return A tibble with columns for the repo and any github repos that are | |
#' listed as dependencies. | |
#' @examples | |
#' tests <- paste0("tidymodels/", c("broom", "parsnip", "recipes")) |
This file contains 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
library(tidymodels) | |
tidymodels_prefer() | |
theme_set(theme_bw()) | |
library(doMC) | |
registerDoMC(cores = 20) | |
# ------------------------------------------------------------------------------ | |
data(ad_data) |
This file contains 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
library(tidymodels) | |
library(rules) | |
tidymodels_prefer() | |
theme_set(theme_bw()) | |
library(doMC) | |
registerDoMC(cores = 20) | |
# ------------------------------------------------------------------------------ |
This file contains 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
suppressPackageStartupMessages(library(tidymodels)) | |
library(furrr) | |
plan(multisession, workers = 20) | |
data(cells) | |
set.seed(1) | |
split <- initial_split(cells, prop = .95) | |
cell_train <- training(split) |
NewerOlder