Dataset.py
def load_rating_file_as_matrix(self, filename):
        '''
        Read .rating file and Return dok matrix.
        The first line of .rating file is: num_users\t num_items
        '''
        # Get number of users and items
        num_users = np.unique(self.data_raw['userId']).shape[0] #138493
        num_items = np.unique(self.data_raw['movieId']).shape[0] #26744
        # Construct matrix
        mat = sp.dok_matrix((num_users, num_items), dtype=np.float32)
        with open(filename, "r") as f:
            line = f.readline()
            while line != None and line != "":
                arr = line.split("\t")
                user, item = int(arr[0]), int(arr[1])
                # item = np.argwhere(self.unique_item==item)[0][0]
                mat[user, item] = 1.0
                line = f.readline()    
        return mat

        Read .rating file and Return dok matrix.
        The first line of .rating file is: num_users\t num_items
        
Read .rating file and Return dok matrix.
The first line of .rating file is: num_users\t num_items
Read . rating file and Return dok matrix . The first line of . rating file is : num_users \ t num_items
def load_rating_file_as_matrix(self, filename):
        num_users = np.unique(self.data_raw['userId']).shape[0] 
        num_items = np.unique(self.data_raw['movieId']).shape[0] 
        mat = sp.dok_matrix((num_users, num_items), dtype=np.float32)
        with open(filename, "r") as f:
            line = f.readline()
            while line != None and line != "":
                arr = line.split("\t")
                user, item = int(arr[0]), int(arr[1])
                mat[user, item] = 1.0
                line = f.readline()    
        return mat
def load_rating_file_as_matrix ( self , filename ) : num_users = np . unique ( self . data_raw [ 'userId' ] ) . shape [ 0 ] num_items = np . unique ( self . data_raw [ 'movieId' ] ) . shape [ 0 ] mat = sp . dok_matrix ( ( num_users , num_items ) , dtype = np . float32 ) with open ( filename , "r" ) as f : line = f . readline ( ) while line != None and line != "" : arr = line . split ( "\t" ) user , item = int ( arr [ 0 ] ) , int ( arr [ 1 ] ) mat [ user , item ] = 1.0 line = f . readline ( ) return mat
Read .rating file and Return dok matrix.
Read . rating file and Return dok matrix .
'''
        Read .rating file and Return dok matrix.
        The first line of .rating file is: num_users\t num_items
        ''' # Get number of users and items
 #138493
 #26744
 # Construct matrix
 # item = np.argwhere(self.unique_item==item)[0][0]

self
filename