Skip to content

Instantly share code, notes, and snippets.

View farach's full-sized avatar
🏠
Working from home

Alex Farach farach

🏠
Working from home
View GitHub Profile
@farach
farach / ai_firm_config_simulation.R
Created January 4, 2025 00:27
This R script uses gganimate to simulate and visualize how firms adapt their configurations—single-layer or two-layer, human or AI—as AI knowledge levels ( 𝑧 𝐴 𝐼 z AI ​ ) increase. Inspired by the Artificial Intelligence in the Knowledge Economy model, it calculates profits for each setup and dynamically displays the best configurations over tim…
library(tidyverse)
library(gganimate)
# Parameters
h <- 0.02 # Time cost per worker for the solver
r <- 2 # Rental rate for one unit of compute
worker_grid <- seq(0.2, 0.8, by = 0.1) # Range of human worker knowledge
solver_grid <- seq(0.3, 1.0, by = 0.1) # Range of human solver knowledge
zAI_values <- seq(0.25, 0.95, by = 0.05) # Range of AI knowledge levels
# This R script generates synthetic data representing job functions in various languages, translates them to English using a local language model, and detects the original language. The output includes the original job function, the translated job function, and the detected language, and is saved to a CSV file for further use.
# Load necessary libraries
library(httr)
library(jsonlite)
library(textcat)
library(tidyverse)
library(glue)
library(here)
# Load necessary libraries
library(janitor)
library(httr)
library(jsonlite)
library(tidyverse)
library(furrr)
library(stringr)
library(glue)
# Setup parallel processing
# Instructions:
# - Download LM Studio
# - Download Phi-3 Model (within LM Studio)
# - Load the model into LM Studio
# - Start the Local Server (instructions here: https://lmstudio.ai/docs/local-server)
# Load necessary libraries
library(httr)
library(jsonlite)
library(tidyverse)
import pandas as pd
def pep_talk ():
pep_csv = pd.read_csv(
"https://raw.githubusercontent.com/farach/pep/main/pep_talk.csv",
encoding = 'unicode_escape'
)
pepText = list(
map(
pep_talk <- function() {
read.csv("https://raw.githubusercontent.com/farach/pep/main/pep_talk.csv") |>
purrr::map_chr(~ sample(.x, 1)) |>
glue::glue_collapse(sep = " ")
}
library(fredr)
library(tidyverse)
library(geofacet)
library(ggrepel)
library(ggtext)
set.seed(42) # For reproducibility
# Prepare state series IDs
state_ids <- c(
@farach
farach / glassdoor_scrape_and_spacy.Rmd
Last active October 17, 2021 21:12
Web scraping glassdoor review, using spacy for NLP, plotting evolution of reviews
---
title: "Using SpacyR on scraped glassdoor reviews"
author: "Alex Farach"
date: "10/17/2021"
output: html_document
---
```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(
@farach
farach / bruce_springsteen_music.R
Created September 13, 2021 00:19
Bruce Springsteen music analysis plot
library(spotifyr)
library(tidyverse)
library(lubridate)
library(glue)
library(geniusr)
library(rvest)
library(tidytext)
# Create a ggplot2 theme
theme_alex <- function() {
library(tidyverse)
library(tidytext)
library(vader)
library(glue)
theme_alex <- function() {
font <- "Arial"
theme_minimal()
theme(
strip.text = element_text(