sksurv.linear_model.CoxPHSurvivalAnalysis

class sksurv.linear_model.CoxPHSurvivalAnalysis(alpha=0, ties='breslow', n_iter=100, tol=1e-09, verbose=0)

Cox proportional hazards model.

There are two possible choices for handling tied event times. The default is Breslow’s method, which considers each of the events at a given time as distinct. Efron’s method is more accurate if there are a large number of ties. When the number of ties is small, the estimated coefficients by Breslow’s and Efron’s method are quite close. Uses Newton-Raphson optimization.

See [1], [2], [3] for further description.

Parameters:
  • alpha (float, optional, default: 0) – Regularization parameter for ridge regression penalty.
  • ties ("breslow" | "efron", optional, default: "breslow") – The method to handle tied event times. If there are no tied event times all the methods are equivalent.
  • n_iter (int, optional, default: 100) – Maximum number of iterations.
  • tol (float, optional, default: 1e-9) –

    Convergence criteria. Convergence is based on the negative log-likelihood:

    |1 - (new neg. log-likelihood / old neg. log-likelihood) | < tol
    
  • verbose (int, optional, default: 0) – Specified the amount of additional debug information during optimization.
coef_

Coefficients of the model

Type:ndarray, shape = (n_features,)
cum_baseline_hazard_

Estimated baseline cumulative hazard function.

Type:sksurv.functions.StepFunction
baseline_survival_

Estimated baseline survival function.

Type:sksurv.functions.StepFunction

References

[1]Cox, D. R. Regression models and life tables (with discussion). Journal of the Royal Statistical Society. Series B, 34, 187-220, 1972.
[2]Breslow, N. E. Covariance Analysis of Censored Survival Data. Biometrics 30 (1974): 89–99.
[3]Efron, B. The Efficiency of Cox’s Likelihood Function for Censored Data. Journal of the American Statistical Association 72 (1977): 557–565.
__init__(alpha=0, ties='breslow', n_iter=100, tol=1e-09, verbose=0)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([alpha, ties, n_iter, tol, verbose]) Initialize self.
fit(X, y) Minimize negative partial log-likelihood for provided data.
predict(X) Predict risk scores.
predict_cumulative_hazard_function(X) Predict cumulative hazard function.
predict_survival_function(X) Predict survival function.
score(X, y) Returns the concordance index of the prediction.

Attributes

baseline_survival_
cum_baseline_hazard_
fit(X, y)

Minimize negative partial log-likelihood for provided data.

Parameters:
  • X (array-like, 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)

Predict risk scores.

Parameters:X (array-like, shape = (n_samples, n_features)) – Data matrix.
Returns:risk_score – Predicted risk scores.
Return type:array, shape = (n_samples,)
predict_cumulative_hazard_function(X)

Predict cumulative hazard function.

The cumulative hazard function for an individual with feature vector \(x\) is defined as

\[H(t \mid x) = \exp(x^\top \beta) H_0(t) ,\]

where \(H_0(t)\) is the baseline hazard function, estimated by Breslow’s estimator.

Parameters:X (array-like, shape = (n_samples, n_features)) – Data matrix.
Returns:cum_hazard – Predicted cumulative hazard functions.
Return type:ndarray, shape = (n_samples,)
predict_survival_function(X)

Predict survival function.

The survival function for an individual with feature vector \(x\) is defined as

\[S(t \mid x) = S_0(t)^{\exp(x^\top \beta)} ,\]

where \(S_0(t)\) is the baseline survival function, estimated by Breslow’s estimator.

Parameters:X (array-like, shape = (n_samples, n_features)) – Data matrix.
Returns:survival – Predicted survival functions.
Return type:ndarray, shape = (n_samples,)
score(X, y)

Returns the concordance index of the prediction.

Parameters:
  • X (array-like, 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