#NEWLINE# def build_model( self ) : #NEWLINE# #INDENT# '\n        Returns\n        -------\n        self:\n             Build the data model\n        ' #NEWLINE# self . _user_ids = np . asanyarray ( self . dataset . keys ( ) ) #NEWLINE# self . _user_ids . sort ( ) #NEWLINE# self . _item_ids = np . array ( [ ] ) #NEWLINE# for items in self . dataset . itervalues ( ) : #NEWLINE# #INDENT# self . _item_ids = np . append ( self . _item_ids , items ) #NEWLINE# #UNINDENT# self . _item_ids = np . unique ( self . _item_ids ) #NEWLINE# self . _item_ids . sort ( ) #NEWLINE# logger . info ( ( 'creating matrix for %d users and %d items' % ( self . _user_ids . size , self . _item_ids . size ) ) ) #NEWLINE# self . index = np . empty ( shape = ( self . _user_ids . size , self . _item_ids . size ) , dtype = bool ) #NEWLINE# for ( userno , user_id ) in enumerate ( self . _user_ids ) : #NEWLINE# #INDENT# if ( ( userno % 2 ) == 0 ) : #NEWLINE# #INDENT# logger . debug ( ( 'PROGRESS: at user_id #%i/%i' % ( userno , self . _user_ids . size ) ) ) #NEWLINE# #UNINDENT# for ( itemno , item_id ) in enumerate ( self . _item_ids ) : #NEWLINE# #INDENT# r = ( True if ( item_id in self . dataset [ user_id ] ) else False ) #NEWLINE# self . index [ ( userno , itemno ) ] = r