Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@CensoringType.right_censoring
def fit(
self,
durations,
event_observed=None,
timeline=None,
entry=None,
label=None,
alpha=None,
ci_labels=None,
weights=None,
): # pylint: disable=too-many-arguments,too-many-locals
"""
Fit the model to a right-censored dataset
Parameters
----------
@CensoringType.right_censoring
def fit(
self,
df: pd.DataFrame,
duration_col: Optional[str] = None,
event_col: Optional[str] = None,
show_progress: bool = False,
initial_point: Optional[ndarray] = None,
strata: Optional[Union[str, List[str]]] = None,
step_size: Optional[float] = None,
weights_col: Optional[str] = None,
cluster_col: Optional[str] = None,
robust: bool = False,
batch_mode: Optional[bool] = None,
) -> "CoxPHFitter":
"""
Fit the Cox proportional hazard model to a dataset.
@CensoringType.right_censoring
def fit(
self,
durations,
event_observed=None,
timeline=None,
entry=None,
label=None,
alpha=None,
ci_labels=None,
weights=None,
): # pylint: disable=too-many-arguments
"""
Parameters
-----------
durations: an array, or pd.Series, of length n
duration subject was observed for
@CensoringType.left_censoring
def fit_left_censoring(
self,
durations,
event_observed=None,
timeline=None,
entry=None,
label=None,
alpha=None,
ci_labels=None,
weights=None,
):
"""
Fit the model to a left-censored dataset
Parameters
----------
def _create_initial_point(self, Ts, E, *args):
if CensoringType.is_right_censoring(self):
T = Ts[0]
elif CensoringType.is_left_censoring(self):
T = Ts[1]
elif CensoringType.is_interval_censoring(self):
T = Ts[1] - Ts[0]
return np.array([np.median(T), 1.0])
@utils.CensoringType.left_censoring
def fit_left_censoring(
self,
df,
duration_col=None,
event_col=None,
ancillary_df=None,
fit_intercept=None,
show_progress=False,
timeline=None,
weights_col=None,
robust=False,
initial_point=None,
entry_col=None,
) -> "ParametericAFTRegressionFitter":
"""
Fit the accelerated failure time model to a left-censored dataset.
@utils.CensoringType.interval_censoring
def fit_interval_censoring(self):
# TODO
pass
def _create_initial_point(self, Ts, E, *args):
if CensoringType.is_right_censoring(self):
log_T = np.log(Ts[0])
elif CensoringType.is_left_censoring(self):
log_T = np.log(Ts[1])
elif CensoringType.is_interval_censoring(self):
log_T = np.log(Ts[1])
return np.array([np.median(log_T), 1.0])
def __repr__(self) -> str:
classname = self._class_name
if self._label:
label_string = """"%s",""" % self._label
else:
label_string = ""
try:
s = """""" % (
classname,
label_string,
self.weights.sum(),
self.weights.sum() - self.weights[self.event_observed > 0].sum(),
utils.CensoringType.get_human_readable_censoring_type(self),
)
except AttributeError:
s = """""" % classname
return s