tick.survival.
ModelCoxRegPartialLik
[source]¶Partial likelihood of the Cox regression model (proportional hazards). This class gives first order information (gradient and loss) for this model.
features : numpy.ndarray
, shape=(n_samples, n_features), (read-only)
The features matrix
times : numpy.ndarray
, shape = (n_samples,), (read-only)
Obverved times
censoring : numpy.ndarray
, shape = (n_samples,), (read-only)
Boolean indicator of censoring of each sample.
True
means true failure, namely non-censored time
n_samples : int
(read-only)
Number of samples
n_features : int
(read-only)
Number of features
n_failures : int
(read-only)
Number of true failure times
n_coeffs : int
(read-only)
Total number of coefficients of the model
censoring_rate : float
The censoring_rate (percentage of ???)
Notes
There is no intercept in this model
fit
(features: numpy.ndarray, times: numpy.array, censoring: numpy.array) → tick.base_model.model.Model[source]¶Set the data into the model object
features : numpy.ndarray
, shape=(n_samples, n_features)
The features matrix
times : numpy.array
, shape = (n_samples,)
Observed times
censoring : numpy.array
, shape = (n_samples,)
Indicator of censoring of each sample.
True
means true failure, namely non-censored time. dtype must be unsigned short
output : ModelCoxRegPartialLik
The current instance with given data
grad
(coeffs: numpy.ndarray, out: numpy.ndarray = None) → numpy.ndarray¶Computes the gradient of the model at coeffs
coeffs : numpy.ndarray
Vector where gradient is computed
out : numpy.ndarray
or None
If
None
a new vector containing the gradient is returned, otherwise, the result is saved inout
and returned
output : numpy.ndarray
The gradient of the model at
coeffs
Notes
The fit
method must be called to give data to the model,
before using grad
. An error is raised otherwise.
loss
(coeffs: numpy.ndarray) → float¶Computes the value of the goodness-of-fit at coeffs
coeffs : numpy.ndarray
The loss is computed at this point
output : float
The value of the loss
Notes
The fit
method must be called to give data to the model,
before using loss
. An error is raised otherwise.
loss_and_grad
(coeffs: numpy.ndarray, out: numpy.ndarray = None) → tuple¶Computes the value and the gradient of the function at
coeffs
coeffs : numpy.ndarray
Vector where the loss and gradient are computed
out : numpy.ndarray
or None
If
None
a new vector containing the gradient is returned, otherwise, the result is saved inout
and returned
loss : float
The value of the loss
grad : numpy.ndarray
The gradient of the model at
coeffs
Notes
The fit
method must be called to give data to the model,
before using loss_and_grad
. An error is raised otherwise.