tick.hawkes.
HawkesCumulantMatching
(integration_support, C=1000.0, penalty='none', solver='adam', step=0.01, tol=1e-08, max_iter=1000, verbose=False, print_every=100, record_every=10, solver_kwargs=None, cs_ratio=None, elastic_net_ratio=0.95)[source]¶This class is used for performing non parametric estimation of multi-dimensional Hawkes processes based cumulant matching.
It does not make any assumptions on the kernel shape and recovers the kernel norms only.
This class relies on Tensorflow to perform the matching of the cumulants. If Tensorflow is not installed, it will not work.
integration_support : float
Controls the maximal lag (positive or negative) upon which we integrate the cumulant densities (covariance and skewness), this amounts to neglect border effects. In practice, this is a good approximation if the support of the kernels is smaller than integration support and if the spectral norm of the kernel norms is sufficiently distant from the critical value, namely 1. It denoted by \(H\) in the paper.
C : float
, default=1e3
Level of penalization
penalty : {‘l1’, ‘l2’, ‘elasticnet’, ‘none’}, default=’none’
The penalization to use. By default no penalization is used. Penalty is only applied to adjacency matrix.
solver : {‘momentum’, ‘adam’, ‘adagrad’, ‘rmsprop’, ‘adadelta’, ‘gd’}, default=’adam’
Name of tensorflow solver that will be used.
step : float
, default=1e-2
Initial step size used for learning. Also known as learning rate.
tol : float
, default=1e-8
The tolerance of the solver (iterations stop when the stopping criterion is below it). If not reached the solver does
max_iter
iterations
max_iter : int
, default=1000
Maximum number of iterations of the solver
verbose : bool
, default=False
If
True
, we verbose things, otherwise the solver does not print anything (but records information in history anyway)
print_every : int
, default=100
Print history information when
n_iter
(iteration number) is a multiple ofprint_every
record_every : int
, default=10
Record history information when
n_iter
(iteration number) is a multiple ofrecord_every
elastic_net_ratio : float
, default=0.95
Ratio of elastic net mixing parameter with 0 <= ratio <= 1.
For ratio = 0 this is ridge (L2 squared) regularization.
For ratio = 1 this is lasso (L1) regularization.
For 0 < ratio < 1, the regularization is a linear combination of L1 and L2.
Used in ‘elasticnet’ penalty
solver_kwargs : dict
, default=`None`
Extra arguments that will be passed to tensorflow solver
n_nodes : int
Number of nodes / components in the Hawkes model
baseline : np.array
, shape=(n_nodes,)
Inferred baseline of each component’s intensity
adjacency : np.ndarray
, shape=(n_nodes, n_nodes)
Inferred adjacency matrix
mean_intensity : list of np.array
shape=(n_nodes,)
Estimated mean intensities, named \(\widehat{L}\) in the paper
covariance : list of np.array
shape=(n_nodes,n_nodes)
Estimated integrated covariance, named \(\widehat{C}\) in the paper
skewness : list of np.array
shape=(n_nodes,n_nodes)
Estimated integrated skewness (sliced), named \(\widehat{K^c}\) in the paper
R : np.array
shape=(n_nodes,n_nodes)
Estimated weight, linked to the integrals of Hawkes kernels. Use to derive adjacency and baseline
References
Achab, M., Bacry, E., Gaïffas, S., Mastromatteo, I., & Muzy, J. F. (2017, July). Uncovering causality from multivariate Hawkes integrated cumulants. In International Conference on Machine Learning (pp. 1-10).
__init__
(integration_support, C=1000.0, penalty='none', solver='adam', step=0.01, tol=1e-08, max_iter=1000, verbose=False, print_every=100, record_every=10, solver_kwargs=None, cs_ratio=None, elastic_net_ratio=0.95)[source]¶Initialize self. See help(type(self)) for accurate signature.
approximate_optimal_cs_ratio
()[source]¶Heuristic to set covariance skewness ratio close to its optimal value
compute_cumulants
(force=False)[source]¶Compute estimated mean intensity, covariance and sliced skewness
force : bool
If
True
previously computed cumulants are not reused
fit
(events, end_times=None, adjacency_start=None, R_start=None)[source]¶Fit the model according to the given training data.
events : list
of list
of np.ndarray
List of Hawkes processes realizations. Each realization of the Hawkes process is a list of n_node for each component of the Hawkes. Namely
events[i][j]
contains a one-dimensionalnumpy.array
of the events’ timestamps of component j of realization i. If only one realization is given, it will be wrapped into a list
end_times : np.ndarray
or float
, default = None
List of end time of all hawkes processes that will be given to the model. If None, it will be set to each realization’s latest time. If only one realization is provided, then a float can be given.
adjacency_start : str
or np.ndarray, shape=(n_nodes + n_nodes * n_nodes,), default=`None
Initial guess for the adjacency matrix. Will be used as starting point in optimization. If
None
andR_start
is alsoNone
, a default starting point is estimated from the estimated cumulants If"random"
, a starting point is estimated from estimated cumulants with a bit a randomness
R_start : np.ndarray
, shape=(n_nodes, n_nodes), default=None
R variable at which we start optimization. Superseded by adjacency_start if adjacency_start is not
None
get_history
(key=None)¶Returns history of the solver
key : str
, default=None
If
None
all history is returned as adict
If
str
, name of the history element to retrieve
output : list
or dict
If
key
is None orkey
is not in history then output is a dict containing history of all keysIf
key
is the name of an element in the history, output is alist
containing the history of this element
get_kernel_norms
()[source]¶Computes kernel norms. This makes our learner compliant with
tick.plot.plot_hawkes_kernel_norms
API
norms : np.ndarray
, shape=(n_nodes, n_nodes)
2d array in which each entry i, j corresponds to the norm of kernel i, j
objective
(adjacency=None, R=None)[source]¶Compute objective value for a given adjacency or variable R
adjacency : np.ndarray
, shape=(n_nodes, n_nodes), default=None
Adjacency matrix at which we compute objective. If
None
, objective will be computed atR
R : np.ndarray
, shape=(n_nodes, n_nodes), default=None
R variable at which objective is computed. Superseded by adjacency if adjacency is not
None
Value of objective function :
tick.hawkes.HawkesCumulantMatching
¶