def factorize(self, niter=10, compute_w=True, compute_h=True, show_progress=False, compute_err=True): """ Factorize s.t. WH = data Parameters ---------- niter : int number of iterations. show_progress : bool print some extra information to stdout. compute_h : bool iteratively update values for H. compute_w : bool iteratively update values for W. compute_err : bool compute Frobenius norm |data-WH| after each update and store it to .ferr[k]. Updated Values -------------- .W : updated values for W. .H : updated values for H. .ferr : Frobenius norm |data-WH| for each iteration. """ # init some learning parameters self._lamb_W = 1.0/niter self._lamb_H = 1.0/niter NMF.factorize(self, niter=niter, compute_w=compute_w, compute_h=compute_h, show_progress=show_progress, compute_err=compute_err)
def factorize(self, show_progress=False, compute_w=True, compute_h=True, compute_err=True, niter=1): """ Factorize s.t. WH = data Parameters ---------- show_progress : bool print some extra information to stdout. compute_h : bool iteratively update values for H. compute_w : bool iteratively update values for W. compute_err : bool compute Frobenius norm |data-WH| after each update and store it to .ferr[k]. Updated Values -------------- .W : updated values for W. .H : updated values for H. .ferr : Frobenius norm |data-WH|. """ NMF.factorize(self, niter=1, show_progress=show_progress, compute_w=compute_w, compute_h=compute_h, compute_err=compute_err)
def factorize(self, show_progress=False, compute_w=True, compute_h=True, compute_err=True, niter=1): """ Factorize s.t. WH = data Parameters ---------- show_progress : bool print some extra information to stdout. compute_h : bool iteratively update values for H. compute_w : bool iteratively update values for W. compute_err : bool compute Frobenius norm |data-WH| after each update and store it to .ferr[k]. Updated Values -------------- .W : updated values for W. .H : updated values for H. .ferr : Frobenius norm |data-WH|. """ NMF.factorize(self, niter=1, show_progress=show_progress, compute_w=compute_w, compute_h=compute_h, compute_err=compute_err)
def factorize(self, niter=1, show_progress=False, compute_w=True, compute_h=True, compute_err=True): # enforce certain default values, otherwise it won't work NMF.factorize(self, niter=1, show_progress=show_progress, compute_w=True, compute_h=True, compute_err=compute_err)
def update_h(self): print self._method if self._method == 'pca': self.H = np.dot(pinv(self.W), self.data) if self._method == 'nmf': mdl = NMF(self.data, num_bases=self._num_bases) mdl.W = self.W mdl.factorize(compute_w=False, niter=50) self.H = mdl.H.copy() if self._method == 'aa': mdl = AA(self.data, num_bases=self._num_bases) mdl.W = self.W mdl.factorize(compute_w=False) self.H = mdl.H.copy()
def update_h(self): print self._method if self._method == 'pca': self.H = np.dot(pinv(self.W), self.data) if self._method == 'nmf': mdl = NMF(self.data, num_bases=self._num_bases) mdl.W = self.W mdl.factorize(compute_w=False, niter=50) self.H = mdl.H.copy() if self._method == 'aa': mdl = AA(self.data, num_bases=self._num_bases) mdl.W = self.W mdl.factorize(compute_w=False) self.H = mdl.H.copy()
def factorize(self, niter=1, show_progress=False, compute_w=True, compute_h=True, compute_err=True): # enforce certain default values, otherwise it won't work NMF.factorize(self, niter=1, show_progress=show_progress, compute_w=True, compute_h=True, compute_err=compute_err)