(task_type)
| 4052 | |
| 4053 | |
| 4054 | def test_randomized_search_cv(task_type): |
| 4055 | pool = Pool(TRAIN_FILE, column_description=CD_FILE) |
| 4056 | model = CatBoost( |
| 4057 | { |
| 4058 | "learning_rate": 0.03, |
| 4059 | "loss_function": "Logloss", |
| 4060 | "eval_metric": "AUC", |
| 4061 | "task_type": task_type, |
| 4062 | "gpu_ram_part": TEST_GPU_RAM_PART, |
| 4063 | } |
| 4064 | ) |
| 4065 | |
| 4066 | class UniformChoice: |
| 4067 | |
| 4068 | def __init__(self, values): |
| 4069 | self.values = values |
| 4070 | |
| 4071 | def rvs(self): |
| 4072 | return np.random.choice(self.values) |
| 4073 | |
| 4074 | feature_border_type_list = ['Median', 'Uniform', 'UniformAndQuantiles', 'MaxLogSum'] |
| 4075 | results = model.randomized_search( |
| 4076 | { |
| 4077 | 'feature_border_type': feature_border_type_list, |
| 4078 | 'one_hot_max_size': UniformChoice(list(range(20))), |
| 4079 | 'iterations': UniformChoice([1, 2, 3]), |
| 4080 | 'border_count': UniformChoice([10, 6, 20, 4]) |
| 4081 | }, |
| 4082 | pool, |
| 4083 | n_iter=2, |
| 4084 | search_by_train_test_split=False |
| 4085 | ) |
| 4086 | assert results['params']['feature_border_type'] in feature_border_type_list |
| 4087 | assert results['params']['one_hot_max_size'] in range(20) |
| 4088 | assert results['params']['border_count'] in [10, 6, 20, 4] |
| 4089 | assert results['params']['iterations'] in [1, 2, 3] |
| 4090 | |
| 4091 | |
| 4092 | def test_grid_search_with_class_weights_lists(): |
nothing calls this directly
no test coverage detected