Beispiel #1
0
    def test_unroll_dict_of_lists(self):
        model_param_search_range = {
            'norm_type': ['normalize', 'clip_0to1'],
            'n_estimators': [10, 50],
            'random_state': [0]
        }

        dicts = ModelCrossValidation._unroll_dict_of_lists(
            model_param_search_range)

        expected_dicts = [
            {
                'norm_type': 'normalize',
                'n_estimators': 10,
                'random_state': 0
            },
            {
                'norm_type': 'clip_0to1',
                'n_estimators': 10,
                'random_state': 0
            },
            {
                'norm_type': 'normalize',
                'n_estimators': 50,
                'random_state': 0
            },
            {
                'norm_type': 'clip_0to1',
                'n_estimators': 50,
                'random_state': 0
            },
        ]

        self.assertEquals(dicts, expected_dicts)
    def test_unroll_dict_of_lists(self):
        model_param_search_range = {'norm_type':['normalize', 'clip_0to1'],
                                    'n_estimators':[10, 50], 'random_state': [0]}

        dicts = ModelCrossValidation._unroll_dict_of_lists(model_param_search_range)

        expected_dicts = [
         {'norm_type':'normalize', 'n_estimators':10, 'random_state':0},
         {'norm_type':'clip_0to1', 'n_estimators':10, 'random_state':0},
         {'norm_type':'normalize', 'n_estimators':50, 'random_state':0},
         {'norm_type':'clip_0to1', 'n_estimators':50, 'random_state':0},
        ]

        self.assertEquals(dicts, expected_dicts)