def set_data(self, data, ignore_feat=True): """ :param data: a TxKxV tensor of event-feature map where T- time; K- process id; V- corresponding feature vector :input feature: V+1 features, [V features, 1 bias], bias- denotes recency """ assert isinstance( data, np.ndarray ) and data.ndim == 3, "data needs to be a TxKxV tensor of event features" self.update_K(data.shape[1]) self.F = data.shape[2] - 1 # calculate linear mark function: F expected to be KxKxTxF tensor if self.F < 1 or ignore_feat: f_mat = None self.F = 0 else: f_mat = data[:, :, :-1] if self.F > 0: self.v = 1e-3 * np.ones((self.K, self.F)) self.win = np.array([ self.basis(i / float(self.dt), **self.basis_args) for i in xrange(data.shape[0]) ]) self.data = data # orignal event features, shape: TxKxF # convolve data with windowed signal self.conv_data = np.concatenate([ convolve(data[:, k, -1], self.win)[:, None] for k in xrange(data.shape[1]) ], axis=1) self.conv_data_fea = f_mat # convolved to feature matrix, shape: TxKxF
def set_data(self, data, dyadic_data, ignore_feat=True): """ :param dyadic_data: expect dyadic interaction data between processes, shape: KxKxT """ assert isinstance(dyadic_data, np.ndarray) and data.ndim == 3, "dyadic_data needs be a KxKxT tensor of interaction events" super(LinearDiscreteHawkes, self).set_data(data, ignore_feat) self.conv_dyad_data = dyadic_data # convolution step for k1 in xrange(self.conv_dyad_data.shape[0]): for k2 in xrange(self.conv_dyad_data.shape[1]): self.conv_dyad_data[k1, k2, :] = self.conv_dyad_data[k1, k2, :] + convolve(self.conv_dyad_data[k1, k2, :], self.win)
def set_data(self, data, dyadic_data, ignore_feat=True): """ :param dyadic_data: expect dyadic interaction data between processes, shape: KxKxT """ assert isinstance( dyadic_data, np.ndarray ) and data.ndim == 3, "dyadic_data needs be a KxKxT tensor of interaction events" super(LinearDiscreteHawkes, self).set_data(data, ignore_feat) self.conv_dyad_data = dyadic_data # convolution step for k1 in xrange(self.conv_dyad_data.shape[0]): for k2 in xrange(self.conv_dyad_data.shape[1]): self.conv_dyad_data[ k1, k2, :] = self.conv_dyad_data[k1, k2, :] + convolve( self.conv_dyad_data[k1, k2, :], self.win)
def set_data(self, data, ignore_feat=True): """ :param data: a TxKxV tensor of event-feature map where T- time; K- process id; V- corresponding feature vector :input feature: V+1 features, [V features, 1 bias], bias- denotes recency """ assert isinstance(data, np.ndarray) and data.ndim == 3, "data needs to be a TxKxV tensor of event features" self.update_K(data.shape[1]) self.F = data.shape[2]-1 # calculate linear mark function: F expected to be KxKxTxF tensor if self.F < 1 or ignore_feat: f_mat = None self.F = 0 else: f_mat = data[:, :, :-1] if self.F > 0: self.v = 1e-3 * np.ones((self.K, self.F)) self.win = np.array([self.basis(i/float(self.dt), **self.basis_args) for i in xrange(data.shape[0])]) self.data = data # orignal event features, shape: TxKxF # convolve data with windowed signal self.conv_data = np.concatenate([convolve(data[:, k, -1], self.win)[:, None] for k in xrange(data.shape[1])], axis=1) self.conv_data_fea = f_mat # convolved to feature matrix, shape: TxKxF