def _make_data_space(self): """Пространство поиска параметров данных модели""" space = { "freq": hyper.make_choice_space("freq", Freq), "lags": hyper.make_choice_space("lags", lags()), } return space
def _make_data_space(self): """Пространство поиска параметров данных модели""" space = { 'freq': hyper.make_choice_space('freq', Freq), 'lags': hyper.make_choice_space('lags', lags()) } return space
def test_optimize_hyper(monkeypatch): space = { 'data': { 'freq': hyper.make_choice_space('freq', Freq), 'lags': hyper.make_choice_space('lags_range', range(1, 4)) }, 'model': { 'one_hot_max_size': hyper.make_choice_space('one_hot_max_size', hyper.ONE_HOT_SIZE), 'learning_rate': hyper.make_log_space('learning_rate', 0.1, 0.1), 'depth': hyper.make_choice_space('depth', range(1, 9)), 'l2_leaf_reg': hyper.make_log_space('l2_leaf_reg', 2.3, 0.3), 'random_strength': hyper.make_log_space('rand_strength', 1.3, 0.3), 'bagging_temperature': hyper.make_log_space('bagging_temperature', 1.4, 0.4) } } params = { 'data': { 'freq': Freq.yearly, 'lags': 1 }, 'model': { 'one_hot_max_size': 2, 'learning_rate': 0.1, 'depth': 6, 'l2_leaf_reg': 2.3, 'random_strength': 1.3, 'bagging_temperature': 1.4 } } monkeypatch.setattr(hyper, 'MAX_SEARCHES', 2) monkeypatch.setattr(hyper, 'make_model_space', lambda x: space['model']) date = '2018-09-03' pos = ('CHMF', 'RTKMP', 'SNGSP', 'VSMO', 'LKOH') result = hyper.optimize_hyper(params, pos, pd.Timestamp(date), cases.learn_pool, space['data']) assert isinstance(result, dict) assert result['data'] == dict(freq=Freq.quarterly, lags=1) assert len(result['model']) == 6 assert result['model']['bagging_temperature'] == pytest.approx( 1.0557058439636) assert result['model']['depth'] == 1 assert result['model']['l2_leaf_reg'] == pytest.approx(2.417498137284288) assert result['model']['learning_rate'] == pytest.approx( 0.10806709959509389) assert result['model']['one_hot_max_size'] == 100 assert result['model']['random_strength'] == pytest.approx( 1.0813796592585887)
def _make_data_space(self): """Пространство поиска параметров данных модели""" space = { "ew_lags": hp.uniform("ew_lags", *ew_lags(self.PARAMS)), "returns_lags": hyper.make_choice_space("returns_lags", returns_lags()), } return space
def _make_data_space(self): """Пространство поиска параметров данных модели""" space = { 'ew_lags': hp.uniform('ew_lags', *ew_lags(self.PARAMS)), 'returns_lags': hyper.make_choice_space('returns_lags', returns_lags()) } return space
'freq': Freq.yearly, 'lags': 1 }, 'model': { 'bagging_temperature': 1.3463876077482095, 'depth': 3, 'l2_leaf_reg': 1.8578444629373057, 'learning_rate': 0.09300426944876264, 'one_hot_max_size': 2, 'random_strength': 1.0464151963029267 } } SPACE = { 'data': { 'freq': hyper.make_choice_space('freq', Freq), 'lags_range': hyper.make_choice_space('lags_range', list(range(1, 4))) }, 'model': { 'one_hot_max_size': hyper.make_choice_space('one_hot_max_size', hyper.ONE_HOT_SIZE), 'learning_rate': hyper.make_log_space('learning_rate', 0.1, 0.1), 'depth': hyper.make_choice_space('depth', list(range(1, 9))), 'l2_leaf_reg': hyper.make_log_space('l2_leaf_reg', 2.3, 0.3), 'random_strength': hyper.make_log_space('rand_strength', 1.3, 0.3), 'bagging_temperature': hyper.make_log_space('bagging_temperature', 1.4, 0.4)