Comments (8)
This feature has been requested before and I do plan to add in the next release (probably in February). In the meantime, please have a look at #15 (comment) for alternative ways.
from scikit-survival.
Looks perfectly fine to me. As mentioned in #15 (comment), the only downside is that this way is still subject to the proportional hazards assumption.
from scikit-survival.
Hi,
Are there any updates on implementing these functions for CoxnetSurvivalAnalysis?
Thanks.
from scikit-survival.
Unfortunately no, I couldn't find the time to implement this yet. Any contributions would appreciated.
from scikit-survival.
Hi, I read through the comments about workarounds for this: specifically "using the predicted risk scores as a feature in a Cox model" to get predicted survival functions.
My question: is it appropriate to use the risk scores as the only feature in a Cox model?
I have tried to implement this and the results look sensible at first glance. Would be grateful if someone could take a look at my code below, and let me know if there is anything fundamentally wrong with this approach. Many thanks.
X = data[feature_cols]
y = data[['censor','time']]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1234)
estimator = GradientBoostingSurvivalAnalysis(subsample=0.95)
estimator.fit(X_train, y_train)
# predicted risk scores - reshaping for next step
y_hat_train = estimator.predict(X_train).reshape(-1, 1)
y_hat_test = estimator.predict(X_test).reshape(-1, 1)
# fit on risk scores from first step ONLY
cox_ph = CoxPHSurvivalAnalysis()
cox_ph.fit(y_hat_train, y_train)
surv_func_train = cox_ph.predict_survival_function(y_hat_train)
surv_func_test = cox_ph.predict_survival_function(y_hat_test)
from scikit-survival.
Just curious-- the implementation of survival function and cumulative hazard function for generic survival models that you were hoping to get to: is that "using the predicted risk scores as a feature in a Cox model" or Van Belle et al.'s method as mentioned in #15, or yet some different methods? Thanks.
from scikit-survival.
I was planning on using the approach proposed by Van Belle et al. Unfortunately, due to other obligations, my time is limited at the moment.
from scikit-survival.
At least for GradientBoostingSurvivalAnalysis w/ coxph loss, you could do something similar to what's in lifelines:
def generate_baselines(self, X, y):
X, event, time = check_arrays_survival(X, y, accept_sparse=['csr', 'csc', 'coo'], dtype=DTYPE)
ind_hazards = pd.DataFrame({
"P": np.exp(self.predict(X)),
"E": event
"T": time
})
ind_hazards_summed_over_durations = ind_hazards.groupby("T")[["P", "E"]].sum()
ind_hazards_summed_over_durations["P"] = (
ind_hazards_summed_over_durations["P"].loc[::-1].cumsum()
)
baseline_hazard = ind_hazards_summed_over_durations["E"] / ind_hazards_summed_over_durations["P"]
baseline_cumulative_hazard = baseline_hazard.cumsum()
baseline_survival = np.exp(-baseline_cumulative_hazard)
return baseline_hazard, baseline_cumulative_hazard, baseline_survival
From which survival = baseline_survival.values ** hazard_ratio
from scikit-survival.
Related Issues (20)
- Add support for predict_survival_function to Stacking
- example or documentation for StratifiedKFold use HOT 1
- Out of date pandas function calls (iteritems vs items). HOT 1
- Elastic net results from lifeline and scikit-survival are different HOT 1
- Visualizing decision trees HOT 1
- Survival Random Forest predict_survival_function does not scale with `n_jobs` HOT 1
- Clarify which metrics expect output of survival function vs output of cumulative hazard function HOT 1
- conf_type is not working in kaplan_meier_estimator: HOT 2
- How to ensemble predictions from ExtraSurvivalTrees models? HOT 1
- parallelization for GradientBoostingSurvivalAnalysis? HOT 1
- plotting a tree from estimators_[i] from RandomSurvivalForest.fit() HOT 6
- Possible memory leak for FastKernelSurvivalSVM HOT 1
- Fit does not throw exception if negative event times are passed
- Description of estimate parameter in integrated_brier_score is unclear HOT 1
- Ipcw estimation: Add small value for numerical stability HOT 1
- Description of estimate parameter in brier_score is unclear HOT 4
- Ability to suppress future warnings? HOT 1
- Possible improvement in documentation of Cumulative dynamic AUC HOT 1
- concordance_index_ipcw output inconsistent with survAUC package HOT 1
- Support Scikit-Learn 1.4 (stable version)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scikit-survival.