文章目录
这次依然用官方的Example:examples/SMAC4HPO_svm.py
初始化与DOE
DOE: Design of Experiment
初始采样次数的确定
self.init_budget = 12
self.init_budget = int(max(1, min(n_configs_x_params * n_params,
(max_config_fracs * scenario.ta_run_limit))))
n_configs_x_params
Out[2]: 10
n_params
Out[3]: 7
max_config_fracs
Out[4]: 0.25
scenario.ta_run_limit
Out[5]: 50.0
scenario.ta_run_limit*0.25
Out[6]: 12.5
n_configs_x_params: int
how many configurations will be used at most in the initial design (X*D)
max_config_fracs: float
use at most X*budget in the initial design. Not active if a time limit is given.
DOE
smac.initial_design.sobol_design.SobolDesign#_select_configurations
sobol = sobol_seq.i4_sobol_generate(len(params) - constants, self.init_budget)
看看算出来这个东西是什么
sobol
Out[6]:
array([[0.5 , 0.5 , 0.5 , 0.5 , 0.5 , 0.5 , 0.5 ],
[0.75 , 0.25 , 0.75 , 0.25 , 0.75 , 0.25 , 0.75 ],
[0.25 , 0.75 , 0.25 , 0.75 , 0.25 , 0.75 , 0.25 ],
[0.375 , 0.375 , 0.625 , 0.125 , 0.875 , 0.875 , 0.125 ],
[0.875 , 0.875 , 0.125 , 0.625 , 0.375 , 0.375 , 0.625 ],
[0.625 , 0.125 , 0.375 , 0.375 , 0.125 , 0.625 , 0.875 ],
[0.125 , 0.625 , 0.875 , 0.875 , 0.625 , 0.125 , 0.375 ],
[0.1875, 0.3125, 0.3125, 0.6875, 0.5625, 0.1875, 0.0625],
[0.6875, 0.8125, 0.8125, 0.1875, 0.0625, 0.6875, 0.5625],
[0.9375, 0.0625, 0.5625, 0.9375, 0.3125, 0.4375, 0.8125],
[0.4375, 0.5625, 0.0625, 0.4375, 0.8125, 0.9375, 0.3125],
[0.3125, 0.1875, 0.9375, 0.5625, 0.4375, 0.8125, 0.1875]])
第一个参数是维数,第二个参数是样本数。
不过需要注意的是,sobol_seq规定,维数不能大于40 。
self.init_budget = 12
将design向量封装为Configuration
sobol_seq.sobol_seq.i4_sobol_generate
cs
Out[11]:
Configuration space object:
Hyperparameters:
C, Type: UniformFloat, Range: [0.001, 1000.0], Default: 1.0
coef0, Type: UniformFloat, Range: [0.0, 10.0], Default: 0.0
degree, Type: UniformInteger, Range: [1, 5], Default: 3
gamma, Type: Categorical, Choices: {
auto, value}, Default: auto
gamma_value, Type: UniformFloat, Range: