Machine learning sklearn:SVR无法推广加法器函数

Machine learning sklearn:SVR无法推广加法器函数,machine-learning,scikit-learn,regression,artificial-intelligence,generalization,Machine Learning,Scikit Learn,Regression,Artificial Intelligence,Generalization,这是我学习加法器函数的SVR(y=x1+x2): 但结果并不是预期的: Input values are those in the train data: 1 + 2 = 6.007171 Input values are those in the train data: 5 + 6 = 9.595818 Input values are those NOT in the train data, but in range: 5 + 5 = 8.533934 Input values are

这是我学习加法器函数的SVR(y=x1+x2):

但结果并不是预期的:

Input values are those in the train data:
1 + 2 = 6.007171

Input values are those in the train data:
5 + 6 = 9.595818

Input values are those NOT in the train data, but in range:
5 + 5 = 8.533934

Input values are those NOT in the train data, and OUT of range:
9 + 1 = 9.170507

sklearn SVR是否可以推广加法器函数?要让SVR学习x1+x2,上面的代码中应该做什么更改?

三次多项式核的方差太大,无法正确预测如此简单的函数,尤其是在如此小的数据集上。这是基于偏差/方差权衡。在这种情况下,您的模型失去了方差,而几乎没有任何偏差(您的函数过于复杂)。甚至低阶多项式和径向基函数也是如此

降低模型的方差就可以做到这一点。只需使用线性核

Model=svm.SVR(kernel=“linear”)
线性核支持向量机的结果如下:

Input values are those in the train data:
1 + 2 = 3.100000

Input values are those in the train data:
5 + 6 = 10.966667

Input values are those NOT in the train data, but in range:
5 + 5 = 9.983333

Input values are those NOT in the train data, and OUT of range:
9 + 1 = 9.983333
Input values are those in the train data:
1 + 2 = 3.100000

Input values are those in the train data:
5 + 6 = 10.966667

Input values are those NOT in the train data, but in range:
5 + 5 = 9.983333

Input values are those NOT in the train data, and OUT of range:
9 + 1 = 9.983333