{"id":30985328,"url":"https://github.com/pr38/survivalpredict","last_synced_at":"2026-05-19T14:34:43.655Z","repository":{"id":314012316,"uuid":"1053797201","full_name":"pr38/survivalpredict","owner":"pr38","description":"Estimating survival predictions","archived":false,"fork":false,"pushed_at":"2025-09-10T00:37:31.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-10T03:54:27.001Z","etag":null,"topics":["cox-proportional-hazard","cox-regression","python","reliability-analysis","scikit-learn","survival-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pr38.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-10T00:24:29.000Z","updated_at":"2025-09-10T01:24:05.000Z","dependencies_parsed_at":"2025-09-10T04:01:53.094Z","dependency_job_id":"c26f0125-ef36-4d43-9625-978029b9bc0f","html_url":"https://github.com/pr38/survivalpredict","commit_stats":null,"previous_names":["pr38/survivalpredict"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pr38/survivalpredict","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr38%2Fsurvivalpredict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr38%2Fsurvivalpredict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr38%2Fsurvivalpredict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr38%2Fsurvivalpredict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pr38","download_url":"https://codeload.github.com/pr38/survivalpredict/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr38%2Fsurvivalpredict/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274823225,"owners_count":25356644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cox-proportional-hazard","cox-regression","python","reliability-analysis","scikit-learn","survival-analysis"],"created_at":"2025-09-12T13:46:35.595Z","updated_at":"2026-05-19T14:34:43.650Z","avatar_url":"https://github.com/pr38.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SurvivalPredict\n\nA python package centered around Survival Analysis Statistical Learning, for predicting survival curves. The code in this repo is lovingly written without any stochastic generative processes.\n\nSee \u003ca href=https://survivalpredict.readthedocs.io/en/latest/index.html\u003edocumentation\u003c/a\u003e\n\nWIP. A pypi release should be released soon. In the meantime, the code in this repo can be installed via `pip install git+https://github.com/pr38/survivalpredict`. Ideally, before the first pypi release docstrings and example notebooks will be added. With the goal of finishing left-censoring support, sparse data support as well as  tree-based, ensemble, and exotic neural network  models further down the line. \n\n\n\u003ca href=https://github.com/pr38/survivalpredict/blob/main/notebooks/survivalpredict_walkthrough_demo.ipynb\u003eGeneral walkthrough-demo\u003c/a\u003e\n\n\u003ca href=https://github.com/pr38/survivalpredict/blob/main/notebooks/demo_sklearn_interface.ipynb\u003eDemo for interfacing with scikit learn\u003c/a\u003e\n\n\n\n## Estimators\nThe estimators implemented in the `survivalpredict.estimators` sub-module.\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eEstimators\u003c/th\u003e\n        \u003cth\u003eDescription\u003c/th\u003e\n        \u003cth\u003eStratifiable\u003c/th\u003e\n        \u003cth\u003eLeft-censorable\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eCoxProportionalHazard\u003c/td\u003e\n        \u003ctd\u003e\n        Cox Proportional Hazards model is a linear semi-parametric relative risk model. A staple of survival analysis. Fast and efficient to train. Survivalpredict's implementation has many optimizations and is faster than other implementations available to Python. Both breslow and efron ties are supported. Currently, only the Breslow base hazard is available.\n        \u003c/td\u003e\n        \u003ctd\u003e Yes\u003c/td\u003e\n        \u003ctd\u003eYes\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eParametricDiscreteTimePH\u003c/td\u003e\n        \u003ctd\u003e A fully parametric linear hazards model. Chen, weibull, log_normal, log_logistic, gompertz, gamma and additive_chen_weibull baseline hazards are available as hyperparameters. Maximum likelihood is estimated using a survival distinct time likelihood with censorship. Implemented with Pymc/Pytensor, with either a Jax or numba backend.\u003c/td\u003e\n        \u003ctd\u003eYes\u003c/td\u003e\n        \u003ctd\u003eYes\u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctr\u003e\n        \u003ctd\u003eCoxPHElasticNet\u003c/td\u003e\n        \u003ctd\u003eCox Proportional Hazards model model with Elastic-Net/Lasso penalty and feature shrinkage/selection. Uses a 'Newton Raphson-like' coordinate descent algorithm described in \u003ca href=https://pmc.ncbi.nlm.nih.gov/articles/PMC4824408\u003eSimon, Noah et al. “Regularization Paths for Cox's Proportional Hazards Model via Coordinate Descent\u003c/a\u003e. Assumes breslow ties. The current literature is unclear on how to incorporate stratification support into said algorithm.\n        \u003c/td\u003e\n        \u003ctd\u003e No\u003c/td\u003e\n        \u003ctd\u003eYes\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eKaplanMeierSurvivalEstimator\u003c/td\u003e\n        \u003ctd\u003e Univariate non-parametric survival curve. Useful as a baseline/dummy estimator.\u003c/td\u003e\n        \u003ctd\u003eAccepts strata, but builds a survival curve for each strata. \u003c/td\u003e\n        \u003ctd\u003eYes\u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctr\u003e\n        \u003ctd\u003eKNeighborsSurvival\u003c/td\u003e\n        \u003ctd\u003eK nearest neighbors for survival. An in-memory non-parametric model that builds a Kaplan-Meier survival curve based on neighbors.\n        \u003c/td\u003e\n        \u003ctd\u003eNo\u003c/td\u003e\n        \u003ctd\u003eYes\u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003eCoxNeuralNetPH\u003c/td\u003e\n        \u003ctd\u003e A neural network model for estimating relative risk. Cox proportional hazards model's 'negative log likelihood for Breslow ties' is used as a loss function. Breslow's base hazard for relative risk is used to estimate survival across time. Implemented using Jax.  \u003c/td\u003e\n        \u003ctd\u003eYes\u003c/td\u003e\n        \u003ctd\u003eYes\u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctr\u003e\n        \u003ctd\u003eAalenAdditiveHazard\u003c/td\u003e\n        \u003ctd\u003e Linear multivariate non-parametric estimation of hazard. Allows for each interval of time and feature to have an associated coefficient, allowing for the effects of features to change over time.\n        \u003c/td\u003e\n        \u003ctd\u003eNo\u003c/td\u003e\n        \u003ctd\u003eYes\u003c/td\u003e\n\u003c/table\u003e\n\n\n\n## Metrics\n\nSurvivalpredict focuses on metrics that directly measure prediction performance. Hence, the `survivalpredict.metrics` module intentionally excludes metrics based on ranking relative risk(i.e., ' c-index').\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eMetrics\u003c/th\u003e\n        \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003ebrier_scores_administrative\u003c/td\u003e\n        \u003ctd\u003eSquared error between the true survival and prediction for each time of interest. Censored intervals are ignored. Averaged by the number of rows not censored at a given interval of time. Ideal in cases of 'administrative' censorship, where 'survival time' is modeled after the time of an individual in the experiment, and not calendar time. This metric is ideal for cases of churn, conversion and operational failure. See \u003ca href=https://jmlr.org/papers/volume24/19-1030/19-1030.pdf\u003ehere\u003c/a\u003e.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eintegrated_brier_score_administrative\u003c/td\u003e\n        \u003ctd\u003eIntegral of administrative brier scores, to allow for a singular metric of performance. \u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003eintegrated_brier_score_administrative_sklearn_metric\u003c/td\u003e\n        \u003ctd\u003escikit-learn metric wrapper around `integrated_brier_score_administrative` function, for accessing said metric in when using the SklearnSurvivalPipeline wrapper class when interfacing with scikit-learn.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eintegrated_brier_score_administrative_sklearn_scorer\u003c/td\u003e\n        \u003ctd\u003escikit-learn scorer wrapper around `integrated_brier_score_administrative` function, for accessing said metric in when using the SklearnSurvivalPipeline wrapper class when interfacing with scikit-learn.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003ebrier_scores_ipcw\u003c/td\u003e\n        \u003ctd\u003eBrier scores with inverse probability of censoring weights. The squared error between the true survival and prediction is weighted using a Kaplan-Meier curve with inverted events, depending on censoring and failure at different points in time. This is a common metric within the field of biostatistics and is used in clinical trials. See \u003ca href=https://pubmed.ncbi.nlm.nih.gov/10474158\u003ehere\u003c/a\u003e.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eintegrated_brier_score_ipcw\u003c/td\u003e\n        \u003ctd\u003eIntegral of brier scores with probability of censoring weights, to allow for a singular metric of performance.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eintegrated_brier_score_ipcw_sklearn_metric\u003c/td\u003e\n        \u003ctd\u003escikit-learn metric wrapper around `integrated_brier_score_ipcw` function.\u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003eintegrated_brier_score_ipcw_sklearn_scorer\u003c/td\u003e\n        \u003ctd\u003escikit-learn scorer wrapper around `integrated_brier_score_ipcw` function.\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n\n## Strata Preprocessing\n\nThe `survivalpredict.strata_preprocessing` module allows for the creation of strata to be used various estimators.\n\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eClass\u003c/th\u003e\n        \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003eStrataBuilderDiscretizer\u003c/td\u003e\n        \u003ctd\u003eBuilds strata keys from numeric data. Allows various splitting strategies. \u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003eStrataBuilderEncoder\u003c/td\u003e\n        \u003ctd\u003eBuilds strata keys from categorical data.\u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003eStrataColumnTransformer\u003c/td\u003e\n        \u003ctd\u003eAllows various StrataBuilders to be stacked and simultaneously to be run on different columns to build the strata. Modeled after scikit-learn's ColumnTransformer. \u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003emake_strata_column_transformer\u003c/td\u003e\n        \u003ctd\u003eGenerates the StrataColumnTransformer class without having to name each transformation directly, like scikit-learn's make_column_transformer. \u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n\n\n## Pipeline\n\nDue to various reasons, survivalpredict intentionally breaks with scikit-learn's api in several ways. The `survivalpredict.pipeline` module allows for creating wrappers around various survivalpredict classes, in order for survivalpredict to interpolate with the greater scikit-learn ecosystem (i.e., for feature selection or hyperparameter tuning); in addition of the various utility of a conventional scikit-learn's pipeline. \n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eClass\u003c/th\u003e\n        \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003ebuild_sklearn_pipeline_target\u003c/td\u003e\n        \u003ctd\u003eBuilds a singular target array from the times and events arrays. Used as the 'y'/observed for scikit-learn ecosystem.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eSklearnSurvivalPipeline\u003c/td\u003e\n        \u003ctd\u003eStacks various sklearn transformers and survivalpredict strata_builders and estimators into single class. It assumes the output of the `build_sklearn_pipeline_target` function as the 'y'/observed.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003emake_sklearn_survival_pipeline\u003c/td\u003e\n        \u003ctd\u003eGenerates a SklearnSurvivalPipeline class without having to directly name all the steps.\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n## Validation\n\nsurvivalpredict comes with some native model validation capability, within `survivalpredict.validation`.\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eClass\u003c/th\u003e\n        \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003esur_cross_val_score\u003c/td\u003e\n        \u003ctd\u003esurvivalpredict's equivalent to scikit-learn's cross_val_score.\u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003esur_cross_validate\u003c/td\u003e\n        \u003ctd\u003esurvivalpredict's equivalent to scikit-learn's cross_validate.\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n\n## Model Selection\n\nScikit-learn's model_selection is also mimicked within `survivalpredict.model_selection`\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eClass\u003c/th\u003e\n        \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003eSur_GridSearchCV\u003c/td\u003e\n        \u003ctd\u003esurvivalpredict's equivalent to scikit-learn's GridSearchCV\u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctd\u003eSur_RandomizedSearchCV\u003c/td\u003e\n        \u003ctd\u003esurvivalpredict's equivalent to scikit-learn's RandomizedSearchCV\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr38%2Fsurvivalpredict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpr38%2Fsurvivalpredict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr38%2Fsurvivalpredict/lists"}