cenreg package — cenreg 0.0.4 documentation

# cenreg package

## Subpackages

- cenreg.distribution package
  - Submodules
  - cenreg.distribution.empirical module
    - `EmpiricalCDF`
      - `EmpiricalCDF.average_cdf()`
      - `EmpiricalCDF.cdf()`
      - `EmpiricalCDF.icdf()`
      - `EmpiricalCDF.set()`
  - cenreg.distribution.linear module
    - `LinearCDF`
      - `LinearCDF.average_cdf()`
      - `LinearCDF.cdf()`
      - `LinearCDF.get_boundary_lengths()`
      - `LinearCDF.icdf()`
      - `LinearCDF.set_knot_values()`
    - `LinearQuantileFunction`
      - `LinearQuantileFunction.average_cdf()`
      - `LinearQuantileFunction.cdf()`
      - `LinearQuantileFunction.get_qk_lengths()`
      - `LinearQuantileFunction.icdf()`
      - `LinearQuantileFunction.set_knot_values()`
  - Module contents
- cenreg.metric package
  - Submodules
  - cenreg.metric.cdf module
    - `brier()`
    - `km_calibration()`
    - `negative_loglikelihood()`
    - `nll_sc()`
    - `ranked_probability_score()`
  - cenreg.metric.cjd module
    - `brier()`
    - `kolmogorov_smirnov_calibration_error()`
    - `negative_loglikelihood()`
    - `ranked_probability_score()`
  - cenreg.metric.quantile module
    - `d_calibration()`
  - Module contents
- cenreg.model package
  - Submodules
  - cenreg.model.F2cjd_np module
    - `convert()`
  - cenreg.model.cjd2F_np module
    - `cjd2surv()`
  - cenreg.model.copula_graphic module
    - `CopulaGraphicDistribution`
      - `CopulaGraphicDistribution.average_cdf()`
      - `CopulaGraphicDistribution.cdf()`
      - `CopulaGraphicDistribution.icdf()`
      - `CopulaGraphicDistribution.survival_function()`
    - `estimate()`
  - cenreg.model.copula_np module
    - `FrankCopula`
      - `FrankCopula.cdf()`
    - `IndependenceCopula`
      - `IndependenceCopula.cdf()`
    - `SurvivalCopula`
      - `SurvivalCopula.cdf()`
    - `create()`
  - cenreg.model.kaplan_meier module
    - `KaplanMeierDistribution`
      - `KaplanMeierDistribution.average_cdf()`
      - `KaplanMeierDistribution.cdf()`
      - `KaplanMeierDistribution.fit()`
      - `KaplanMeierDistribution.icdf()`
      - `KaplanMeierDistribution.survival_function()`
    - `createCdfLinear()`
    - `createQuantilesLinear()`
  - Module contents
    - `cjd2surv()`
- cenreg.pytorch package
  - Submodules
  - cenreg.pytorch.cjd2F module
    - `MseModel`
      - `MseModel.configure_optimizers()`
      - `MseModel.forward()`
      - `MseModel.loss()`
    - `minimize_mse()`
  - cenreg.pytorch.copula_torch module
    - `ClaytonCopula`
      - `ClaytonCopula.cdf()`
    - `FrankCopula`
      - `FrankCopula.cdf()`
    - `GumbelCopula`
      - `GumbelCopula.cdf()`
    - `IndependenceCopula`
      - `IndependenceCopula.cdf()`
    - `SurvivalCopula`
      - `SurvivalCopula.cdf()`
    - `create()`
  - cenreg.pytorch.datamodule module
    - `ProbDataModule`
      - `ProbDataModule.test_dataloader()`
      - `ProbDataModule.train_dataloader()`
      - `ProbDataModule.val_dataloader()`
    - `ProbDataset`
      - `ProbDataset.len_feature()`
    - `SurvDataModule`
      - `SurvDataModule.test_dataloader()`
      - `SurvDataModule.train_dataloader()`
      - `SurvDataModule.val_dataloader()`
    - `SurvDataset`
      - `SurvDataset.len_feature()`
  - cenreg.pytorch.distribution module
    - `LinearCDF`
      - `LinearCDF.average_cdf()`
      - `LinearCDF.cdf()`
      - `LinearCDF.get_boundary_lengths()`
      - `LinearCDF.icdf()`
      - `LinearCDF.set_knot_values()`
    - `LinearQuantileFunction`
      - `LinearQuantileFunction.average_cdf()`
      - `LinearQuantileFunction.cdf()`
      - `LinearQuantileFunction.get_qk_lengths()`
      - `LinearQuantileFunction.icdf()`
      - `LinearQuantileFunction.set_knot_values()`
  - cenreg.pytorch.loss_cdf module
    - `Brier`
      - `Brier.loss()`
    - `CNLL_CR`
      - `CNLL_CR.loss()`
    - `NegativeLogLikelihood`
      - `NegativeLogLikelihood.loss()`
    - `RankedProbabilityScore`
      - `RankedProbabilityScore.loss()`
    - `brier()`
    - `negative_log_likelihood()`
    - `ranked_probability_score()`
  - cenreg.pytorch.loss_cjd module
    - `Brier`
      - `Brier.loss()`
    - `NegativeLogLikelihood`
      - `NegativeLogLikelihood.loss()`
    - `RankedProbabilityScore`
      - `RankedProbabilityScore.loss()`
  - cenreg.pytorch.loss_cont module
    - `CopulaNegativeLogLikelihood`
      - `CopulaNegativeLogLikelihood.loss()`
    - `NegativeLogLikelihood`
      - `NegativeLogLikelihood.loss()`
  - cenreg.pytorch.mlp module
    - `Linear`
      - `Linear.forward()`
    - `MLP`
      - `MLP.forward()`
    - `MLP_MultiHead`
      - `MLP_MultiHead.forward()`
    - `SMM`
      - `SMM.forward()`
    - `SMM_MultiHead`
      - `SMM_MultiHead.forward()`
  - cenreg.pytorch.utils module
    - `denormalize_pred()`
    - `normalize_y()`
  - Module contents

## 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