def __init__(self, data, S, w_augments, h_augments=None, num_bases=4, mask_zeros=False, **kwargs): PyMFBase.__init__(self, data, num_bases, **kwargs) if mask_zeros: mask = (data != 0).astype(int) else: mask = np.ones(data.shape) self.S = S * mask self.S_sqrt = np.sqrt(S) self.comp_S = (S - 1) * -1 self.w_augments = w_augments self.h_augments = h_augments S_shape = S.shape # Make sure augments have the right dimensions assert w_augments.shape[0] == S_shape[0] assert w_augments.shape[1] <= num_bases # set w_augments index m_range_w = list(range(0, S_shape[0])) n_range_w = list(range(num_bases - w_augments.shape[1], num_bases)) self.w_augments_idx = np.ix_(m_range_w, n_range_w)
def __init__(self, data, num_bases=4, augments=None, smoothness=100, **kwargs): # Setup self.num_bases = num_bases self.smoothness = smoothness data_shape = data.shape self.w_outer = data_shape[0] self.h_outer = data_shape[1] self.augments = augments if self.augments is not None: # Make sure augments have the right dimensions assert augments.shape[0] == data.shape[0] assert augments.shape[1] <= num_bases m_range = list(range(0, data.shape[0])) n_range = list(range(num_bases - augments.shape[1], num_bases)) self.augments_idx = np.ix_(m_range, n_range) PyMFBase.__init__(self, data, num_bases, **kwargs) self._parse_args(**kwargs)
def __init__(self, data, S, num_bases=4, mask_zeros=False, **kwargs): PyMFBase.__init__(self, data, num_bases, **kwargs) if mask_zeros: mask = (data != 0).astype(int) else: mask = np.ones(data.shape) self.S = S * mask self.S_sqrt = np.sqrt(S) self.comp_S = (S - 1) * -1
def __init__(self, data, num_bases=0, center_mean=True, **kwargs): PyMFBase.__init__(self, data, num_bases=num_bases) # center the data around the mean first self._center_mean = center_mean if self._center_mean: # copy the data before centering it self._data_orig = data self._meanv = self._data_orig[:,:].mean(axis=1).reshape(-1,1) self.data = self._data_orig - self._meanv else: self.data = data
def __init__(self, data, w_augments, h_augments=None, num_bases=4, **kwargs): PyMFBase.__init__(self, data, num_bases, **kwargs) self.w_augments = w_augments self.h_augments = h_augments S_shape = data.shape # Make sure augments have the right dimensions assert w_augments.shape[0] == S_shape[0] assert w_augments.shape[1] <= num_bases #assert h_augments.shape[0] == S_shape[1] # set w_augments index m_range_w = list(range(0, S_shape[0])) n_range_w = list(range(num_bases - w_augments.shape[1], num_bases)) self.w_augments_idx = np.ix_(m_range_w, n_range_w)
def __init__(self, data, k=-1, num_bases=4): # call inherited method PyMFBase.__init__(self, data, num_bases=num_bases) self._k = k if self._k == -1: self._k = num_bases
def __init__(self, data, num_bases=4, lamb=2.0): # call inherited method PyMFBase.__init__(self, data, num_bases=num_bases) self._lamb = lamb