def all_estimates(reviews, k=1):
 reviews = reviews.astype(float)
 k -= 1
 (nusers, nmovies) = reviews.shape
 estimates = np.zeros_like(reviews)
 for u in range(nusers):
  ureviews = np.delete(reviews, u, axis=0)
  ureviews -= ureviews.mean(0)
  ureviews /= (ureviews.std(0) + 1e-05)
  ureviews = ureviews.T.copy()
  for m in np.where((reviews[u] > 0))[0]:
   estimates[(u, m)] = nn_movie(ureviews, reviews, u, m, k)
 return estimates

def all_estimates ( reviews , k = 1 ) : reviews = reviews . astype ( float ) k -= 1 ( nusers , nmovies ) = reviews . shape estimates = np . zeros_like ( reviews ) for u in range ( nusers ) : ureviews = np . delete ( reviews , u , axis = 0 ) ureviews -= ureviews . mean ( 0 ) ureviews /= ( ureviews . std ( 0 ) + 1e-05 ) ureviews = ureviews . T . copy ( ) for m in np . where ( ( reviews [ u ] > 0 ) ) [ 0 ] : estimates [ ( u , m ) ] = nn_movie ( ureviews , reviews , u , m , k ) return estimates
estimate all review ratings .