gpt4 book ai didi

machine-learning - 为什么使用高斯过程回归的 GridCV 会出现错误?

转载 作者:行者123 更新时间:2023-11-30 09:27:06 27 4
gpt4 key购买 nike

我正在尝试使用 GridCV 确定 sklearn 中 GPR 的超参数。但是,我收到以下错误:
ValueError:不支持连续

欢迎任何见解。我的代码如下:

import numpy as np

from sklearn.gaussian_process import GaussianProcess
from sklearn.gaussian_process import regression_models as regression
from sklearn.gaussian_process import correlation_models as correlation
from sklearn.datasets import make_regression
from sklearn.utils.testing import assert_greater, assert_true, raises
from sklearn.model_selection import GridSearchCV

b, kappa, e = 5., .5, .1
g = lambda x: b - x[:, 1] - kappa * (x[:, 0] - e) ** 2.
X = np.array([[-4.61611719, -6.00099547],
[4.10469096, 5.32782448],
[0.00000000, -0.50000000],
[-6.17289014, -4.6984743],
[1.3109306, -6.93271427],
[-5.03823144, 3.10584743],
[-2.87600388, 6.74310541],
[5.21301203, 4.26386883]])
y = g(X).ravel()


tuned_parameters = [{'corr':['squared_exponential'], 'theta0': [0.01, 0.2, 0.8, 1.]},
{'corr':['cubic'], 'theta0': [0.01, 0.2, 0.8, 1.]}]

scores = ['precision', 'recall']

xy_line=(0,1200)


for score in scores:
print("# Tuning hyper-parameters for %s" % score)
print()

gp = GridSearchCV(GaussianProcess(normalize=False), tuned_parameters, cv=5,
scoring='%s_weighted' % score)
gp.fit(X, y)

最佳答案

准确率和召回率是用于分类的指标,而不是回归的指标。将 GridSearchCV 中的 scoring='%s_weighted' % Score 更改为类似 scoring='r2' 的内容,错误就会消失。

关于machine-learning - 为什么使用高斯过程回归的 GridCV 会出现错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46783826/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com