Skip to content

Instantly share code, notes, and snippets.

from edsl import QuestionList, ScenarioList, QuestionFreeText
import random
q = QuestionList(question_text = "Generate a list of 10 fruits", question_name = "fruits")
fruits = q()
def list_to_pref(items):
return " > ".join(items)
preferences = [list_to_pref(random.sample(fruits, len(fruits))) for _ in range(20)]
@johnjosephhorton
johnjosephhorton / student_sample_plot.R
Created February 8, 2025 01:22
Plot of the student sample
library(ggplot2)
library(dplyr)
library(tidyr)
library(gridExtra)
library(purrr)
# Function to compute medians and bootstrap CIs for a single tau value
get_medians <- function(data, simtot = 150, tau = 0.5) {
# Data without errors
data0 <- subset(data, all_errors == 0)
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "pip",
# "edsl @ git+https://github.com/expectedparrot/edsl.git@improved_report",
# ]
# ///
from textwrap import dedent
from edsl import QuestionFreeText, QuestionList, Agent
@johnjosephhorton
johnjosephhorton / grid_image.py
Created July 11, 2025 00:26
Tool for applying a grid to a PNG and labeling.
#!/usr/bin/env python3
"""
Grid Image Tool
Adds red horizontal and vertical lines to an image and labels each cell with letters.
Dependencies are declared inline for use with uv run.
Usage: uv run grid_image.py input.png --num-vertical 5 --num-horizontal 3
"""
@johnjosephhorton
johnjosephhorton / score.py
Created July 11, 2025 16:00
Implement a startup scoring system
from edsl import (
QuestionLinearScale,
ScenarioList,
Scenario,
Scenario,
Survey,
QuestionCompute,
)
@johnjosephhorton
johnjosephhorton / claude_code_written_analysis.py
Created October 21, 2025 19:33
Analyze a customer call transcript, as macro
import textwrap
from edsl.agents import Agent
from edsl.questions import (
QuestionFreeText,
QuestionLinearScale,
QuestionMultipleChoice,
)
from edsl.surveys import Survey
from edsl.macros import Macro