This file contains hidden or 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(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) |
This file contains hidden or 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
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)] |
This file contains hidden or 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
import textwrap | |
from edsl import QuestionMultipleChoice, Scenario | |
pay_offs = { | |
('red', 'red'):(1, -1), | |
('red', 'black'):(-1, 1), | |
('black', 'red'):(1, -1), | |
('black', 'black'): (-1, 1) | |
} | |
instructions = textwrap.dedent("""\ |
This file contains hidden or 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
""" | |
This gives some examples of how to use SQL and ggplot2 together in the Results class. | |
Note that rather than call LLMs, we are created an agent with a direct-answering capability. | |
After we create the agent, we create a `Results` object. | |
""" | |
import random | |
from edsl import QuestionNumerical, QuestionFreeText | |
from edsl import Agent |
This file contains hidden or 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
(venv) john@Johns-MacBook-Air agent_dialog % python -i AgentDialog.py | |
John: Hello Robin, I was thinking about going hiking today. Are you interested in joining me? | |
Robin: Hello John, hiking sounds like a great idea! I was actually hoping to go biking today, but a hike could be a nice compromise. Where were you thinking of hiking? | |
John: That's great to hear, Robin! I was thinking of hitting the trails at the Green Mountain Forest. There are some fantastic views and the terrain is just right for a good day's hike. How does that sound to you? | |
Robin: Green Mountain Forest sounds wonderful, John! I've heard the trails there are quite scenic. And you're right, it seems like the perfect place for a good day's hike. Let's do it! What time were you thinking of starting? | |
John: I'm glad you're on board, Robin! How about we start early to make the most of the day? Meeting at 8:00 AM would give us plenty of time to enjoy the trails. Does that work for you? | |
Robin: That sounds like a plan, John! Meeting at 8:00 AM works for |
This file contains hidden or 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
import aiohttp | |
import asyncio | |
http_status_codes = { | |
100: "Continue", | |
101: "Switching Protocols", | |
102: "Processing", | |
200: "OK", | |
201: "Created", | |
202: "Accepted", |
This file contains hidden or 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
from jinja2 import Template | |
from jinja2 import Environment, meta | |
class Question: | |
"""This class reprsents a question sent to an LLM (or human). | |
It uses the jinja2 templating language to generate the prompt. | |
For details on jinja2: https://jinja.palletsprojects.com/en/3.0.x/ | |
This templating language gives us lots of flexibility in how we ask questions. | |
""" | |
def __init__(self, template_string): |
This file contains hidden or 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
# Find all your R files & get just the package names, uniquely | |
find ../analysis/ -name *R -print0 | xargs -0 grep -h 'library*' | sed 's/library//g' | sed 's/#//g' | sed 's/ //g' | sort | uniq|\ | |
sed 's/(//g' | sed 's/)//g' > package_list.txt | |
# Install each package | |
cat package_list.txt | xargs -I {} Rscript -e 'install.packages("{}")' |
This file contains hidden or 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
#!/usr/bin/Rscript --vanilla | |
suppressPackageStartupMessages({ | |
library(magrittr) | |
library(dplyr) | |
library(foreign) | |
library(plm) | |
library(reshape2) | |
library(stargazer) | |
library(ggplot2) |
This file contains hidden or 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
project_name = hot_towel | |
ts := $(shell /bin/date "+%Y-%m-%d---%H-%M-%S") | |
params = | |
# DONE | |
params += params_exp_details.tex | |
params_exp_details.tex: ../analysis/params_exp_details.R | |
cd ../analysis && ./params_exp_details.R |
NewerOlder