def run(self,iterations):
     """ Run the Gibbs sampler for the specified number of iterations. """
     self.all_U = numpy.zeros((iterations,self.I,self.K))  
     self.all_V = numpy.zeros((iterations,self.J,self.K))   
     self.all_tau = numpy.zeros(iterations) 
     self.all_times = []
     self.all_performances = { metric: [] for metric in METRICS } 
     
     time_start = time.time()
     for it in range(iterations):
         # Update the random variables
         self.U = update_U_gaussian_volumeprior_nonnegative(
             gamma=self.gamma, R=self.R, M=self.M, U=self.U, V=self.V, tau=self.tau) 
         self.V = update_V_gaussian_gaussian_multivariate(
             lamb=self.lamb, R=self.R, M=self.M, U=self.U, tau=self.tau)
         self.tau = update_tau_gaussian(
             alpha=self.alpha, beta=self.beta, R=self.R, M=self.M, U=self.U, V=self.V)
         
         # Store the draws
         self.all_U[it], self.all_V[it] = numpy.copy(self.U), numpy.copy(self.V)
         self.all_tau[it] = self.tau
         
         # Print the performance, store performance and time
         perf = self.predict_while_running()
         for metric in METRICS:
             self.all_performances[metric].append(perf[metric])
         time_iteration = time.time()
         self.all_times.append(time_iteration-time_start)   
         print "Iteration %s. MSE: %s. R^2: %s. Rp: %s." % (it+1,perf['MSE'],perf['R^2'],perf['Rp'])
 def run(self,iterations):
     """ Run the Gibbs sampler for the specified number of iterations. """
     self.all_U = numpy.zeros((iterations,self.I,self.K))  
     self.all_V = numpy.zeros((iterations,self.J,self.K))   
     self.all_tau = numpy.zeros(iterations) 
     self.all_times = []
     self.all_performances = { metric: [] for metric in METRICS } 
     
     time_start = time.time()
     for it in range(iterations):
         # Update the random variables
         self.U = update_U_gaussian_gaussian_multivariate(
             lamb=self.lamb, R=self.R, M=self.M, V=self.V, tau=self.tau) 
         self.V = update_V_gaussian_gaussian_multivariate(
             lamb=self.lamb, R=self.R, M=self.M, U=self.U, tau=self.tau)
         self.tau = update_tau_gaussian(
             alpha=self.alpha, beta=self.beta, R=self.R, M=self.M, U=self.U, V=self.V)
         
         # Store the draws
         self.all_U[it], self.all_V[it] = numpy.copy(self.U), numpy.copy(self.V)
         self.all_tau[it] = self.tau
         
         # Print the performance, store performance and time
         perf = self.predict_while_running()
         for metric in METRICS:
             self.all_performances[metric].append(perf[metric])
         time_iteration = time.time()
         self.all_times.append(time_iteration-time_start)   
         print "Iteration %s. MSE: %s. R^2: %s. Rp: %s." % (it+1,perf['MSE'],perf['R^2'],perf['Rp'])
 def run(self,iterations):
     """ Run the Gibbs sampler for the specified number of iterations. """
     self.all_U = numpy.zeros((iterations,self.I,self.K))  
     self.all_V = numpy.zeros((iterations,self.J,self.K))   
     self.all_muU = numpy.zeros((iterations,self.K))  
     self.all_muV = numpy.zeros((iterations,self.K))  
     self.all_sigmaU = numpy.zeros((iterations,self.K,self.K))  
     self.all_sigmaV = numpy.zeros((iterations,self.K,self.K))  
     self.all_tau = numpy.zeros(iterations) 
     self.all_times = []
     self.all_performances = { metric: [] for metric in METRICS } 
     
     time_start = time.time()
     for it in range(iterations):
         # Update the random variables
         self.muU, self.sigmaU = update_muU_sigmaU_gaussian_gaussian_wishart(
             mu0=self.mu0, beta0=self.beta0, v0=self.v0, W0=self.W0, U=self.U)
         self.U = update_U_gaussian_gaussian_wishart(
             muU=self.muU, sigmaU=self.sigmaU, R=self.R, M=self.M, V=self.V, tau=self.tau)
         
         self.muV, self.sigmaV = update_muV_sigmaV_gaussian_gaussian_wishart(
             mu0=self.mu0, beta0=self.beta0, v0=self.v0, W0=self.W0, V=self.V)
         self.V = update_V_gaussian_gaussian_wishart(
             muV=self.muV, sigmaV=self.sigmaV, R=self.R, M=self.M, U=self.U, tau=self.tau)
              
         self.tau = update_tau_gaussian(
             alpha=self.alpha, beta=self.beta, R=self.R, M=self.M, U=self.U, V=self.V)
         
         # Store the draws
         self.all_U[it], self.all_V[it] = numpy.copy(self.U), numpy.copy(self.V)
         self.all_muU[it], self.all_sigmaU[it] = numpy.copy(self.muU), numpy.copy(self.sigmaU)
         self.all_muV[it], self.all_sigmaV[it] = numpy.copy(self.muV), numpy.copy(self.sigmaV)
         self.all_tau[it] = self.tau
         
         # Print the performance, store performance and time
         perf = self.predict_while_running()
         for metric in METRICS:
             self.all_performances[metric].append(perf[metric])
         time_iteration = time.time()
         self.all_times.append(time_iteration-time_start)   
         print "Iteration %s. MSE: %s. R^2: %s. Rp: %s." % (it+1,perf['MSE'],perf['R^2'],perf['Rp'])