#NEWLINE# def predict( self , choosers , alternatives , debug = False ) : #NEWLINE# #INDENT# '\n        Choose from among alternatives for a group of agents after\n        segmenting the `choosers` table.\n\n        Parameters\n        ----------\n        choosers : pandas.DataFrame\n            Table describing the agents making choices, e.g. households.\n            Must have a column matching the .segmentation_col attribute.\n        alternatives : pandas.DataFrame\n            Table describing the things from which agents are choosing.\n        debug : bool\n            If debug is set to true, will set the variable "sim_pdf" on\n            the object to store the probabilities for mapping of the\n            outcome.\n\n        Returns\n        -------\n        choices : pandas.Series\n            Mapping of chooser ID to alternative ID. Some choosers\n            will map to a nan value when there are not enough alternatives\n            for all the choosers.\n\n        ' #NEWLINE# logger . debug ( 'start: predict models in LCM group {}' . format ( self . name ) ) #NEWLINE# results = [ ] #NEWLINE# for ( name , df ) in self . _iter_groups ( choosers ) : #NEWLINE# #INDENT# choices = self . models [ name ] . predict ( choices , alternatives , debug = debug ) #NEWLINE# if self . remove_alts : #NEWLINE# #INDENT# alternatives = alternatives . loc [ ( ~ alternatives . index . isin ( choices ) ) ] #NEWLINE# #UNINDENT# results . append ( choices ) #NEWLINE# #UNINDENT# logger . debug ( 'finish: predict models in LCM group {}' . format ( self . name ) ) #NEWLINE# return ( pd . concat ( results ) if results else pd . Series ( ) )