Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
344651c
homogeneize fadin and unhap init arguments
vloison Jul 4, 2025
6eac89d
fix compute_gradient
vloison Jul 4, 2025
76f811a
fix unhap moment matching
vloison Jul 4, 2025
979626b
update readme
vloison Jul 7, 2025
7df13a2
small readme update
vloison Jul 7, 2025
c0eda90
add moment matchig test
vloison Jul 8, 2025
4069217
minor changes
vloison Jul 8, 2025
0b8a32c
fix linter
vloison Jul 8, 2025
c93e84a
add unhap ecg experiments
vloison Jul 8, 2025
77046f4
add utils
vloison Jul 8, 2025
d6b29b8
add stocunhap option to unhap
vloison Jul 8, 2025
891598d
Update README.md
vloison Jul 9, 2025
3cb77b0
Update README.md
vloison Jul 9, 2025
da89433
Update fadin/loss_and_gradient.py
vloison Jul 9, 2025
f414269
Update fadin/solver.py
vloison Jul 9, 2025
a69dcf4
add simulate_marked_data to utils_simu
vloison Jul 9, 2025
9a1eab6
update docstrings, add _ to solver attributes.
vloison Jul 9, 2025
a088838
update solver attributes: params_intens to private, add public baseli…
vloison Jul 9, 2025
95481e1
update utils examples and tests with new solver attributes
vloison Jul 9, 2025
ce378ac
add attributes test
vloison Jul 9, 2025
24aab0e
minor changes
vloison Jul 9, 2025
ccd659e
fix plot
vloison Jul 9, 2025
26fecd9
rename UNHaP rho_ attribute
vloison Jul 9, 2025
4157a85
update ecg experiment with attributes
vloison Jul 9, 2025
8f1cc0f
add gait experiments
vloison Jul 9, 2025
eb67efc
remove unused function in gait experiment
vloison Jul 9, 2025
a93c4d9
minor changes
vloison Jul 9, 2025
a1b05ac
add unhap experiments on simulated data
vloison Jul 11, 2025
464db70
linter fix
vloison Jul 11, 2025
34a60ae
Update README.md
vloison Jul 15, 2025
8ad23c5
Update README.md
vloison Jul 15, 2025
9f7e9cc
Update README.md
vloison Jul 15, 2025
55b95b9
Update README.md
vloison Jul 15, 2025
5220903
Update fadin/utils/utils_simu.py
vloison Jul 15, 2025
bbd4edd
Update fadin/utils/utils_simu.py
vloison Jul 15, 2025
a1fc636
Update README.md
vloison Jul 15, 2025
c762783
Update fadin/utils/utils_simu.py
vloison Jul 15, 2025
dc19cf5
Update fadin/utils/utils_simu.py
vloison Jul 15, 2025
50c2538
minor changes to readme
vloison Jul 15, 2025
409eb65
add doc for events
vloison Jul 15, 2025
ddcb368
update pyproject.toml and readme with experiment dependencies
vloison Jul 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# FaDIn: Fast Discretized Inference For Hawkes Processes with General Parametric Kernels
# UNHaP: Unmixing Noise from Hawkes Processes
Comment thread
vloison marked this conversation as resolved.
Outdated

![build](https://img.shields.io/github/actions/workflow/status/GuillaumeStaermanML/FaDIn/unit_tests.yml?event=push&style=for-the-badge)
![python version](https://img.shields.io/badge/python-3.7_|_3.8_|_3.9_|_3.10_|_3.11-blue?style=for-the-badge)
![license](https://img.shields.io/github/license/GuillaumeStaermanML/FaDIn?style=for-the-badge)
![code style](https://img.shields.io/badge/code_style-black-black?style=for-the-badge)

This Package implements FaDIn.
This package implements FaDIn and UNHaP. FaDIn and UNHaP are solvers for inference of Hawkes Processes with finite-support kernels on simulated or real data, with the following features:
Comment thread
vloison marked this conversation as resolved.
Outdated
- Computation time is low compared to other methods.
- Compatible in an univariate setting as well as a multivariate setting.
Comment thread
vloison marked this conversation as resolved.
Outdated
- Classical kernels (exponential truncated gaussian, raised cosine) are implemented. The user can add their own kernel for inference.
Comment thread
vloison marked this conversation as resolved.
Outdated
- Masking: if only a few Hawkes Parameters need to be inferred, the user can mask the other parameters.
Comment thread
vloison marked this conversation as resolved.
Outdated
- Smart initialization of parameters before optimization: the user can choose between `random` (purely random), `moment_matching_max` (moment matching with maximum mode) and `moment_matching_mean` (moment matching with mean mode).

## Installation

**To install this package, make sure you have an up-to-date version of** `pip`.
[FaDIn](https://proceedings.mlr.press/v202/staerman23a/staerman23a.pdf) does classical Hawkes inference with gradient descent.
[UNHaP](https://raw.githubusercontent.com/mlresearch/v258/main/assets/loison25a/loison25a.pdf) does Hawkes inference where the Hawkes Process is marked and mixed with a noisy Poisson process.


## Installation

**To install this package, make sure you have an up-to-date version of** `pip`.
```bash
python3 -m pip install --upgrade pip
```
### From PyPI (coming soon)

In a dedicated Python env, run:
Expand Down Expand Up @@ -41,6 +53,12 @@ pip install -e ".[dev]"
pre-commit install
```

## Short examples
A few illustrative examples are provided in the `examples` folder of this repository:
Comment thread
vloison marked this conversation as resolved.
Outdated
- `plot_univariate_fadin`: simulate an univariate unmarked Hawkes process, infer Hawkes Process parameters using FaDIn, and plot inferred kernel.
- `plot_multivariate_fadin`: same as `plot_univariate_fadin` but in the multivariate case.
- `plot_unhap`: simulate an univariate marked Hawkes process and a marked Poisson process, infer Hawkes Process parameters using UNHaP, ald plot inferred kernels.

## Citing this work

If this package was useful to you, please cite it in your work:
Expand All @@ -54,4 +72,12 @@ If this package was useful to you, please cite it in your work:
year={2023},
organization={PMLR}
}

@improceedings{loison2025unhap,
Comment thread
vloison marked this conversation as resolved.
Outdated
title={UNHaP: Unmixing Noise from Hawkes Process},
author={Loison, Virginie and Staerman, Guillaume and Moreau, Thomas},
booktitle={International Conference on Artificial Intelligence and Statistics},
pages={1342--1350},
year={2025}
}
```
8 changes: 4 additions & 4 deletions examples/plot_unhap.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
# %% Create the simulating function


def simulate_data(baseline, baseline_noise, alpha, end_time, seed=0):
def simulate_marked_data(baseline, baseline_noise, alpha, end_time, seed=0):
n_dim = len(baseline)

marks_kernel = identity
Expand Down Expand Up @@ -102,15 +102,15 @@ def simulate_data(baseline, baseline_noise, alpha, end_time, seed=0):
np.zeros(marked_events[i].shape[0] + noisy_events_[i].shape[0])
for i in range(n_dim)
]
labels[0][-marked_events[0].shape[0] :] = 1.0
labels[0][-marked_events[0].shape[0]:] = 1.0
true_rho = [labels[i][events[i][:, 0].argsort()] for i in range(n_dim)]
# put the mark to one to test the impact of the marks
# events_cat[0][:, 1] = 1.

return events_cat, noisy_marks, true_rho


ev, noisy_marks, true_rho = simulate_data(
ev, noisy_marks, true_rho = simulate_marked_data(
baseline, baseline_noise.item(), alpha, end_time, seed=0
)
# %% Apply UNHAP
Expand All @@ -119,14 +119,14 @@ def simulate_data(baseline, baseline_noise, alpha, end_time, seed=0):
n_dim=1,
kernel="truncated_gaussian",
kernel_length=1.0,
init='moment_matching_mean',
delta=delta,
optim="RMSprop",
params_optim={"lr": 1e-3},
max_iter=max_iter,
batch_rho=batch_rho,
density_hawkes="linear",
density_noise="uniform",
moment_matching=True,
)
solver.fit(ev, end_time)

Expand Down
Loading