コード例 #1
0
ファイル: hawkes_em.py プロジェクト: zhangxinsheng/tick
    def fit(self,
            events,
            end_times=None,
            baseline_start=None,
            kernel_start=None):
        """Fit the model according to the given training data.

        Parameters
        ----------
        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-dimensional `numpy.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.

        baseline_start : `None` or `np.ndarray`, shape=(n_nodes), default=None
            Used to force start values for baseline parameter
            If `None` starts with uniform 1 values

        kernel_start : `None` or `np.ndarray`, shape=(n_nodes, n_nodes, kernel_size), default=None
            Used to force start values for kernel parameter
            If `None` starts with random values
        """
        LearnerHawkesNoParam.fit(self, events, end_times=end_times)
        self.solve(baseline_start=baseline_start, kernel_start=kernel_start)
        return self
コード例 #2
0
    def fit(self, events, end_times=None, adjacency_start=None, R_start=None):
        """Fit the model according to the given training data.

        Parameters
        ----------
        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-dimensional `numpy.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` and `R_start` is also `None`, 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`
        """
        LearnerHawkesNoParam.fit(self, events, end_times=end_times)
        self.solve(adjacency_start=adjacency_start, R_start=R_start)