(cls, yaml_str=None, str_or_buffer=None)
return seg
Create a SegmentedMNLDiscreteChoiceModel instance from a saved YAML
        configuration. Arguments are mutally exclusive.

        Parameters
        ----------
        yaml_str : str, optional
            A YAML string from which to load model.
        str_or_buffer : str or file like, optional
            File name or buffer from which to load YAML.

        Returns
        -------
        SegmentedMNLDiscreteChoiceModel
Create a SegmentedMNLDiscreteChoiceModel instance from a saved YAML
        configuration. Arguments are mutally exclusive.
Create a SegmentedMNLDiscreteChoiceModel instance from a saved YAML configuration . Arguments are mutally exclusive .
def from_yaml(cls, yaml_str=None, str_or_buffer=None):
        """
        Create a SegmentedMNLDiscreteChoiceModel instance from a saved YAML
        configuration. Arguments are mutally exclusive.

        Parameters
        ----------
        yaml_str : str, optional
            A YAML string from which to load model.
        str_or_buffer : str or file like, optional
            File name or buffer from which to load YAML.

        Returns
        -------
        SegmentedMNLDiscreteChoiceModel

        """
        cfg = yamlio.yaml_to_dict(yaml_str, str_or_buffer)

        default_model_expr = cfg['default_config']['model_expression']

        seg = cls(
            cfg['segmentation_col'],
            cfg['sample_size'],
            cfg['probability_mode'],
            cfg['choice_mode'],
            cfg['choosers_fit_filters'],
            cfg['choosers_predict_filters'],
            cfg['alts_fit_filters'],
            cfg['alts_predict_filters'],
            cfg['interaction_predict_filters'],
            cfg['estimation_sample_size'],
            cfg['prediction_sample_size'],
            cfg['choice_column'],
            default_model_expr,
            cfg['remove_alts'],
            cfg['name'])

        if "models" not in cfg:
            cfg["models"] = {}

        for name, m in cfg['models'].items():
            m['model_expression'] = m.get(
                'model_expression', default_model_expr)
            m['sample_size'] = cfg['sample_size']
            m['probability_mode'] = cfg['probability_mode']
            m['choice_mode'] = cfg['choice_mode']
            m['choosers_fit_filters'] = None
            m['choosers_predict_filters'] = None
            m['alts_fit_filters'] = None
            m['alts_predict_filters'] = None
            m['interaction_predict_filters'] = \
                cfg['interaction_predict_filters']
            m['estimation_sample_size'] = cfg['estimation_sample_size']
            m['prediction_sample_size'] = cfg['prediction_sample_size']
            m['choice_column'] = cfg['choice_column']

            model = MNLDiscreteChoiceModel.from_yaml(
                yamlio.convert_to_yaml(m, None))
            seg._group.add_model(model)

        logger.debug(
            'loaded segmented LCM model {} from YAML'.format(seg.name))
        return seg
def from_yaml ( cls , yaml_str = None , str_or_buffer = None ) : cfg = yamlio . yaml_to_dict ( yaml_str , str_or_buffer ) default_model_expr = cfg [ 'default_config' ] [ 'model_expression' ] seg = cls ( cfg [ 'segmentation_col' ] , cfg [ 'sample_size' ] , cfg [ 'probability_mode' ] , cfg [ 'choice_mode' ] , cfg [ 'choosers_fit_filters' ] , cfg [ 'choosers_predict_filters' ] , cfg [ 'alts_fit_filters' ] , cfg [ 'alts_predict_filters' ] , cfg [ 'interaction_predict_filters' ] , cfg [ 'estimation_sample_size' ] , cfg [ 'prediction_sample_size' ] , cfg [ 'choice_column' ] , default_model_expr , cfg [ 'remove_alts' ] , cfg [ 'name' ] ) if "models" not in cfg : cfg [ "models" ] = { } for name , m in cfg [ 'models' ] . items ( ) : m [ 'model_expression' ] = m . get ( 'model_expression' , default_model_expr ) m [ 'sample_size' ] = cfg [ 'sample_size' ] m [ 'probability_mode' ] = cfg [ 'probability_mode' ] m [ 'choice_mode' ] = cfg [ 'choice_mode' ] m [ 'choosers_fit_filters' ] = None m [ 'choosers_predict_filters' ] = None m [ 'alts_fit_filters' ] = None m [ 'alts_predict_filters' ] = None m [ 'interaction_predict_filters' ] = cfg [ 'interaction_predict_filters' ] m [ 'estimation_sample_size' ] = cfg [ 'estimation_sample_size' ] m [ 'prediction_sample_size' ] = cfg [ 'prediction_sample_size' ] m [ 'choice_column' ] = cfg [ 'choice_column' ] model = MNLDiscreteChoiceModel . from_yaml ( yamlio . convert_to_yaml ( m , None ) ) seg . _group . add_model ( model ) logger . debug ( 'loaded segmented LCM model {} from YAML' . format ( seg . name ) ) return seg