Skip to main content

rsf-grid-search

A small grid search over RandomSurvivalForest hyperparameters (min_samples_leaf, max_features, max_depth), scored by Harrell's concordance index on a held-out validation split.

Random survival forests have no closed-form regularization path the way a penalized Cox model does, so their main regularization knobs are tuned by grid search instead. events_per_leaf is reported alongside the C-index for each combination as a rough diagnostic: a leaf with too few events gives an unstable local Kaplan-Meier estimate, the survival-forest analogue of too few events per parameter in a Cox model.

Install

pip install rsf-grid-search

Usage

from rsf_grid_search import grid_rsf

results = grid_rsf(X, y, n_sub=30000, n_trees=300, seed=1)
print(results.head())

X is a pandas.DataFrame design matrix and y is a survival target in scikit-survival's structured-array format (fields "event", "time", e.g. built with sksurv.util.Surv.from_arrays).

If the training split is larger than n_sub, it is subsampled (stratified on the event indicator) before the grid search, to keep each fit's runtime bounded. The result is a DataFrame, one row per grid point, sorted by descending validation C-index, with columns leaf, max_features, depth, events_per_leaf, c_index, secs.

The default grid is min_samples_leaf in (30, 60, 100, 150, 250), max_features in ("sqrt", 0.2, 0.35, 0.6), and max_depth in (None, 10). Override any of them:

results = grid_rsf(
    X, y,
    leaf_grid=(20, 50, 100),
    max_features_grid=("sqrt", 0.5),
    depth_grid=(None,),
)

License

MIT

Release files for rsf-grid-search 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rsf-grid-search 0.1.0
File Size Uploaded
rsf_grid_search-0.1.0.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rsf-grid-search 0.1.0
File Interpreter ABI Platform
rsf_grid_search-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.1 kB

Release files / rsf_grid_search-0.1.0.tar.gz

Download URL rsf_grid_search-0.1.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d997917df45bc27d275cab48f00a494b3895e4757350e55a689c85a62e329851
BLAKE2b-256 checksum
How to use checksums
381bb388a4c71950fd0cee04754f00155876d23ddfc9c4128eca00b1b4e5099f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / rsf_grid_search-0.1.0-py3-none-any.whl

Download URL rsf_grid_search-0.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32c2bc244a06e6fcb8f4173cc7e500a8f6bde45bc39074efe4a7093e03a9494c
BLAKE2b-256 checksum
How to use checksums
6b33830ffce471ac79875708c51a0da23d5aa7c1ab904b82e9078723e3db95da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page