(self, name, model_expression=None)
Add a new segment with its own model expression.

        Parameters
        ----------
        name
            Segment name. Must match a segment in the groupby of the data.
        model_expression : str or dict, optional
            A patsy model expression that can be used with statsmodels.
            Should contain both the left- and right-hand sides.
            If not given the default model will be used, which must not be
            None.
Add a new segment with its own model expression.
Add a new segment with its own model expression .
def add_segment(self, name, model_expression=None):
        """
        Add a new segment with its own model expression.

        Parameters
        ----------
        name
            Segment name. Must match a segment in the groupby of the data.
        model_expression : str or dict, optional
            A patsy model expression that can be used with statsmodels.
            Should contain both the left- and right-hand sides.
            If not given the default model will be used, which must not be
            None.

        """
        logger.debug('adding LCM model {} to segmented model {}'.format(
            name, self.name))
        if not model_expression:
            if not self.default_model_expr:
                raise ValueError(
                    'No default model available, '
                    'you must supply a model expression.')
            model_expression = self.default_model_expr

        # we'll take care of some of the filtering this side before
        # segmentation
        self._group.add_model_from_params(
            name=name,
            model_expression=model_expression,
            sample_size=self.sample_size,
            probability_mode=self.probability_mode,
            choice_mode=self.choice_mode,
            choosers_fit_filters=None,
            choosers_predict_filters=None,
            alts_fit_filters=None,
            alts_predict_filters=None,
            interaction_predict_filters=self.interaction_predict_filters,
            estimation_sample_size=self.estimation_sample_size,
            choice_column=self.choice_column)
def add_segment ( self , name , model_expression = None ) : logger . debug ( 'adding LCM model {} to segmented model {}' . format ( name , self . name ) ) if not model_expression : if not self . default_model_expr : raise ValueError ( 'No default model available, ' 'you must supply a model expression.' ) model_expression = self . default_model_expr # we'll take care of some of the filtering this side before # segmentation self . _group . add_model_from_params ( name = name , model_expression = model_expression , sample_size = self . sample_size , probability_mode = self . probability_mode , choice_mode = self . choice_mode , choosers_fit_filters = None , choosers_predict_filters = None , alts_fit_filters = None , alts_predict_filters = None , interaction_predict_filters = self . interaction_predict_filters , estimation_sample_size = self . estimation_sample_size , choice_column = self . choice_column )