Skip to content

Commit a505bfc

Browse files
JOSS #3 (#78)
* fixed typos, added warning for ties * removed lines, added plots * cleanup * Address reviews on the Statement of Need Section --------- Co-authored-by: melodiemonod <[email protected]>
1 parent ffd6920 commit a505bfc

File tree

6 files changed

+454
-79
lines changed

6 files changed

+454
-79
lines changed

docs/notebooks/helpers_momentum.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def train_dataloader(self):
162162
batch_size=self.batch_size,
163163
num_workers=self.num_workers,
164164
persistent_workers=True,
165+
shuffle=True,
165166
)
166167

167168
def val_dataloader(self):

docs/notebooks/introduction.ipynb

Lines changed: 308 additions & 45 deletions
Large diffs are not rendered by default.

docs/notebooks/momentum.ipynb

Lines changed: 136 additions & 27 deletions
Large diffs are not rendered by default.

paper/paper.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ bibliography: paper.bib
4141

4242
# Statement of need
4343

44-
Survival analysis plays a crucial role in various domains, such as medicine, economics or engineering. Thus, sophisticated survival models sugin deep learning opens new opportunities to leverage complex dataset and relationships. However, no existing library provides the flexibility to define the survival model's parameters using a custom `PyTorch`-based neural network.
44+
Survival analysis plays a crucial role in various domains, such as medicine, economics or engineering. Sophisticated survival analysis using deep learning, often referred to as "deep survival analysis," unlocks new opportunities to leverage new data types and uncover intricate relationships.
45+
However, performing comprehensive deep survival analysis remain challenging. Key issues include the lack of flexibility in existing tools to define survival model parameters with custom architectures and limitations in handling complex, high-dimensional datasets. Indeed, existing frameworks often lack the computational efficiency necessary to process large datasets efficiently, making them less suitable for real-world applications where time and resource constraints are paramount.
4546

46-
\autoref{tab:bibliography} compares the functionalities of `TorchSurv` with those of
47+
To address these gaps, we propose a flexible, `PyTorch`-based library that allows users to define survival model parameters using custom neural network architectures. By combining computational efficiency with ease of use, this toolbox opens new opportunities to advance survival analysis research and application, making it more accessible and interpretable for practitioners across disciplines. \autoref{tab:bibliography} compares the functionalities of `TorchSurv` with those of
4748
`auton-survival` [@nagpal2022auton],
4849
`pycox` [@Kvamme2019pycox],
4950
`torchlife` [@torchlifeAbeywardana],

src/torchsurv/loss/cox.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ def neg_partial_log_likelihood(
9898
>>> time = torch.tensor([1., 2., 3., 4., 5.])
9999
>>> neg_partial_log_likelihood(log_hz, event, time) # default, mean of log likelihoods across patients
100100
tensor(1.0071)
101-
>>> neg_partial_log_likelihood(log_hz, event, time, reduction = 'sum') # sun of log likelihoods across patients
101+
>>> neg_partial_log_likelihood(log_hz, event, time, reduction = 'sum') # sum of log likelihoods across patients
102102
tensor(3.0214)
103103
>>> time = torch.tensor([1., 2., 2., 4., 5.]) # Dealing with ties (default: Efron)
104104
>>> neg_partial_log_likelihood(log_hz, event, time, ties_method = "efron")
105105
tensor(1.0873)
106-
>>> neg_partial_log_likelihood(log_hz, event, time, ties_method = "breslow") # Dealing with ties (Bfron)
106+
>>> neg_partial_log_likelihood(log_hz, event, time, ties_method = "breslow") # Dealing with ties (Breslow)
107107
tensor(1.0873)
108108
109109
References:
@@ -134,6 +134,10 @@ def neg_partial_log_likelihood(
134134
# if not ties, use traditional cox partial likelihood
135135
pll = _partial_likelihood_cox(log_hz_sorted, event_sorted)
136136
else:
137+
# add warning about ties
138+
warnings.warn(
139+
f"Ties in event time detected; using {ties_method}'s method to handle ties."
140+
)
137141
# if ties, use either efron or breslow approximation of partial likelihood
138142
if ties_method == "efron":
139143
pll = _partial_likelihood_efron(

src/torchsurv/stats/kaplan_meier.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,6 @@ def print_survival_table(self):
195195
for t, y in zip(self.time, self.km_est):
196196
print(f"{t:.2f}\t{y:.4f}")
197197

198-
x = torch.randn(1, 50, 50, 50)
199-
print(x.shape) # shows the shape of the tensor
200-
201198
def _compute_counts(
202199
self,
203200
) -> Tuple[torch.tensor, torch.tensor, torch.tensor, torch.tensor]:

0 commit comments

Comments
 (0)