Skip to content

Instantly share code, notes, and snippets.

View simonpcouch's full-sized avatar

Simon P. Couch simonpcouch

View GitHub Profile

A log of a problematic run of a prefixing (roxygen) pal in Positron using these changes. Search for the first instance of key_get()modifyRange() attempts to add a "#' @" in its sixth line, but the rstudioapi::getActiveDocumentContext() call immediately after it doesn't find it (and instead finds the line that follows what should be there) and instead picks up key_get <- ..., which is erroneously replaced in the next iteration.

io$last_run

$before
$before$row_start_end
[1] 1 1

$before$before

min_grid() with submodels and postprocessors

library(tidymodels)
library(tailor)

Consider the following regular grid:

@simonpcouch
simonpcouch / errortester-prefix.md
Created October 21, 2024 19:15
A pal prompt for testing error-raising code

You are a terse assistant designed to help R package developers test their error-raising code. Given some function definitions (and possibly even the documentation preceding them), reply with a testthat unit test that triggers each of the errors, warnings, and messages raised in the function and captures them with a snapshot test. Respond with only the testing code, no backticks or newlines around the response, though feel free to intersperse newlines within the function call as needed, per tidy style.

# given:
some_fn <- function(data = NULL, something = FALSE) {
  if (is.null(data) && something) {
    cli::cli_abort("{.arg something} must be {.code FALSE} if {.arg data} is {.code NULL}.")
  }
}
@simonpcouch
simonpcouch / summarize-prefix.md
Last active October 15, 2024 16:06
An example pal prompt, hosted as a GitHub Gist.

Given some text, summarize it to 3-5 words. Respond with only the summary, no backticks or newlines around the response and no punctuation.

Splitting Data With add_tailor(method)

This gist whittles down discussion (with myself) in tidymodels/workflows#233.

The add_tailor(method) argument supplies information about how the data supplied to fit.workflow() came to be. Its currently supplied as the class of the rsplit object from which data arose, i.e. "mc_split".

tune does not need to use add_tailor(method), as it has all of the information it needs in the split itself to make an inner split, and interfaces with the .fit_*() helpers directly instead of fit.workflow(). workflows, in fit.workflow(), does not actually have all the information it needs between fit.workflow(data) and add_tailor(method) unless the data arose from a random sample. So, in short: tune does not use method and workflows can't do anything with it, as it is currently

@simonpcouch
simonpcouch / oracle-connect-positron.md
Created July 17, 2024 14:27
Error logs for Oracle Connection in Positron
2024-07-17 09:18:25.207 [info] [Positron] Connecting to R 4.3.3 kernel (pid 66302)
2024-07-17 09:18:25.207 [info] [Positron] Streaming log file: /var/folders/6c/w21prsj167b_x82q4_s45t340000gn/T/kernel-oQwqsE/kernel.log
2024-07-17 09:18:25.207 [info] [Positron] Connecting to kernel sockets defined in /var/folders/6c/w21prsj167b_x82q4_s45t340000gn/T/kernel-oQwqsE/connection.json...
2024-07-17 09:18:25.207 [info] [Positron] Control socket created (count = 1)
2024-07-17 09:18:25.207 [info] [Positron] Shell socket created (count = 2)
2024-07-17 09:18:25.207 [info] [Positron] Stdin socket created (count = 3)
2024-07-17 09:18:25.207 [info] [Positron] I/O socket created (count = 4)
2024-07-17 09:18:25.207 [info] [Positron] Heartbeat socket created (count = 5)

Supporting older R versions in broom

In preparing the most recent release of the broom package, I’ve run into some headaches related to the large number of Suggests that make it very difficult to support older versions of R. I’m considering revising the package’s approach so managing dependencies such that broom can “support” a package’s output with including it in Suggests.

Setup

Data usage when post-processing workflows

Simon Couch

# with tidymodels/container#12 and tidymodels/workflows#225
library(tidymodels)
── Attaching packages ────────────────────────────────────── tidymodels 1.2.0 ──
@simonpcouch
simonpcouch / fair_ml_timeline.md
Last active November 29, 2023 19:32
Timeline for machine learning fairness implementations in tidymodels

Fair machine learning with tidymodels: timeline

For context on this document, see the fairness reading group summary.

Releases, round 1: Assessment and critique

The first component of fairness metrics functionality, assessment, is completed and merged into the main dev versions of tidymodels.

@simonpcouch
simonpcouch / arguments_with_submodels.md
Created October 11, 2023 18:52
tidymodels arguments with submodels
library(tidyverse)
library(parsnip)
x <- lapply(parsnip:::extensions(), require, character.only = TRUE)
#> Loading required package: baguette
#> Loading required package: censored
#> Loading required package: survival
#> Loading required package: discrim
#> Loading required package: multilevelmod
#> Loading required package: plsmod