# ohdsi/patientlevelprediction architecture

> Architecture diagram of the GitHub repository ohdsi/patientlevelprediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ohdsi/patientlevelprediction
- Repository: https://github.com/ohdsi/patientlevelprediction

## Overview

PatientLevelPrediction is an R package for defining, training, and validating patient-level prediction models with OMOP-format observational healthcare data. The principal workflow runs from prediction-design choices and cohort-based data extraction through preprocessing and model fitting to validation and performance exploration. The README also documents multiple target/outcome combinations, external validation, learning curves, and interactive result viewing. Relationships are based on README capabilities and module names in the tree; source excerpts were unavailable, so detailed call ownership and wiring cannot be verified.

Main entry points: [`R/Fit.R`](https://github.com/ohdsi/patientlevelprediction/blob/main/R/Fit.R) (Model fitting), [`R/ExtractData.R`](https://github.com/ohdsi/patientlevelprediction/blob/main/R/ExtractData.R) (OMOP extraction), [`R/EvaluatePlp.R`](https://github.com/ohdsi/patientlevelprediction/blob/main/R/EvaluatePlp.R) (Performance evaluation), [`R/SaveLoadPlp.R`](https://github.com/ohdsi/patientlevelprediction/blob/main/R/SaveLoadPlp.R) (Saved results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_design["Study design and data"]
  node_design["Prediction design"]
  node_extract["OMOP extraction<br/>[ExtractData.R]"]
  node_covariates["Covariates"]
end

subgraph group_modeling["Model development"]
  node_preprocess["Preprocessing"]
  node_split["Data splitting<br/>[DataSplitting.R]"]
  node_features["Feature engineering"]
  node_fit["Model fitting<br/>[Fit.R]"]
  node_algorithms["Model algorithms<br/>[CyclopsModels.R]"]
  node_predict["Prediction<br/>[Predict.R]"]
end

subgraph group_validation["Validation and evaluation"]
  node_validate["External validation"]
  node_evaluate["Performance evaluation<br/>[EvaluatePlp.R]"]
  node_metrics["Performance summaries"]
  node_learning["Learning curves<br/>[LearningCurve.R]"]
end

subgraph group_results["Results and exploration"]
  node_results[("Saved results<br/>[SaveLoadPlp.R]")]
  node_viewer["Interactive viewer<br/>[ViewShinyPlp.R]"]
  node_plots["Performance plots<br/>[Plotting.R]"]
end

subgraph group_integration["Optional integrations"]
  node_python["Python ML"]
end

node_user(("Analyst"))
node_omop[("OMOP database")]

node_user -->|"defines problem"| node_design
node_design -->|"specifies extraction"| node_extract
node_extract -->|"reads cohorts and data"| node_omop
node_extract -->|"uses covariate settings"| node_covariates
node_extract -->|"provides prediction data"| node_preprocess
node_preprocess -->|"prepares data"| node_split
node_split -->|"supplies training data"| node_fit
node_fit -->|"applies feature engineering"| node_features
node_fit -->|"uses algorithms"| node_algorithms
node_fit -->|"produces model"| node_predict
node_predict -->|"provides predictions"| node_evaluate
node_validate -->|"evaluates predictions"| node_evaluate
node_evaluate -->|"summarizes performance"| node_metrics
node_fit -->|"supports learning curves"| node_learning
node_evaluate -->|"saves results"| node_results
node_results -->|"supplies results"| node_viewer
node_results -->|"supplies performance data"| node_plots
node_algorithms -.->|"uses when selected"| node_python

click node_design "https://github.com/ohdsi/patientlevelprediction/blob/main/R/PopulationSettings.R"
click node_extract "https://github.com/ohdsi/patientlevelprediction/blob/main/R/ExtractData.R"
click node_covariates "https://github.com/ohdsi/patientlevelprediction/blob/main/R/AdditionalCovariates.R"
click node_preprocess "https://github.com/ohdsi/patientlevelprediction/blob/main/R/PreprocessingData.R"
click node_split "https://github.com/ohdsi/patientlevelprediction/blob/main/R/DataSplitting.R"
click node_features "https://github.com/ohdsi/patientlevelprediction/blob/main/R/FeatureEngineering.R"
click node_fit "https://github.com/ohdsi/patientlevelprediction/blob/main/R/Fit.R"
click node_algorithms "https://github.com/ohdsi/patientlevelprediction/blob/main/R/CyclopsModels.R"
click node_predict "https://github.com/ohdsi/patientlevelprediction/blob/main/R/Predict.R"
click node_validate "https://github.com/ohdsi/patientlevelprediction/blob/main/R/ExternalValidatePlp.R"
click node_evaluate "https://github.com/ohdsi/patientlevelprediction/blob/main/R/EvaluatePlp.R"
click node_metrics "https://github.com/ohdsi/patientlevelprediction/blob/main/R/EvaluationSummary.R"
click node_learning "https://github.com/ohdsi/patientlevelprediction/blob/main/R/LearningCurve.R"
click node_results "https://github.com/ohdsi/patientlevelprediction/blob/main/R/SaveLoadPlp.R"
click node_viewer "https://github.com/ohdsi/patientlevelprediction/blob/main/R/ViewShinyPlp.R"
click node_plots "https://github.com/ohdsi/patientlevelprediction/blob/main/R/Plotting.R"
click node_python "https://github.com/ohdsi/patientlevelprediction/blob/main/R/SklearnClassifier.R"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_design,node_extract,node_covariates toneBlue
class node_preprocess,node_split,node_features,node_fit,node_algorithms,node_predict,node_omop toneAmber
class node_validate,node_evaluate,node_metrics,node_learning toneMint
class node_results,node_viewer,node_plots toneRose
class node_python,node_user toneIndigo
```

## Components

### Study design and data

- [Prediction design](https://github.com/ohdsi/patientlevelprediction/blob/main/R/PopulationSettings.R): `R/PopulationSettings.R`
- [OMOP extraction](https://github.com/ohdsi/patientlevelprediction/blob/main/R/ExtractData.R): `R/ExtractData.R`
- [Covariates](https://github.com/ohdsi/patientlevelprediction/blob/main/R/AdditionalCovariates.R): `R/AdditionalCovariates.R`

### Model development

- [Preprocessing](https://github.com/ohdsi/patientlevelprediction/blob/main/R/PreprocessingData.R): `R/PreprocessingData.R`
- [Data splitting](https://github.com/ohdsi/patientlevelprediction/blob/main/R/DataSplitting.R): `R/DataSplitting.R`
- [Feature engineering](https://github.com/ohdsi/patientlevelprediction/blob/main/R/FeatureEngineering.R): `R/FeatureEngineering.R`
- [Model fitting](https://github.com/ohdsi/patientlevelprediction/blob/main/R/Fit.R): `R/Fit.R`
- [Model algorithms](https://github.com/ohdsi/patientlevelprediction/blob/main/R/CyclopsModels.R): `R/CyclopsModels.R`
- [Prediction](https://github.com/ohdsi/patientlevelprediction/blob/main/R/Predict.R): `R/Predict.R`

### Validation and evaluation

- [External validation](https://github.com/ohdsi/patientlevelprediction/blob/main/R/ExternalValidatePlp.R): `R/ExternalValidatePlp.R`
- [Performance evaluation](https://github.com/ohdsi/patientlevelprediction/blob/main/R/EvaluatePlp.R): `R/EvaluatePlp.R`
- [Performance summaries](https://github.com/ohdsi/patientlevelprediction/blob/main/R/EvaluationSummary.R): `R/EvaluationSummary.R`
- [Learning curves](https://github.com/ohdsi/patientlevelprediction/blob/main/R/LearningCurve.R): `R/LearningCurve.R`

### Results and exploration

- [Saved results](https://github.com/ohdsi/patientlevelprediction/blob/main/R/SaveLoadPlp.R): `R/SaveLoadPlp.R`
- [Interactive viewer](https://github.com/ohdsi/patientlevelprediction/blob/main/R/ViewShinyPlp.R): `R/ViewShinyPlp.R`
- [Performance plots](https://github.com/ohdsi/patientlevelprediction/blob/main/R/Plotting.R): `R/Plotting.R`

### Optional integrations

- [Python ML](https://github.com/ohdsi/patientlevelprediction/blob/main/R/SklearnClassifier.R): `R/SklearnClassifier.R`

### Other components

- **Analyst**
- **OMOP database**

## Connections

- Analyst → Prediction design: defines problem
- Prediction design → OMOP extraction: specifies extraction
- OMOP extraction → OMOP database: reads cohorts and data
- OMOP extraction → Covariates: uses covariate settings
- OMOP extraction → Preprocessing: provides prediction data
- Preprocessing → Data splitting: prepares data
- Data splitting → Model fitting: supplies training data
- Model fitting → Feature engineering: applies feature engineering
- Model fitting → Model algorithms: uses algorithms
- Model fitting → Prediction: produces model
- Prediction → Performance evaluation: provides predictions
- External validation → Performance evaluation: evaluates predictions
- Performance evaluation → Performance summaries: summarizes performance
- Model fitting → Learning curves: supports learning curves
- Performance evaluation → Saved results: saves results
- Saved results → Interactive viewer: supplies results
- Saved results → Performance plots: supplies performance data
- Model algorithms → Python ML: uses when selected
