survivalpredict.estimators.MultiTaskLogisticRegression¶
- class survivalpredict.estimators.MultiTaskLogisticRegression(*, c1=0.0, c2=0.0, fit_intercept=True, solver='L-BFGS-B')¶
Multi-Task Logistic Regression.
Multi-Task Logistic Regression is a survival model with time-varying coefficients. Each interval of time and feature has an associated coefficient. Each interval of time’s estimation of survival is dependent on the previous estimation of survival[1]. The ‘brown loss’ for discrete time survival is used[2] instead of the log-likelihood of the original paper. The c1 and c2 regulation from the Yu et al[1] paper is present.
Implemented with Jax.
- Parameters:
c1 (float, default=0.0) – Regulation penatly for smoothing the effects of features across time.
c2 (float, default=0.0) – Penatly for l2 regularization of weights.
fit_intercept (bool, default=True) – If true, adds constants to X array.
solver ({"BFGS","L-BFGS-B"}, default='L-BFGS-B') – Numerical solver to use.
- coef_¶
Coefficients of the model.
- Type:
ndarray of shape (n_features,max_time)
- loss_¶
Loss at point the point of convergence.
- Type:
float
- max_iter_seen_¶
Number of training iterations point of convergence.
- Type:
int
See also
survivalpredict.estimators.AalenAdditiveHazardSimilar estimator that trains on a heuristic.
References
[1] Yu, Chun-Nam & Greiner, Russ & Lin, Hsiu-Chin & Baracos, Vickie. (2012). Learning Patient-Specific Cancer Survival Distributions as a Sequence of Dependent Regressors.
[2] Suresh K, Severn C, Ghosh D. Survival prediction models: an introduction to discrete-time modeling. BMC Med Res Methodol. 2022 Jul 26;22(1):207. doi: 10.1186/s12874-022-01679-6. PMID: 35883032; PMCID: PMC9316420.
Methods
convert_hazard_to_survival(hazards)Convert hazards to survival curves.
fit(X, times, events[, check_input, times_start])Fit model.
fit_predict(*args, **kwargs)Fit model and Build survival curves.
predict(X[, max_time])Build survival curves on an array of vectors X.
predict_hazard(X[, max_time])Build hazards on an array of vectors X.
- __init__(*, c1=0.0, c2=0.0, fit_intercept=True, solver='L-BFGS-B')¶
- Parameters:
c1 (float)
c2 (float)
fit_intercept (bool)
solver (Literal['BFGS', 'L-BFGS-B'])
Methods
__init__(*[, c1, c2, fit_intercept, solver])convert_hazard_to_survival(hazards)Convert hazards to survival curves.
fit(X, times, events[, check_input, times_start])Fit model.
fit_predict(*args, **kwargs)Fit model and Build survival curves.
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
predict(X[, max_time])Build survival curves on an array of vectors X.
predict_hazard(X[, max_time])Build hazards on an array of vectors X.
set_fit_request(*[, check_input, events, ...])Configure whether metadata should be requested to be passed to the
fitmethod.set_params(**params)Set the parameters of this estimator.
set_predict_request(*[, max_time])Configure whether metadata should be requested to be passed to the
predictmethod.- static convert_hazard_to_survival(hazards)¶
Convert hazards to survival curves.
- Parameters:
hazards (array-like, dtype=np.float64) – Array of hazards.
- Returns:
Survival curves generated from given hazards.
- Return type:
ndarray, dtype=np.float64
- fit(X, times, events, check_input=True, times_start=None)¶
Fit model.
- Parameters:
X (array-like of shape (n_samples, n_features)) – Training data.
times (array-like of shape (n_samples), dtype=np.int64) – Point in time last observed.
events (array-like of shape (n_samples), dtype=np.bool_) – Experianed event.
check_input (bool, default=True) – If True, validates and casts inputs.
times_start (array-like of shape (n_samples, dtype=np.int64), default=None) – Starting point for observation. If not passed in, all times_start times are assumed to be 0.
- Returns:
Fitted Estimator.
- Return type:
object
- fit_predict(*args, **kwargs)¶
Fit model and Build survival curves.
- predict(X, max_time=None)¶
Build survival curves on an array of vectors X.
- Parameters:
X (array-like of shape (n_samples, n_features)) – Predicting data.
max_time (int, default=None) – Maximum time of built survival curves. If none, maximum time is max time seen on training data.
- Returns:
The estimated survival curves, the left-most column is the probability of survival at time 1, and the right-most column ends at max_time.
- Return type:
ndarray of shape (n_samples, max_time), dtype=np.float64
- predict_hazard(X, max_time=None)¶
Build hazards on an array of vectors X.
It should be noted that MTLR does not have a native notion of hazard. What is presented here is a modified formula of MTLR, before probabilities per time of survival are multiplied. It can function as an equivalent to hazards; survival curves can also be built from it.
- Parameters:
X (array-like of shape (n_samples, n_features)) – Predicting data.
max_time (int, default=None) – Maximum time of built hazards. If none, maximum time is max time seen on training data.
- Returns:
The estimated hazards, the left-most column is the hazards at time 1, and the right-most column ends at max_time.
- Return type:
ndarray of shape (n_samples, max_time), dtype=np.float64