sksurv.linear_model.CoxnetSurvivalAnalysis¶

class
sksurv.linear_model.
CoxnetSurvivalAnalysis
(n_alphas=100, alphas=None, alpha_min_ratio='warn', l1_ratio=0.5, penalty_factor=None, normalize=False, copy_X=True, tol=1e07, max_iter=100000, verbose=False, fit_baseline_model=False)¶ Cox’s proportional hazard’s model with elastic net penalty.
See [1] for further description.
Parameters:  n_alphas (int, optional, default: 100) – Number of alphas along the regularization path.
 alphas (arraylike or None, optional) – List of alphas where to compute the models.
If
None
alphas are set automatically.  alpha_min_ratio (float, optional, default 0.0001) –
Determines minimum alpha of the regularization path if
alphas
isNone
. The smallest value for alpha is computed as the fraction of the data derived maximum alpha (i.e. the smallest value for which all coefficients are zero).The default value of alpha_min_ratio will depend on the sample size relative to the number of features in 0.13. If n_samples > n_features, the current default value 0.0001 will be used. If n_samples < n_features, 0.01 will be used instead.
 l1_ratio (float, optional, default: 0.5) – The ElasticNet mixing parameter, with
0 < l1_ratio <= 1
. Forl1_ratio = 0
the penalty is an L2 penalty. Forl1_ratio = 1
it is an L1 penalty. For0 < l1_ratio < 1
, the penalty is a combination of L1 and L2.  penalty_factor (arraylike or None, optional) – Separate penalty factors can be applied to each coefficient. This is a number that multiplies alpha to allow differential shrinkage. Can be 0 for some variables, which implies no shrinkage, and that variable is always included in the model. Default is 1 for all variables. Note: the penalty factors are internally rescaled to sum to n_features, and the alphas sequence will reflect this change.
 normalize (boolean, optional, default: False) – If True, the features X will be normalized before optimization by
subtracting the mean and dividing by the l2norm.
If you wish to standardize, please use
sklearn.preprocessing.StandardScaler
before callingfit
on an estimator withnormalize=False
.  copy_X (boolean, optional, default: True) – If
True
, X will be copied; else, it may be overwritten.  tol (float, optional, default: 1e7) – The tolerance for the optimization: optimization continues
until all updates are smaller than
tol
.  max_iter (int, optional, default: 100000) – The maximum number of iterations.
 verbose (bool, optional, default: False) – Whether to print additional information during optimization.
 fit_baseline_model (bool, optional, default: False) – Whether to estimate baseline survival function
and baseline cumulative hazard function for each alpha.
If enabled,
predict_cumulative_hazard_function()
andpredict_survival_function()
can be used to obtain predicted cumulative hazard function and survival function.

alphas_
¶ The actual sequence of alpha values used.
Type: ndarray, shape=(n_alphas,)

penalty_factor_
¶ The actual penalty factors used.
Type: ndarray, shape=(n_features,)

coef_
¶ Matrix of coefficients.
Type: ndarray, shape=(n_features, n_alphas)

deviance_ratio_
¶ The fraction of (null) deviance explained.
Type: ndarray, shape=(n_alphas,)
References
[1] Simon N, Friedman J, Hastie T, Tibshirani R. Regularization paths for Cox’s proportional hazards model via coordinate descent. Journal of statistical software. 2011 Mar;39(5):1. 
__init__
(n_alphas=100, alphas=None, alpha_min_ratio='warn', l1_ratio=0.5, penalty_factor=None, normalize=False, copy_X=True, tol=1e07, max_iter=100000, verbose=False, fit_baseline_model=False)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
([n_alphas, alphas, …])Initialize self. fit
(X, y)Fit estimator. predict
(X[, alpha])The linear predictor of the model. predict_cumulative_hazard_function
(X[, alpha])Predict cumulative hazard function. predict_survival_function
(X[, alpha])Predict survival function. score
(X, y)Returns the concordance index of the prediction. 
fit
(X, y)¶ Fit estimator.
Parameters:  X (arraylike, shape = (n_samples, n_features)) – Data matrix
 y (structured array, shape = (n_samples,)) – A structured array containing the binary event indicator as first field, and time of event or time of censoring as second field.
Returns: Return type: self

predict
(X, alpha=None)¶ The linear predictor of the model.
Parameters:  X (arraylike, shape = (n_samples, n_features)) – Test data of which to calculate loglikelihood from
 alpha (float, optional) – Constant that multiplies the penalty terms. If the same alpha was used during training, exact
coefficients are used, otherwise coefficients are interpolated from the closest alpha values that
were used during training. If set to
None
, the last alpha in the solution path is used.
Returns: T – The predicted decision function
Return type: array, shape = (n_samples,)

predict_cumulative_hazard_function
(X, alpha=None)¶ Predict cumulative hazard function.
Only available if
fit()
has been called with fit_baseline_model = True.The cumulative hazard function for an individual with feature vector \(x_\alpha\) is defined as
\[H(t \mid x_\alpha) = \exp(x_\alpha^\top \beta) H_0(t) ,\]where \(H_0(t)\) is the baseline hazard function, estimated by Breslow’s estimator.
Parameters:  X (arraylike, shape = (n_samples, n_features)) – Data matrix.
 alpha (float, optional) – Constant that multiplies the penalty terms. The same alpha as used during training
must be specified. If set to
None
, the last alpha in the solution path is used.
Returns: cum_hazard – Predicted cumulative hazard functions.
Return type: ndarray, shape = (n_samples,)

predict_survival_function
(X, alpha=None)¶ Predict survival function.
Only available if
fit()
has been called with fit_baseline_model = True.The survival function for an individual with feature vector \(x_\alpha\) is defined as
\[S(t \mid x_\alpha) = S_0(t)^{\exp(x_\alpha^\top \beta)} ,\]where \(S_0(t)\) is the baseline survival function, estimated by Breslow’s estimator.
Parameters:  X (arraylike, shape = (n_samples, n_features)) – Data matrix.
 alpha (float, optional) – Constant that multiplies the penalty terms. The same alpha as used during training
must be specified. If set to
None
, the last alpha in the solution path is used.
Returns: survival – Predicted survival functions.
Return type: ndarray, shape = (n_samples,)

score
(X, y)¶ Returns the concordance index of the prediction.
Parameters:  X (arraylike, shape = (n_samples, n_features)) – Test samples.
 y (structured array, shape = (n_samples,)) – A structured array containing the binary event indicator as first field, and time of event or time of censoring as second field.
Returns: cindex – Estimated concordance index.
Return type: float