超参数#

class sklearn.gaussian_process.kernels.Hyperparameter(name, value_type, bounds, n_elements=1, fixed=None)[源代码]#

以命名字节形式的内核超参数规范。

Added in version 0.18.

属性:
namestr

超参数的名称。请注意,使用名称为“x”的超参数的内核必须具有属性self.x和self.x_bounds

value_typestr

超参数的类型。目前,仅支持“数字”超参数。

bounds浮动对>= 0或“固定”

参数的下限和上限。如果n_elements>1,则可以替代地给出一对具有n_elements的1d数组。如果字符串“fixed”作为边界传递,则无法更改超参数的值。

n_elementsint,默认=1

超参数值的元素数。为1,对应于纯量超参数。n_elements & 1对应于一个具有载体值的超参数,例如,各向异性的长度尺度。

fixedbool,默认值=无

该超参数的值是否固定,即超参数调整期间无法更改。如果传递了“无”,则根据给定的边界推导出“固定”。

示例

>>> from sklearn.gaussian_process.kernels import ConstantKernel
>>> from sklearn.datasets import make_friedman2
>>> from sklearn.gaussian_process import GaussianProcessRegressor
>>> from sklearn.gaussian_process.kernels import Hyperparameter
>>> X, y = make_friedman2(n_samples=50, noise=0, random_state=0)
>>> kernel = ConstantKernel(constant_value=1.0,
...    constant_value_bounds=(0.0, 10.0))

我们可以访问每个超参数:

>>> for hyperparameter in kernel.hyperparameters:
...    print(hyperparameter)
Hyperparameter(name='constant_value', value_type='numeric',
bounds=array([[ 0., 10.]]), n_elements=1, fixed=False)
>>> params = kernel.get_params()
>>> for key in sorted(params): print(f"{key} : {params[key]}")
constant_value : 1.0
constant_value_bounds : (0.0, 10.0)
bounds#

字段2的收件箱

count(value, /)#

返回值出现的次数。

fixed#

字段号4的收件箱

index(value, start=0, stop=sys.maxsize, /)#

返回值的第一个索引。

如果该值不存在,则引发Value错误。

n_elements#

字段号3的收件箱

name#

字段号0的收件箱

value_type#

字段号1的收件箱