为什么我在使用高斯过程回归的GridCV时会遇到错误?

我在尝试使用GridCV来确定sklearn中高斯过程回归(GPR)的超参数时,遇到了以下错误:
ValueError: continuous is not supported

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

import numpy as npfrom sklearn.gaussian_process import GaussianProcessfrom sklearn.gaussian_process import regression_models as regressionfrom sklearn.gaussian_process import correlation_models as correlationfrom sklearn.datasets import make_regressionfrom sklearn.utils.testing import assert_greater, assert_true, raisesfrom sklearn.model_selection import GridSearchCVb, kappa, e = 5., .5, .1g = 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'的内容,你的错误就会消失。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注