(self, choosers, alternatives, current_choice)
return results
Fit and save models based on given data after segmenting
        the `choosers` table. Segments that have not already been explicitly
        added will be automatically added with default model.

        Parameters
        ----------
        choosers : pandas.DataFrame
            Table describing the agents making choices, e.g. households.
            Must have a column with the same name as the .segmentation_col
            attribute.
        alternatives : pandas.DataFrame
            Table describing the things from which agents are choosing,
            e.g. buildings.
        current_choice
            Name of column in `choosers` that indicates which alternative
            they have currently chosen.

        Returns
        -------
        log_likelihoods : dict of dict
            Keys will be model names and values will be dictionaries of
            log-liklihood values as returned by MNLDiscreteChoiceModel.fit.
Fit and save models based on given data after segmenting
        the `choosers` table. Segments that have not already been explicitly
        added will be automatically added with default model.
Fit and save models based on given data after segmenting the choosers table . Segments that have not already been explicitly added will be automatically added with default model .
def fit(self, choosers, alternatives, current_choice):
        """
        Fit and save models based on given data after segmenting
        the `choosers` table. Segments that have not already been explicitly
        added will be automatically added with default model.

        Parameters
        ----------
        choosers : pandas.DataFrame
            Table describing the agents making choices, e.g. households.
            Must have a column with the same name as the .segmentation_col
            attribute.
        alternatives : pandas.DataFrame
            Table describing the things from which agents are choosing,
            e.g. buildings.
        current_choice
            Name of column in `choosers` that indicates which alternative
            they have currently chosen.

        Returns
        -------
        log_likelihoods : dict of dict
            Keys will be model names and values will be dictionaries of
            log-liklihood values as returned by MNLDiscreteChoiceModel.fit.

        """
        logger.debug('start: fit models in segmented LCM {}'.format(self.name))

        choosers, alternatives = self.apply_fit_filters(choosers, alternatives)
        unique = choosers[self.segmentation_col].unique()

        # Remove any existing segments that may no longer have counterparts
        # in the data. This can happen when loading a saved model and then
        # calling this method with data that no longer has segments that
        # were there the last time this was called.
        gone = set(self._group.models) - set(unique)
        for g in gone:
            del self._group.models[g]

        for x in unique:
            if x not in self._group.models:
                self.add_segment(x)

        results = self._group.fit(choosers, alternatives, current_choice)
        logger.debug(
            'finish: fit models in segmented LCM {}'.format(self.name))
        return results
def fit ( self , choosers , alternatives , current_choice ) : logger . debug ( 'start: fit models in segmented LCM {}' . format ( self . name ) ) choosers , alternatives = self . apply_fit_filters ( choosers , alternatives ) unique = choosers [ self . segmentation_col ] . unique ( ) # Remove any existing segments that may no longer have counterparts # in the data. This can happen when loading a saved model and then # calling this method with data that no longer has segments that # were there the last time this was called. gone = set ( self . _group . models ) - set ( unique ) for g in gone : del self . _group . models [ g ] for x in unique : if x not in self . _group . models : self . add_segment ( x ) results = self . _group . fit ( choosers , alternatives , current_choice ) logger . debug ( 'finish: fit models in segmented LCM {}' . format ( self . name ) ) return results