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
# https://twitter.com/topepos/status/1024001039278714880 | |
topic_gen <- function(x) { | |
require(glue) | |
prefix <- c("adaptive", "auto-regressive", "regularized", "multivariate", | |
"semiparametric", "Bayesian", "elastic", "variational", "robust", | |
"nonparametric", "flexible", "overdispersed", "latent", | |
"interpretable", "dynamic", "interval censored", "novel") | |
mod <- c("logistic regression", "Cox model", "mixed effects model", |
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
--- | |
title: "A simple Test Example" | |
output: html_document | |
--- | |
```{r setup, include = FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
library(testthat) | |
library(sessioninfo) | |
options(width = 100) |
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
# _Prototype_ code to find the minimum grid that should be fit for models. This | |
# exploits the fact that some models can evaluate extra sub-models from the same | |
# object. | |
# devtools::install_github("tidymodels/parsnip") | |
# devtools::install_github("tidymodels/dials") | |
library(tidymodels) | |
#> ── Attaching packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────── tidymodels 0.0.2 ── | |
#> ✔ broom 0.5.1 ✔ purrr 0.3.2 |
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
# A prototype mechanism to collect the tunable parameters and their sources. It | |
# also allows for parameter with the same to be tuned. For example, you might | |
# model some variables with a spline but want to allow for different degrees | |
# of freedom by adding a different `step_ns()` for each variable. This interface | |
# allows the user to add an annotation for the parameter so that we can tell the | |
# different parameters apart. | |
# Limitations: | |
# - Currently, only one varying value is allowed per argument. For example, if | |
# some argument had a length two vector as its format, you can do something |
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
product review score | |
B001E4KFG0 I have bought several of the Vitality canned dog food products and have found them all to be of good quality. The product looks more like a stew than a processed meat and it smells better. My Labrador is finicky and she appreciates this product better than most. great | |
B00813GRG4 "Product arrived labeled as Jumbo Salted Peanuts...the peanuts were actually small sized unsalted. Not sure if this was an error or if the vendor intended to represent the product as ""Jumbo""." other | |
B000LQOCH0 "This is a confection that has been around a few centuries. It is a light, pillowy citrus gelatin with nuts - in this case Filberts. And it is cut into tiny squares and then liberally coated with powdered sugar. And it is a tiny mouthful of heaven. Not too chewy, and very flavorful. I highly recommend this yummy treat. If you are familiar with the story of C.S. Lewis' ""The Lion, The Witch, and The Wardrobe"" - this is the treat that seduces Edmund into selling out his Brother and Sisters |
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(tune) | |
library(discrim) | |
library(klaR) | |
library(gganimate) | |
options(width = 100) | |
theme_set(theme_bw()) | |
data("parabolic", package = "rsample") |
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
finalize_model <- function(x, param) { | |
if (!inherits(x, "model_spec")) { | |
stop("`x` should be a parsnip model specification.") | |
} | |
# check for nrow > 1 and tibble/list | |
pset <- parameters(x) | |
if (tibble::is_tibble(param)) { | |
param <- as.list(param) | |
} |
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
get_default_values <- function(model, engine, mode) { | |
eng <- engine | |
mod_args <- | |
parsnip::get_from_env(paste0(model, "_args")) %>% | |
dplyr::filter(engine == eng) | |
model_fun <- | |
parsnip::get_from_env(paste0(model, "_fit")) %>% | |
dplyr::filter(engine == eng) %>% | |
dplyr::mutate(pkg = purrr::map_chr(value, ~ .x$func["pkg"]), | |
fun = purrr::map_chr(value, ~ .x$func["fun"])) |
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(shiny) | |
library(ggplot2) | |
library(dplyr) | |
library(yardstick) | |
theme_set(theme_bw()) | |
n <- 1000 | |
set.seed(124254) |
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(nycflights13) | |
set.seed(25213) | |
flight_data <- | |
flights %>% | |
mutate( | |
delay = ifelse(arr_delay >= 30, "late", "on_time"), | |
delay = factor(delay), | |
date = as.Date(time_hour) |
OlderNewer