Metadata-Version: 2.4
Name: rftvc
Version: 0.2.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Requires-Dist: numpy>=1.24
Requires-Dist: scikit-learn>=1.6
Requires-Dist: polars>=1.0
Requires-Dist: narwhals>=1.30
Requires-Dist: altair>=5 ; extra == 'viz'
Provides-Extra: viz
License-File: LICENSE
Summary: Scikit-learn compatible random survival forests with time-varying covariates
Keywords: survival-analysis,random-forest,scikit-learn,time-varying-covariates
Author-email: Gokhan Ciflikli <gokhanciflikli@gmail.com>
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/ciflikli/rftvc/blob/main/CHANGELOG.md
Project-URL: Documentation, https://rftvc.readthedocs.io
Project-URL: Homepage, https://github.com/ciflikli/rftvc
Project-URL: Repository, https://github.com/ciflikli/rftvc

# rftvc

Random survival forests for **time-varying covariates**, with a Rust engine and a
scikit-learn compatible Python API.

- Counting-process data `(id, start, stop, event, X)` with delayed entry
  (left truncation) and covariates that change over follow-up.
- Whole-subject resampling, id-level out-of-bag estimates, and leaf sizes
  counted in subjects, not rows.
- Landmark data building and a landmark super-model for dynamic prediction.
- Time-aware cross-validation and IPCW landmark metrics.
- An exact log-rank split criterion, and an opt-in coarse time grid for large data.
- Optional plotting (`rftvc.viz`, `pip install rftvc[viz]`): survival/hazard/CIF curves,
  importance and calibration charts (Altair), and a dependency-free SVG tree diagram.

## Install

Not yet published to PyPI. Build from source: a [Rust toolchain](https://rustup.rs/)
(via [maturin](https://www.maturin.rs/)) and [uv](https://docs.astral.sh/uv/) are
required.

```console
git clone https://github.com/ciflikli/rftvc.git
cd rftvc
uv venv
uv pip install -e . --group dev
```

Add `--extra viz` (or `pip install rftvc[viz]` once published) for `rftvc.viz`'s
Altair-based charts; its SVG tree diagram (`rftvc.viz.plot_tree`) needs no extra install.

## Quickstart

```python
import numpy as np
from rftvc import SurvivalForestTV, make_survival_y

rng = np.random.default_rng(0)
X = rng.normal(size=(200, 3))
t = rng.exponential(np.exp(-0.5 * X[:, 0]))
event = t <= 2.0
y = make_survival_y(np.minimum(t, 2.0), event)

forest = SurvivalForestTV(n_estimators=200, random_state=0).fit(X, y)
risk = forest.predict_risk(X[:5], horizon=1.0)
```

## Documentation

- [Docs site](https://rftvc.readthedocs.io) — user guide, API reference, case studies.
- [Case studies](docs/source/case_studies/) — worked examples on real datasets.
- [Compatibility](https://rftvc.readthedocs.io/en/latest/compatibility.html) — supported
  Python, scikit-learn and platform versions.
- [Changelog](CHANGELOG.md)

## License

MIT

