-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtpe_space.py
72 lines (53 loc) · 2.29 KB
/
tpe_space.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 15.2.2019
@author: Jiali Lin
"""
from hyperopt import hp
import hyperopt.pyll.stochastic
# Define the search space
space = {
# Step 1:
'Preprocess': hp.choice('pre',
['cpoScale()',
'cpoScale(scale = FALSE)',
'cpoScale(center = FALSE)',
'cpoSpatialSign()',
'NA']),
# Step 2:
'FeatureFilter': hp.choice('feature', [
{'filter': 'cpoFilterAnova(perc)',
'perc': hp.uniform('ano_per', 0.1, 1)},
{'filter': 'cpoFilterKruskal(perc)',
'perc': hp.uniform('kru_per', 0.1, 1)},
{'filter': 'cpoFilterUnivariate(perc)',
'perc': hp.uniform('uni_per', 0.1, 1)},
{'filter': 'cpoPca(center = FALSE, rank)',
'rank': hp.uniform('pca_rank', 0, 0.9)},
{'filter': 'NA'}]),
# Step 3:
'Classifier': hp.choice('classify_model', [
{'model': 'kknn',
'k': 1 + hp.randint('kknn_k', 19)},
{'model': 'ksvm',
'C': hp.uniform('ksvm_C', 2**(-15), 2**(15)),
'sigma': hp.uniform('ksvm_sigma', 2**(-15), 2**(15))},
{'model': 'ranger',
'mtry': hp.uniform('ranger_mtry', 0.1, 0.66666),
'sample.fraction': hp.uniform('ranger_fra', 0.1, 1)},
{'model': 'xgboost',
'eta': hp.uniform('xgboost_eta', 0.001, 0.3),
'max_depth': 1 + hp.randint('xgboost_depth', 14),
'subsample': hp.uniform('xgboost_sub', 0.5, 1),
'colsample_bytree': hp.uniform('xgboost_col', 0.5, 1),
'min_child_weight': hp.uniform('xgboost_min', 0, 50)},
{'model': 'naiveBayes',
'laplace': hp.uniform('bay_laplace', 0.01, 100)}
])}
# Sample one configuration:
# print(hyperopt.pyll.stochastic.sample(space))
#print(hyperopt.pyll.stochastic.sample(space))
#106 {'Classifier': {'model': 'ranger', 'mtry': 0.574453305013119, 'sample.fracti
#107 on': 0.8656502995483121}, 'FeatureFilter': {'filter': 'cpoFilterAnova(perc)'
#108 , 'perc': 0.3726989872044636}, 'Preprocess': 'NA'}