The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
The llm_interpret() function integrates Large Language
Model (LLM) capabilities to automatically interpret epidemiological
visualisations and data. This powerful feature can generate insights,
identify patterns, and provide contextual analysis of your charts and
datasets, making it valuable for surveillance reporting and data
exploration.
Before using llm_interpret(), set provider-agnostic
environment variables. These are what the function reads.
Set these in your .Renviron file or R session:
# Provider: one of "openai", "gemini", or "anthropic"
Sys.setenv(LLM_PROVIDER = "openai")
# API key for the chosen provider
Sys.setenv(LLM_API_KEY = "your-api-key")
# Model for the chosen provider (examples)
Sys.setenv(LLM_MODEL = "gpt-4.1-nano") # OpenAI
# Sys.setenv(LLM_MODEL = "gemini-2.5-flash-lite") # Google
# Sys.setenv(LLM_MODEL = "claude-sonnet-4-20250514") # AnthropicThis example demonstrates how to use LLM interpretation to analy#sze an epidemic curve and generate insights about temporal patterns.
# Create an epidemic curve for interpretation
epi_data <- epiviz::lab_data %>%
filter(
organism_species_name == "STAPHYLOCOCCUS AUREUS",
specimen_date >= as.Date("2023-01-01"),
specimen_date <= as.Date("2023-12-31")
)
# Create the epidemic curve
epi_curve_plot <- epi_curve(
dynamic = FALSE,
params = list(
df = epi_data,
date_var = "specimen_date",
date_start = "2023-01-01",
date_end = "2023-12-31",
time_period = "year_month",
fill_colours = "#007C91",
chart_title = "Monthly Staph aureus detections (2023)",
x_axis_title = "Month",
y_axis_title = "Number of detections"
)
)
# Display the plot
print(epi_curve_plot)# Use LLM to interpret the epidemic curve
interpretation <- llm_interpret(
input = epi_curve_plot,
word_limit = 120,
prompt_extension = "Analyse this epidemic curve and identify notable patterns, trends, or anomalies. Focus on seasonal patterns and potential outbreak periods."
)
# Display the interpretation
cat("LLM Interpretation:\n")
cat(interpretation)Interpretation: The LLM will analyse the epidemic curve and provide insights about temporal patterns, seasonal trends, and any notable peaks or anomalies in the data.
This example shows how to provide a custom prompt to guide the LLM’s analysis toward specific epidemiological concerns.
# Create an age-sex pyramid for interpretation
pyramid_data <- epiviz::lab_data %>%
filter(
organism_species_name == "KLEBSIELLA PNEUMONIAE",
specimen_date >= as.Date("2023-01-01"),
specimen_date <= as.Date("2023-06-30")
)
# Create the age-sex pyramid
pyramid_plot <- age_sex_pyramid(
dynamic = FALSE,
params = list(
df = pyramid_data,
var_map = list(dob_var = "date_of_birth", sex_var = "sex"),
grouped = FALSE,
mf_colours = c("#440154", "#2196F3"),
x_axis_title = "Number of cases",
y_axis_title = "Age group (years)",
legend_title = "Klebsiella pneumoniae cases by age and sex (H1 2023)"
)
)
# Display the plot
print(pyramid_plot)# Use LLM with a custom prompt focused on public health implications
custom_interpretation <- llm_interpret(
input = pyramid_plot,
word_limit = 150,
prompt_extension = "As a public health epidemiologist, analyze this age-sex pyramid for Klebsiella pneumoniae cases. Identify which demographic groups are most at risk, discuss potential risk factors, and suggest targeted prevention strategies. Consider healthcare-associated infections and community transmission patterns."
)
# Display the custom interpretation
cat("Custom Epidemiological Analysis:\n")
cat(custom_interpretation)Interpretation: The LLM will provide a detailed epidemiological analysis focusing on risk groups, potential transmission patterns, and public health recommendations based on the demographic distribution shown in the pyramid.
.Renviron fileAPI Key Not Found: Ensure your environment variables are properly set and accessible to R.
Rate Limiting: If you hit rate limits, implement delays between requests or use different API keys.
Model Not Available: Check that your specified model is available in your API plan.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.