cenreg package

Subpackages

Submodules

cenreg.utils module

cenreg.utils.create_bins(max_y: float, min_y: float = 0.0, num_bins=10, algorithm: str = 'even') ndarray

Create bins for discretizing a continuous variable. This function generates evenly spaced bins between min_y and max_y with num_bins-2 intervals, and generates an additional bin at the end to include the value exceeding max_y.

Parameters:
  • max_y (float) – Maximum value of y.

  • min_y (float) – Minimum value of y.

  • num_bins (int) – Number of bins.

Returns:

bins – Array of bin edges.

Return type:

np.ndarray

cenreg.utils.create_discretized_labels(bins: ndarray, num_risks: int, t: ndarray, e: ndarray) ndarray

Create discretized labels for survival analysis.

Parameters:
  • bins (np.ndarray) – Array of bin edges.

  • num_risks (int) – Number of risks (or categories) to be assigned to each bin.

  • t (np.ndarray) – Array of time values.

  • e (np.ndarray) – Array of event indicators (1 for event, 0 for censored).

Returns:

Array of discretized labels, where each label corresponds to a bin and a risk category.

Return type:

np.ndarray

Module contents