<commit_before>from hyperopt import fmin, tpe, hp, Trials, space_eval

def get_space(num_models):
    space = {}

    for i in range(num_models):
        add_model(str(i), space)
    return space

def get_linear_model(model_num):
    return {
        'model_' + model_num: 'LR',
        'regularizer_lr_' + model_num: hp.choice('regularizer_lr_' + model_num,[
            ('l1', hp.loguniform('l1_strength_lr_' + model_num, -5,5)),
            ('l2', hp.loguniform('l2_strength_lr_' + model_num, -5,5))
            
#                    ('l1', hp.loguniform('l1_strength', np.log(1e-7), np.log(10**2))),
#                    ('l2', hp.loguniform('l2_strength', np.log(1e-7), np.log(100)))
        ]),
        'converg_tol_' + model_num: hp.loguniform('converg_tol_' + model_num, -10, -1)
    }

def get_xgboost_model(model_num):
    return {
            'model_' + model_num: 'XGBoost',
            'eta_' + model_num: hp.loguniform('eta_' + model_num,-5,0),
            'gamma_' + model_num: hp.uniform('gamma_' + model_num,0,10),
            'max_depth_' + model_num: hp.quniform('max_depth_' + model_num, 1,30,1),
            'min_child_weight_' + model_num: hp.uniform('min_child_weight_' + model_num, 0, 10),
            'max_delta_step_' + model_num: hp.uniform('max_delta_step_' + model_num, 0, 10),
            'num_round_' + model_num: hp.quniform('num_round_' + model_num, 1, 10, 1),
            'subsample_' + model_num: 1,# hp.uniform('subsample_' + model_num, .001, 1),
            'regularizer_xgb_' + model_num: hp.choice('regularizer_xgb_' + model_num,[
                ('l1', hp.loguniform('l1_strength_xgb_' + model_num, -5,5)),
                ('l2', hp.loguniform('l2_strength_xgb_' + model_num, -5,5))
                
#                    ('l1_' + model_num, hp.loguniform('l1_strength_' + model_num, np.log(1e-7), np.log(10**2))),
#                    ('l2_' + model_num, hp.loguniform('l2_strength_' + model_num, np.log(1e-7), np.log(100)))
            ])
        }


def add_model(model_num, space):
    #should take this as a param
    set_of_models = [get_linear_model(model_num)]
    space['model_' + model_num] = hp.choice('model_' + model_num, set_of_models)
    space['features_' + model_num] = {
        'nmin_to_max_' + model_num: hp.choice('nmin_to_max_' + model_num, 
                                              [(1,1),(1,2),(1,3),(2,2),(2,3)]),
        'binary_' + model_num: hp.choice('binary_' + model_num, [True, False]),<commit_msg>trying to commit from workhorse...<commit_after>from hyperopt import fmin, tpe, hp, Trials, space_eval

def get_space(num_models):
    space = {}

    for i in range(num_models):
        add_model(str(i), space)
    return space

def get_linear_model(model_num):
    return {
        'model_' + model_num: 'LR',
        'regularizer_lr_' + model_num: hp.choice('regularizer_lr_' + model_num,[
            ('l1', hp.loguniform('l1_strength_lr_' + model_num, -5,5)),
            ('l2', hp.loguniform('l2_strength_lr_' + model_num, -5,5))
            
#                    ('l1', hp.loguniform('l1_strength', np.log(1e-7), np.log(10**2))),
#                    ('l2', hp.loguniform('l2_strength', np.log(1e-7), np.log(100)))
        ]),
        'converg_tol_' + model_num: hp.loguniform('converg_tol_' + model_num, -10, -1)
    }

def get_xgboost_model(model_num):
    return {
            'model_' + model_num: 'XGBoost',
            'eta_' + model_num: hp.loguniform('eta_' + model_num,-5,0),
            'gamma_' + model_num: hp.uniform('gamma_' + model_num,0,10),
            'max_depth_' + model_num: hp.quniform('max_depth_' + model_num, 1,30,1),
            'min_child_weight_' + model_num: hp.uniform('min_child_weight_' + model_num, 0, 10),
            'max_delta_step_' + model_num: hp.uniform('max_delta_step_' + model_num, 0, 10),
            'num_round_' + model_num: hp.quniform('num_round_' + model_num, 1, 10, 1),
            'subsample_' + model_num: 1,# hp.uniform('subsample_' + model_num, .001, 1),
            'regularizer_xgb_' + model_num: hp.choice('regularizer_xgb_' + model_num,[
                ('l1', hp.loguniform('l1_strength_xgb_' + model_num, -5,5)),
                ('l2', hp.loguniform('l2_strength_xgb_' + model_num, -5,5))
                
#                    ('l1_' + model_num, hp.loguniform('l1_strength_' + model_num, np.log(1e-7), np.log(10**2))),
#                    ('l2_' + model_num, hp.loguniform('l2_strength_' + model_num, np.log(1e-7), np.log(100)))
            ])
        }

def add_model(model_num, space):
    #should take this as a param
    set_of_models = [get_linear_model(model_num)]
    space['model_' + model_num] = hp.choice('model_' + model_num, set_of_models)
    space['features_' + model_num] = {
        'nmin_to_max_' + model_num: hp.choice('nmin_to_max_' + model_num, 
                                              [(1,1),(1,2),(1,3),(2,2),(2,3)]),
        'binary_' + model_num: hp.choice('binary_' + model_num, [True, False]),
{'fraction_non_alphanumeric': 0.16525764895330114, 'fraction_numerical': 0.03260869565217391, 'mean_word_length': 2.6296566837107376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6397491', 'n_tokens_mistral': 2000, 'n_tokens_neox': 1895, 'n_words': 301}