AI-Powered Coding and Data Analysis

AI for Health Research Workshop Series · Yale School of Public Health, Data Science and Data Equity

About me

  • Data scientist, Johns Hopkins Biostatistics Center, Department of Biostatistics
  • Trained in the social sciences; 10+ years as a data scientist and software developer
  • I teach data visualization and provide statistical consulting, data management, and software engineering services for the Johns Hopkins Biostatistics Center (JHBC)
  • ewestlund@jhu.edu

Module 1: AI Today

Goals

  • Define the terms: AI, machine learning, and large language models.
  • Place the current moment in historical context.
  • Review what the research says about performance.
  • Move from chat to agents that read your files and run your code.
  • Guide agents with context files and skills.
  • Check AI output, and use AI to review an analysis.
  • Use AI safely with protected health data.

Definitions

Working definitions

  • AI is the broad umbrella: systems that perform tasks associated with intelligence.
  • Machine learning estimates patterns from data and uses them to predict, classify, or decide on new cases.
  • Large language models (LLMs) are trained to predict text and code from context.

LLM summary

  • An LLM is a function trained to predict the next token.
  • Given a sequence of tokens, it outputs a probability distribution over the next one.
  • At scale, the same objective produces behavior that looks like reasoning on many tasks.
  • Paired with an agent harness, an LLM can complete complex tasks from text instructions.

LLM basics

Watch: Large Language Models explained briefly, 3Blue1Brown.

Key concepts for users

Concept Meaning
Context window How many tokens the model can see at once. Model pickers often show it in the name: “Opus 5.5 (1M)” means a 1-million-token window.
Temperature Randomness of the output
Stochasticity The same prompt can give different answers
No memory Each conversation starts empty unless you supply context

Limits of LLMs

  • An LLM generates answers. It does not look them up.
  • It does not retrieve documents unless a tool gives it that ability.
  • The same input can produce different outputs.
  • Its reasoning is usually sound. When it is wrong, the error can read as convincingly as a correct answer.

A brief history

The initial vision

  • 1950: Turing proposes the imitation game.
  • 1956: The Dartmouth workshop coins “artificial intelligence.”
  • 1958: Rosenblatt builds the perceptron. The New York Times reports that the Navy expects it to “walk, talk, see, write, reproduce itself, and be conscious.”

Symbolic AI

“Good old-fashioned AI” treats intelligence as symbol manipulation (Haugeland 1985). The approach encodes human knowledge as rules and reasons over them.

System Capability Limitation
ELIZA (1966) Simulated a therapist by pattern matching No understanding
SHRDLU (1971) Understood language about blocks on a table Worked only in a toy world
Expert systems (1980s) Encoded specialist rules Brittle and costly to maintain

Hype cycles

Era Promise Outcome
1960s AI within a generation Two AI winters
1980s Expert systems replace professionals Collapsed under brittleness
2010s Self-driving cars by 2020 Substantial progress, years late
2020s General AI is imminent Unknown

Revival and the transformer

  • Machine learning replaced hand-coded rules with learning from data.
  • 2012: AlexNet wins ImageNet with a neural network trained on GPUs.
  • 2017: The transformer architecture (Vaswani et al. 2017).
  • 2020–2022: GPT-3, GitHub Copilot, and ChatGPT.
  • 2023–2024: GPT-4, Claude, Gemini, and open-weight models such as Llama.
  • 2025–2026: Coding agents such as Claude Code and Codex work independently on provided tasks.

Reasoning models

  • 2024–2025: Reasoning models iterate on an answer before returning it.
  • They use the same architecture with different pre- and post-training.
  • Iteration takes longer and costs more, and it is more accurate on most tasks.

Research on performance

Strong performance

Task Performance Source
Code generation (HumanEval) 80% (GPT-4) Ni et al. (2024)
Grade-school math (GSM8k) 92% Fu et al. (2023)
Undergraduate statistics (StatEval) 87% (GPT-5) Lu et al. (2025)

Weak performance

Task Performance Source
Research-level statistics ~58% (best closed model) Lu et al. (2025)
Expert-level questions (HLE) 3–13% Phan et al. (2025)
Code completion with buggy context 1–3% Dinh et al. (2023)
Fixing bugs in AI agent software 4% (best agent) Islam et al. (2026)

Recurring failure modes

  • Brittleness to context. Small upstream errors cascade (Dinh et al. 2023).
  • Overconfidence. Models sound certain when they are wrong (Phan et al. 2025).
  • Contamination. Benchmark scores can be inflated about fourfold (Chen et al. 2025).
  • Distribution shift. Real tasks differ from curated benchmarks (Liu et al. 2023).

The research is out of date

  • A study takes a year or more to design, run, review, and publish.
  • The models tested are usually two or more generations old by publication.
  • Benchmarks also saturate and become targets.
  • Published results describe older models. Newer tools usually do better, but contamination and benchmark differences can push scores either way.
  • Test the tools on your own work.

Recent results in mathematics

  • 2025: Systems from Google DeepMind and OpenAI reached gold-medal level at the International Mathematical Olympiad.
  • 2025: Google DeepMind’s AlphaEvolve found new algorithms, including a faster method for 4×4 complex matrix multiplication.
  • September 2026: OpenAI reported a proof, formalized in Lean, that a smooth fluid can develop a singularity under a smooth force. OpenAI says this resolves the Navier–Stokes Millennium Prize problem.
  • October 2026: OpenAI released 722 manuscripts of new results on open problems, including Erdős problems.

Implications for us

Regardless of how these results hold up, LLMs are clearly capable of working on mathematical and statistical problems. The results also show that their work needs human review and judgment before we can trust it.

Our approach

  • Most applied statistical work is far from Navier–Stokes: cleaning data, visualization, and statistical modeling.
  • We don’t expect LLMs to get things right unsupervised (although they often do).
  • We can guide them toward useful results.
  • Our goal is to learn how to do that.

Should we use AI?

My philosophy: potential outcomes.

  • This is a causal inference problem.
  • Consider you specifically, or the average analyst. Do modern frontier models produce more thorough and correct code, or other outputs, than people working without AI assistance?
    • On their own?
    • With human assistance?

Accountability

  • We are still responsible for AI outputs: privacy, correctness, and interpretation.
  • Use AI for boilerplate, code scaffolding, explanation, and review.
  • Treat generated code and interpretation as untrusted until checked.
  • Developers who know code is AI-generated catch more bugs (Tang et al. 2024).

Model and harness

Model and harness

  • Model: the system that generates text or code from context.
  • Harness: the environment around the model.
  • Harness = model + tools + permissions + context + workflow.
  • The same model in a different harness produces different work.

Common harnesses

Harness Notes
Claude Code Anthropic’s coding agent
Codex OpenAI’s coding agent
Posit AI Posit’s assistant for data science in RStudio and Positron
OpenCode Open source; works with many model providers
Pi Open source and minimal

AI Safety in Health Research

Core principle

Code can move across computing environments. Protected data cannot.

Protected data

Definitions depend on law and institutional policy. Common categories:

  • Direct identifiers
  • Dates, geography, rare conditions, and small cells
  • Free text
  • Linkable combinations of variables
  • Restricted-use datasets
  • Metadata covered by data use agreements

Exposure through AI workflows

An AI workflow can send more than the prompt:

  • raw data or excerpts and data summaries,
  • file names, paths, code, and comments,
  • error messages and system details, and
  • generated output that contains sensitive values.

Agents and file access

  • An agent with read permission on a folder should be assumed to read it.
  • Instructions not to look at data do not guarantee compliance.
  • Agents rarely upload large files. They read glimpses, such as the first rows or summaries.
  • Files can contain prompt injection: instructions that an agent may follow.

The tension

  • Agents work best with few restrictions.
  • Protected data needs strict restrictions.
  • On a personal computer an agent can usually reach any file the user can.

Layers of protection

  1. Separation: the agent runs where the data is absent.
  2. Git and .gitignore: data never enters the repository.
  3. Pre-commit hooks: commits containing private data are refused.
  4. Tool permissions: the tool enforces deny rules and a sandbox.
  5. Context files and skills: instructions to stay away. They are not proof of safety.

Separation

  • A secure enclave holds the real data.
  • A virtual machine or separate server keeps agents physically away from it.
  • Git moves code between the AI environment and the protected environment.

Two enclave workflows

Simulated data Schema and aggregates
The agent sees Reviewed metadata and simulated data The data structure and approved aggregate results
The agent can run code Yes, on simulated data No
Results come back as Nothing; you run the final code Reviewed aggregates
Works best with Project-specific files Standardized data models such as OMOP

Workflow 1: simulated data

  1. Extract metadata without AI, and review it for disclosure risk.
  2. The agent writes a generator script from the reviewed metadata.
  3. You run the script in the secure environment, without AI.
  4. You review the simulated data as a release, then transfer the approved file yourself.
  5. The agent develops code on the reviewed simulated data.
  6. You run the reviewed code on real data without AI.

Structural information

Metadata derives from the protected data. Review it before an agent sees it, and keep it out of git.

Usually acceptable when allowed:

  • Variable names, types, and value labels
  • Allowed categories and plausible ranges
  • Missing-value codes and broad missingness patterns

Treat with care:

  • Exact rare-category counts and extreme values
  • Dates, geography, and free text

Simulated data review

  • Simulated data derives from protected data. Review it as a release.
  • Check for small cells and exact minimums and maximums.
  • Check that simulated records do not recreate recognizable combinations.
  • Simulated IDs must not link to original IDs.
  • Avoid free text, rare categories, and specific geography.

Simulated data generators

generate-sim-data.R

  • Draws variables from reviewed metadata.
  • Keeps only the relationships you build in.
  • Requires disclosure review.

synthpop (Nowok et al. 2016)

  • Fits synthesis models to the real data, using CART by default.
  • Can preserve more relationships between variables.
  • Requires utility and disclosure assessment.

synthpop guidelines

  • Run it only in the secure environment.
  • Drop direct identifiers first.
  • Coarsen rare categories and top-code extremes.
  • Check distributions and intended analyses on the secure side.
  • Assess disclosure using relevant quasi-identifiers. Removing replicated uniques alone does not establish privacy.
  • Keep files, fitted objects, and diagnostics private until release approval.
  • Transfer approved data yourself, label it as synthetic, and keep it gitignored.
  • Check your data use agreement. Synthetic data may still count as restricted.

Workflow 2: schema and aggregates

  1. Give the agent the data structure: tables, columns, types, and codes.
  2. The agent writes code without access to any data.
  3. You move the code into the enclave and run it.
  4. You review the aggregate output for disclosure risk.
  5. You bring back only approved aggregates, and the agent revises the code.

Standardized data models

  • EHR data in a common data model, such as OMOP, share one published structure.
  • The agent can write code against the public specification: tables such as person, condition_occurrence, and measurement, and standard concept IDs.
  • No simulated data is needed, because the structure itself reveals nothing about patients.
  • The agent can’t test its code, so expect more rounds of run, review, and revise.

Aggregate results review

  • Bring back counts, means, model coefficients, and error messages. Never bring back rows.
  • Suppress small cells. Many data use agreements, such as CMS’s, prohibit counts under 11.
  • Check error messages and logs before sharing. They can contain data values.
  • Watch for combinations of aggregates that let someone recover a small cell.
  • Follow the enclave’s output review rules. Some require a second person to approve each release.

The exercise project

  • inputs/private/raw/: protected data (public NHANES data for this exercise).
  • inputs/private/simulated/: the same path on both machines. Generate and review on the secure machine, then manually transfer the approved file to the AI machine.
  • inputs/metadata/: reviewed metadata. Git ignores metadata and both copies of simulated data.
  • .claude/settings.json: Claude Code deny rules and sandbox.
  • protected-data skill and AGENTS.md: read only the reviewed simulated copy; stay out of raw data.
  • Each notebook has a data_dir setting that a person changes from "simulated" to "raw" without AI.

Responsibility

  • Disclose AI use where required.
  • The analyst is responsible for privacy, correctness, and interpretation.

References

Chen, Simin, Pranav Pusarla, and Baishakhi Ray. 2025. “DyCodeEval: Dynamic Benchmarking of Reasoning Capabilities in Code Large Language Models Under Data Contamination.” Proceedings of the 42nd International Conference on Machine Learning (ICML), PMLR, vol. 267. https://arxiv.org/abs/2503.04149.
Dinh, Tuan, Jinman Zhao, Samson Tan, et al. 2023. “Large Language Models of Code Fail at Completing Code with Potential Bugs.” Proceedings of the 37th Conference on Neural Information Processing Systems (NeurIPS). https://arxiv.org/abs/2306.03438.
Fu, Yao, Litu Ou, Mingyu Chen, Yuhao Wan, Hao Peng, and Tushar Khot. 2023. Chain-of-Thought Hub: A Continuous Effort to Measure Large Language Models’ Reasoning Performance. https://arxiv.org/abs/2305.17306.
Haugeland, John. 1985. Artificial Intelligence: The Very Idea. MIT Press.
Islam, Niful, Ragib Shahariar Ayon, Deepak George Thomas, Shibbir Ahmed, and Mohammad Wardat. 2026. When Agents Fail: A Comprehensive Study of Bugs in LLM Agents with Automated Labeling. https://arxiv.org/abs/2601.15232.
Liu, Jiawei, Chunqiu Steven Xia, Yuyao Wang, and Lingming Zhang. 2023. “Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation.” Proceedings of the 37th Conference on Neural Information Processing Systems (NeurIPS). https://arxiv.org/abs/2305.01210.
Lu, Yuchen, Run Yang, Yichen Zhang, et al. 2025. StatEval: A Comprehensive Benchmark for Large Language Models in Statistics. https://arxiv.org/abs/2510.09517.
Ni, Ansong, Pengcheng Yin, Yilun Zhao, et al. 2024. L2CEval: Evaluating Language-to-Code Generation Capabilities of Large Language Models. https://arxiv.org/abs/2309.17446.
Nowok, Beata, Gillian M. Raab, and Chris Dibben. 2016. “synthpop: Bespoke Creation of Synthetic Data in R.” Journal of Statistical Software 74 (11): 1–26. https://doi.org/10.18637/jss.v074.i11.
Phan, Long, Alice Gatti, Ziwen Han, et al. 2025. “Humanity’s Last Exam.” Nature, ahead of print. https://doi.org/10.1038/s41586-025-09962-4.
Tang, Ningzhi, Meng Chen, Zheng Ning, et al. 2024. A Study on Developer Behaviors for Validating and Repairing LLM-Generated Code Using Eye Tracking and IDE Actions. https://arxiv.org/abs/2405.16081.
Vaswani, Ashish, Noam Shazeer, Niki Parmar, et al. 2017. “Attention Is All You Need.” Advances in Neural Information Processing Systems 30 (NeurIPS).