简体   繁体   English

使用 RBF 内核进行 SVR 推理的方程式是什么?

[英]What is the equation for SVR inference using an RBF kernel?

I'm using sklearn for SVR (regression) using an RBF kernel.我正在使用 sklearn 使用 RBF 内核进行 SVR(回归)。 I'm want to know how the inference is done under the hood.我想知道推理是如何在幕后完成的。 I thought it was a function of the support vectors, function mean, and gamma, but it appears I'm missing one aspect (probably some scaling based on how close 2 points are.我认为它是支持向量、函数均值和 gamma 的函数,但似乎我缺少一个方面(可能基于 2 个点的接近程度进行一些缩放。

Here is "my Equation" that I've tried in the graph's below.这是我在下图中尝试过的“我的方程式”

out = mean
for vect in vectors:
    out = out + (vect.y - mean) * math.exp(-(vect.x - x) ** 2 * gamma)

When I do just 2 points spaced away, my equation matches what skLearn reports with svr.predict.当我只隔开 2 个点时,我的方程与 skLearn 使用 svr.predict 报告的结果相匹配。

用这两个训练点制作了这个

With 3 training points and 2 close together, my equation does not match what svr.predict gives:有 3 个训练点和 2 个靠近在一起,我的方程与 svr.predict 给出的不匹配:

在此处输入图像描述

Given the support vectors, gamma, and mean, and anything else needed, what is the equation for SVR inference with RBF kernel?给定支持向量、伽马和均值,以及其他任何需要的东西,使用 RBF 内核进行 SVR 推理的方程是什么? Can those be obtained from the sklearn svr class?这些可以从 sklearn svr 类中获得吗?

The equation that works for me using sklearn library and SVR inference with RBF kernel is as follows with python code:使用 sklearn 库和带有 RBF 内核的 SVR 推理对我有用的等式如下与 python 代码:

# x and y is already defined, and is the training data for the SVR
svr = svm.SVR(kernel="rbf", C=C, gamma=gamma, epsilon=epsilon, tol=tol)
svr.fit(x,y)
vectors = []
for i in svr.support_:
    vectors.append([x[i][0], y[i]])
out = svr._intercept_[0]
for vect, coef in zip(vectors, svr._dual_coef_[0]):
    out = out + coef * math.exp(-(vect[0] - x) ** 2 * gamma)

I found that svr._intercept_[0] contains the y offset for the function.我发现svr._intercept_[0]包含函数的 y 偏移量。

I found that svr._dual_coef_[0] contains the coefficients to multiply each of the exponentials by.我发现svr._dual_coef_[0]包含将每个指数乘以的系数。

I found that svr.support_ contains the indexes of the elements in your training set used as the support vectors.我发现svr.support_包含用作支持向量的训练集中元素的索引。

I realize I'm accessing what is intended to be accessed within the svr class only, however, I don't see an official API method for accessing these variables, and this is working for me for now.我意识到我正在访问打算在 svr 类中访问的内容,但是,我没有看到用于访问这些变量的官方 API 方法,目前这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 GPy RBF内核实现 - GPy RBF Kernel Implementation 高斯 RBF 核的目的 - Purpose of Gaussian RBF kernel 如何在使用带有RBF内核的SVM的系统之间进行适当的比较? - How to conduct a proper comparison between systems using SVM with RBF kernel? 使用RBF内核SVM时,c或gamma的高值是否有问题? - Are high values for c or gamma problematic when using an RBF kernel SVM? SVM 自定义 RBF 内核 IndexError - SVM custom RBF kernel IndexError 多元核密度估计技术的方程式是什么? - What is the equation for multivariate kernel density estimation techniques? 我试图用自定义RBF内核实现scikit-learn中的SVM,但它显示错误,该怎么办? - I am trying to implement SVM in scikit-learn with custom RBF kernel ,But it is showing an error ,what to do? 在sklearn.svm.SVC(kernel ='rbf')分类器上使用learning_curve的虚假ValueError - Spurious ValueError using learning_curve on sklearn.svm.SVC(kernel='rbf') classifier 如何使用libSVM(RBF内核)选择C和gamma AFTER网格搜索以获得最佳可能的推广? - How to choose C and gamma AFTER grid search using libSVM (RBF kernel) for best possible generalisation? 使用scikit-learn的SVM分类算法(RBF内核)时出现意外结果 - Unexpected results when using scikit-learn's SVM classification algorithm (RBF kernel)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM