# sebp/scikit-survival architecture

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

- Interactive diagram: https://gitdiagram.com/sebp/scikit-survival
- Repository: https://github.com/sebp/scikit-survival

## Overview

scikit-survival is a Python survival-analysis library built on scikit-learn. The principal workflow is to prepare censored time-to-event data, fit a survival estimator, produce risk or survival-function predictions, and evaluate them with censoring-aware metrics. Its major capabilities also include nonparametric estimation, tree and ensemble models, survival SVMs, meta-estimators, clinical kernels, dataset loading, and ARFF I/O. Source-index references support several internal links; other workflow links are documented at a high level in the README, so unsampled implementation details are not asserted.

Main entry points: [`sksurv/_dataframe`](https://github.com/sebp/scikit-survival/tree/main/sksurv/_dataframe) (Dataframe handling), [`sksurv/linear_model/coxph.py`](https://github.com/sebp/scikit-survival/blob/main/sksurv/linear_model/coxph.py) (Linear models), [`sksurv/datasets/base.py`](https://github.com/sebp/scikit-survival/blob/main/sksurv/datasets/base.py) (Dataset loading), [`sksurv/ensemble`](https://github.com/sebp/scikit-survival/tree/main/sksurv/ensemble) (Tree ensembles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data and preparation"]
  node_datasets["Dataset loading<br/>[base.py]"]
  node_arff["ARFF I/O<br/>[arffread.py]"]
  node_prep["Preprocessing<br/>[preprocessing.py]"]
end

subgraph group_models["Survival models"]
  node_linear["Linear models<br/>[coxph.py]"]
  node_aft["AFT model<br/>[aft.py]"]
  node_coxnet["Regularized Cox<br/>[coxnet.py]"]
  node_trees["Survival trees<br/>[tree.py]"]
  node_ensembles["Tree ensembles"]
  node_svm["Survival SVMs<br/>[survival_svm.py]"]
  node_kernels["Clinical kernels<br/>[clinical.py]"]
end

subgraph group_analysis["Survival analysis"]
  node_nonparametric["Nonparametric estimators<br/>[nonparametric.py]"]
  node_functions["Step functions<br/>[functions.py]"]
  node_compare["Group comparison<br/>[compare.py]"]
end

subgraph group_evaluation["Evaluation and composition"]
  node_metrics["Survival metrics<br/>[metrics.py]"]
  node_meta["Meta-estimators<br/>[stacking.py]"]
  node_selection["Ensemble selection"]
end

subgraph group_internals["Shared internals"]
  node_frame["Dataframe handling"]
  node_survtarget["Survival targets<br/>[util.py]"]
  node_columns["Column utilities<br/>[column.py]"]
  node_base["Estimator base<br/>[base.py]"]
end

node_user(("Analyst"))

node_user -.->|"loads data"| node_datasets
node_user -.->|"prepares inputs"| node_prep
node_user -.->|"fits estimator"| node_linear
node_datasets -->|"uses ARFF I/O"| node_arff
node_datasets -->|"handles dataframes"| node_frame
node_datasets -->|"uses columns"| node_columns
node_prep -.->|"normalizes inputs"| node_frame
node_linear -->|"checks inputs"| node_frame
node_linear -.->|"validates targets"| node_survtarget
node_coxnet -->|"checks inputs"| node_frame
node_trees -->|"checks inputs"| node_frame
node_ensembles -->|"uses tree estimators"| node_trees
node_ensembles -->|"uses Cox model"| node_linear
node_svm -->|"checks inputs"| node_frame
node_linear -->|"estimates baseline"| node_nonparametric
node_linear -->|"builds predictions"| node_functions
node_base -->|"scores predictions"| node_metrics
node_metrics -->|"estimates censoring"| node_nonparametric
node_meta -->|"wraps estimators"| node_base
node_selection -->|"uses stacking"| node_meta
node_kernels -->|"handles dataframes"| node_frame
node_compare -.->|"reports comparisons"| node_user

click node_datasets "https://github.com/sebp/scikit-survival/blob/main/sksurv/datasets/base.py"
click node_arff "https://github.com/sebp/scikit-survival/blob/main/sksurv/io/arffread.py"
click node_prep "https://github.com/sebp/scikit-survival/blob/main/sksurv/preprocessing.py"
click node_frame "https://github.com/sebp/scikit-survival/tree/main/sksurv/_dataframe"
click node_survtarget "https://github.com/sebp/scikit-survival/blob/main/sksurv/util.py"
click node_linear "https://github.com/sebp/scikit-survival/blob/main/sksurv/linear_model/coxph.py"
click node_aft "https://github.com/sebp/scikit-survival/blob/main/sksurv/linear_model/aft.py"
click node_coxnet "https://github.com/sebp/scikit-survival/blob/main/sksurv/linear_model/coxnet.py"
click node_trees "https://github.com/sebp/scikit-survival/blob/main/sksurv/tree/tree.py"
click node_ensembles "https://github.com/sebp/scikit-survival/tree/main/sksurv/ensemble"
click node_svm "https://github.com/sebp/scikit-survival/blob/main/sksurv/svm/survival_svm.py"
click node_nonparametric "https://github.com/sebp/scikit-survival/blob/main/sksurv/nonparametric.py"
click node_functions "https://github.com/sebp/scikit-survival/blob/main/sksurv/functions.py"
click node_metrics "https://github.com/sebp/scikit-survival/blob/main/sksurv/metrics.py"
click node_meta "https://github.com/sebp/scikit-survival/blob/main/sksurv/meta/stacking.py"
click node_selection "https://github.com/sebp/scikit-survival/blob/main/sksurv/meta/ensemble_selection.py"
click node_kernels "https://github.com/sebp/scikit-survival/blob/main/sksurv/kernels/clinical.py"
click node_compare "https://github.com/sebp/scikit-survival/blob/main/sksurv/compare.py"
click node_columns "https://github.com/sebp/scikit-survival/blob/main/sksurv/column.py"
click node_base "https://github.com/sebp/scikit-survival/blob/main/sksurv/base.py"

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_datasets,node_arff,node_prep toneBlue
class node_linear,node_aft,node_coxnet,node_trees,node_ensembles,node_svm,node_kernels toneAmber
class node_nonparametric,node_functions,node_compare toneMint
class node_metrics,node_meta,node_selection toneRose
class node_frame,node_survtarget,node_columns,node_base,node_user toneIndigo
```

## Components

### Data and preparation

- [Dataset loading](https://github.com/sebp/scikit-survival/blob/main/sksurv/datasets/base.py): `sksurv/datasets/base.py`
- [ARFF I/O](https://github.com/sebp/scikit-survival/blob/main/sksurv/io/arffread.py): `sksurv/io/arffread.py`
- [Preprocessing](https://github.com/sebp/scikit-survival/blob/main/sksurv/preprocessing.py): `sksurv/preprocessing.py`

### Survival models

- [Linear models](https://github.com/sebp/scikit-survival/blob/main/sksurv/linear_model/coxph.py): `sksurv/linear_model/coxph.py`
- [AFT model](https://github.com/sebp/scikit-survival/blob/main/sksurv/linear_model/aft.py): `sksurv/linear_model/aft.py`
- [Regularized Cox](https://github.com/sebp/scikit-survival/blob/main/sksurv/linear_model/coxnet.py): `sksurv/linear_model/coxnet.py`
- [Survival trees](https://github.com/sebp/scikit-survival/blob/main/sksurv/tree/tree.py): `sksurv/tree/tree.py`
- [Tree ensembles](https://github.com/sebp/scikit-survival/tree/main/sksurv/ensemble): `sksurv/ensemble`
- [Survival SVMs](https://github.com/sebp/scikit-survival/blob/main/sksurv/svm/survival_svm.py): `sksurv/svm/survival_svm.py`
- [Clinical kernels](https://github.com/sebp/scikit-survival/blob/main/sksurv/kernels/clinical.py): `sksurv/kernels/clinical.py`

### Survival analysis

- [Nonparametric estimators](https://github.com/sebp/scikit-survival/blob/main/sksurv/nonparametric.py): `sksurv/nonparametric.py`
- [Step functions](https://github.com/sebp/scikit-survival/blob/main/sksurv/functions.py): `sksurv/functions.py`
- [Group comparison](https://github.com/sebp/scikit-survival/blob/main/sksurv/compare.py): `sksurv/compare.py`

### Evaluation and composition

- [Survival metrics](https://github.com/sebp/scikit-survival/blob/main/sksurv/metrics.py): `sksurv/metrics.py`
- [Meta-estimators](https://github.com/sebp/scikit-survival/blob/main/sksurv/meta/stacking.py): `sksurv/meta/stacking.py`
- [Ensemble selection](https://github.com/sebp/scikit-survival/blob/main/sksurv/meta/ensemble_selection.py): `sksurv/meta/ensemble_selection.py`

### Shared internals

- [Dataframe handling](https://github.com/sebp/scikit-survival/tree/main/sksurv/_dataframe): `sksurv/_dataframe`
- [Survival targets](https://github.com/sebp/scikit-survival/blob/main/sksurv/util.py): `sksurv/util.py`
- [Column utilities](https://github.com/sebp/scikit-survival/blob/main/sksurv/column.py): `sksurv/column.py`
- [Estimator base](https://github.com/sebp/scikit-survival/blob/main/sksurv/base.py): `sksurv/base.py`

### Other components

- **Analyst**

## Connections

- Analyst → Dataset loading: loads data
- Analyst → Preprocessing: prepares inputs
- Analyst → Linear models: fits estimator
- Dataset loading → ARFF I/O: uses ARFF I/O (evidence: `sksurv/datasets/base.py`)
- Dataset loading → Dataframe handling: handles dataframes (evidence: `sksurv/datasets/base.py`)
- Dataset loading → Column utilities: uses columns (evidence: `sksurv/datasets/base.py`)
- Preprocessing → Dataframe handling: normalizes inputs
- Linear models → Dataframe handling: checks inputs (evidence: `sksurv/linear_model/coxph.py`)
- Linear models → Survival targets: validates targets (evidence: `sksurv/linear_model/coxph.py`)
- Regularized Cox → Dataframe handling: checks inputs (evidence: `sksurv/linear_model/coxnet.py`)
- Survival trees → Dataframe handling: checks inputs (evidence: `sksurv/tree/tree.py`)
- Tree ensembles → Survival trees: uses tree estimators (evidence: `sksurv/ensemble/forest.py`)
- Tree ensembles → Linear models: uses Cox model (evidence: `sksurv/ensemble/boosting.py`)
- Survival SVMs → Dataframe handling: checks inputs (evidence: `sksurv/svm/survival_svm.py`)
- Linear models → Nonparametric estimators: estimates baseline (evidence: `sksurv/linear_model/coxph.py`)
- Linear models → Step functions: builds predictions (evidence: `sksurv/linear_model/coxph.py`)
- Estimator base → Survival metrics: scores predictions (evidence: `sksurv/base.py`)
- Survival metrics → Nonparametric estimators: estimates censoring (evidence: `sksurv/metrics.py`)
- Meta-estimators → Estimator base: wraps estimators (evidence: `sksurv/meta/stacking.py`)
- Ensemble selection → Meta-estimators: uses stacking (evidence: `sksurv/meta/ensemble_selection.py`)
- Clinical kernels → Dataframe handling: handles dataframes (evidence: `sksurv/kernels/clinical.py`)
- Group comparison → Analyst: reports comparisons
