skglm.datafits.Cox#

class skglm.datafits.Cox(use_efron=False)[source]#

Cox datafit for survival analysis.

Refer to Mathematics behind Cox datafit for details.

Parameters:
use_efronbool, default=False

If True uses Efron estimate to handle tied observations.

Attributes:
T_indicesarray-like, shape (n_samples,)

Indices of observations with the same occurrence times stacked horizontally as [group_1, group_2, ...] in ascending order. It is initialized with the .initialize method (or initialize_sparse for sparse X).

T_indptrarray-like, (np.unique(tm) + 1,)

Array where two consecutive elements delimit a group of observations having the same occurrence times.

H_indicesarray-like, shape (n_samples,)

Indices of uncensored observations with the same occurrence times stacked horizontally as [group_1, group_2, ...] in ascending order. It is initialized when calling the .initialize method (or initialize_sparse for sparse X) when use_efron=True.

H_indptrarray-like, shape (np.unique(tm[s != 0]) + 1,)

Array where two consecutive elements delimits a group of uncensored observations having the same occurrence time.

__init__(use_efron=False)[source]#

Methods

__init__([use_efron])

get_global_lipschitz(X, y)

get_global_lipschitz_sparse(X_data, ...)

get_spec()

Specify the numba types of the class attributes.

gradient(X, y, Xw)

Compute gradient of the datafit.

gradient_sparse(X_data, X_indptr, X_indices, ...)

Compute gradient of the datafit in case X is sparse.

initialize(X, y)

Initialize the datafit attributes.

initialize_sparse(X_data, X_indptr, X_indices, y)

Initialize the datafit attributes in sparse dataset case.

params_to_dict()

Get the parameters to initialize an instance of the class.

raw_grad(y, Xw)

Compute gradient of datafit w.r.t.

raw_hessian(y, Xw)

Compute a diagonal upper bound of the datafit's Hessian w.r.t.

value(y, w, Xw)

Compute the value of the datafit.