Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculation of NHP's log-likelihood #43

Open
HaochenWang1243 opened this issue Sep 18, 2024 · 3 comments
Open

Calculation of NHP's log-likelihood #43

HaochenWang1243 opened this issue Sep 18, 2024 · 3 comments

Comments

@HaochenWang1243
Copy link

HaochenWang1243 commented Sep 18, 2024

Hi. I have doubts on how the code calculates NHP's log-likelihood, which is specified by equation (8) in the NHP paper:
Screenshot 2024-09-18 at 14 54 42

The former part of equation (8) is the sum of individual-type log intensities at all event occurrences. In the compute_loglikelihood method in torch_basemodel.py, however, I saw the type dimension (last dimension) of lambda_at_event is summed:

event_lambdas = torch.sum(lambda_at_event * lambda_type_mask, dim=-1) + self.eps
which doesn't seem to comply with equation (8) shown above. FYI, the caller of this method in NHP is
event_ll, non_event_ll, num_events = self.compute_loglikelihood(lambda_at_event=lambda_at_event,
where lambda_at_event has shape [batch_size, num_times=max_len-1, num_event_types], as the comments mentioned.

The latter part of equation (8), according to Algorithm 1 of the NHP paper:
Screenshot 2024-09-18 at 15 40 10
is calculated by uniformly sampling the intensity function over the whole time frame of the event sequence. In the code, however, it seems like the sampling is done by drawing equidistant samples in each inter-event interval:

# for every batch and every event point => do a sampling (num_mc_sampling)
which, I imagine, can give quite different results from uniform sampling for event sequences of large inter-event-time variance.

Maybe I'm missing something. Thank you for your help.

@iLampard
Copy link
Collaborator

Hi,

Regarding the sampling method used here, we are working on to publish a newer version to fix relevant issues. this will be done shortly.

@HaochenWang1243
Copy link
Author

Thank you. It'll be really helpful to my research. For now it's a bit hard to reproduce the results in the original papers.

@iLampard
Copy link
Collaborator

We will have quite a few PRs in next month, fixing the potential problems in loglike computation, some inconsistency in reproducing models and other issues.

Besides, we will issue a tech report to explain the details of implementation and re-publish the experiment results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants