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