<jupyter_start><jupyter_text>Hyperopt<jupyter_code># funkcja celu
def obj_func(params):
  print("Training with params: ")
  print(params)

  mean_mae, score_std = run_model(xgb.XGBRegressor(**params), feats)

  return {'loss': np.abs(mean_mae), 'status': STATUS_OK}

# obszar przeszukiwania parametrów/space

xgb_reg_params = {
    'learning_rate':    hp.choice('learning_rate',  np.arange(0.05, 0.31, 0.05)), #np.arange(start, stop, step)
    'max_depth':        hp.choice('max_depth',      np.arange(5, 16, 1, dtype=int)),
    'subsample':        hp.quniform('subsample', 0.5, 1, 0.05),
    'colsample_bytree': hp.quniform('colsample_bytree', 0.5, 1, 0.05),
    'objective':        'reg:squarederror',
    'n_estimators':     100,
    'seed':             0,
}

# szukaj, optymalizuj/run
best = fmin(obj_func, xgb_reg_params, algo=tpe.suggest, max_evals=25)

best<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1610738255033557, 'fraction_numerical': 0.03467561521252797, 'mean_word_length': 4.114285714285714, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '50675', 'license': 'MIT', 'n_tokens_mistral': 394, 'n_tokens_neox': 359, 'n_words': 60, 'path': 'day_5_hyperopt.ipynb', 'repo_name': 'ggierlik/dw_matrix_car', 'size': '894'}