How to use the lifelines.utils.CensoringType function in lifelines

To help you get started, we’ve selected a few lifelines examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CamDavidsonPilon / lifelines / lifelines / fitters / kaplan_meier_fitter.py View on Github external
    @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
        ----------
github CamDavidsonPilon / lifelines / lifelines / fitters / coxph_fitter.py View on Github external
    @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.
github CamDavidsonPilon / lifelines / lifelines / fitters / nelson_aalen_fitter.py View on Github external
    @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
github CamDavidsonPilon / lifelines / lifelines / fitters / kaplan_meier_fitter.py View on Github external
    @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
        ----------
github CamDavidsonPilon / lifelines / lifelines / fitters / log_logistic_fitter.py View on Github external
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])
github CamDavidsonPilon / lifelines / lifelines / fitters / __init__.py View on Github external
    @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.
github CamDavidsonPilon / lifelines / lifelines / fitters / __init__.py View on Github external
    @utils.CensoringType.interval_censoring
    def fit_interval_censoring(self):
        # TODO
        pass
github CamDavidsonPilon / lifelines / lifelines / fitters / log_normal_fitter.py View on Github external
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])
github CamDavidsonPilon / lifelines / lifelines / fitters / __init__.py View on Github external
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