Esempio n. 1
0
    def __init__(self, data, T, alpha_beta):
        assert isinstance(data, scipy.sparse.csr.csr_matrix)
        self.D, self.V = data.shape
        self.T = T
        self.alpha_beta = alpha_beta

        self.data = data

        self.pyrngs = initialize_pyrngs()

        self.initialize_beta()
        self.initialize_theta()
        self.z = np.zeros((data.data.shape[0], T), dtype="uint32")
        self.resample_z()

        # precompute
        self._training_gammalns = gammaln(data.sum(1) + 1).sum() - gammaln(data.data + 1).sum()
Esempio n. 2
0
    def __init__(self, data, T, alpha_beta):
        assert isinstance(data, scipy.sparse.csr.csr_matrix)
        self.D, self.V = data.shape
        self.T = T
        self.alpha_beta = alpha_beta

        self.data = data

        self.pyrngs = initialize_pyrngs()

        self.initialize_beta()
        self.initialize_theta()
        self.z = np.zeros((data.data.shape[0], T), dtype='uint32')
        self.resample_z()

        # precompute
        self._training_gammalns = \
            gammaln(data.sum(1)+1).sum() - gammaln(data.data+1).sum()
Esempio n. 3
0
    def __init__(self, data, timestamps, K, alpha_theta):
        assert isinstance(data, scipy.sparse.csr.csr_matrix)
        self.alpha_theta = alpha_theta
        self.D, self.V = data.shape
        self.K = K

        self.data = data

        self.timestamps = timestamps
        self.timeidx = self._get_timeidx(timestamps, data)
        self.T = self.timeidx.max() - self.timeidx.min() + 1

        self.ppgs = initialize_polya_gamma_samplers()
        self.pyrngs = initialize_pyrngs()

        self.initialize_parameters()

        self._training_gammalns = gammaln(data.sum(1) + 1).sum() - gammaln(data.data + 1).sum()
Esempio n. 4
0
    def __init__(self, data, timestamps, K, alpha_theta):
        assert isinstance(data, scipy.sparse.csr.csr_matrix)
        self.alpha_theta = alpha_theta
        self.D, self.V = data.shape
        self.K = K

        self.data = data

        self.timestamps = timestamps
        self.timeidx = self._get_timeidx(timestamps, data)
        self.T = self.timeidx.max() - self.timeidx.min() + 1

        self.ppgs = initialize_polya_gamma_samplers()
        self.pyrngs = initialize_pyrngs()

        self.initialize_parameters()

        self._training_gammalns = \
            gammaln(data.sum(1)+1).sum() - gammaln(data.data+1).sum()