本文整理汇总了Python中sklearn.gaussian_process.GaussianProcessRegressor.set_params方法的典型用法代码示例。如果您正苦于以下问题:Python GaussianProcessRegressor.set_params方法的具体用法?Python GaussianProcessRegressor.set_params怎么用?Python GaussianProcessRegressor.set_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.gaussian_process.GaussianProcessRegressor
的用法示例。
在下文中一共展示了GaussianProcessRegressor.set_params方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BayesianOptimization
# 需要导入模块: from sklearn.gaussian_process import GaussianProcessRegressor [as 别名]
# 或者: from sklearn.gaussian_process.GaussianProcessRegressor import set_params [as 别名]
#.........这里部分代码省略.........
:param acq:
Acquisition function to be used, defaults to Upper Confidence Bound.
:param gp_params:
Parameters to be passed to the Scikit-learn Gaussian Process object
Returns
-------
:return: Nothing
Example:
>>> xs = np.linspace(-2, 10, 10000)
>>> f = np.exp(-(xs - 2)**2) + np.exp(-(xs - 6)**2/10) + 1/ (xs**2 + 1)
>>> bo = BayesianOptimization(f=lambda x: f[int(x)],
>>> pbounds={"x": (0, len(f)-1)})
>>> bo.maximize(init_points=2, n_iter=25, acq="ucb", kappa=1)
"""
# Reset timer
self.plog.reset_timer()
# Set acquisition function
self.util = UtilityFunction(kind=acq, kappa=kappa, xi=xi)
# Initialize x, y and find current y_max
if not self.initialized:
if self.verbose:
self.plog.print_header()
self.init(init_points)
y_max = self.space.Y.max()
# Set parameters if any was passed
self.gp.set_params(**gp_params)
# Find unique rows of X to avoid GP from breaking
self.gp.fit(self.space.X, self.space.Y)
# Finding argmax of the acquisition function.
x_max = acq_max(ac=self.util.utility,
gp=self.gp,
y_max=y_max,
bounds=self.space.bounds,
random_state=self.random_state,
**self._acqkw)
# Print new header
if self.verbose:
self.plog.print_header(initialization=False)
# Iterative process of searching for the maximum. At each round the
# most recent x and y values probed are added to the X and Y arrays
# used to train the Gaussian Process. Next the maximum known value
# of the target function is found and passed to the acq_max function.
# The arg_max of the acquisition function is found and this will be
# the next probed value of the target function in the next round.
for i in range(n_iter):
# Test if x_max is repeated, if it is, draw another one at random
# If it is repeated, print a warning
pwarning = False
while x_max in self.space:
x_max = self.space.random_points(1)[0]
pwarning = True
# Append most recently generated values to X and Y arrays
y = self.space.observe_point(x_max)
if self.verbose: