我想使用 scikit-learn用于计算一些数据的方程式。我使用此代码为我的数据拟合曲线:
svr_lin = SVR(kernel='linear', C=1e3)
y_lin = svr_lin.fit(X, y).predict(Xp)
但我不知道我应该怎么做才能得到拟合模型的确切方程。 你知道我如何得到这些方程式吗?
最佳答案
这是一个例子:
from sklearn.datasets import load_boston
from sklearn.svm import SVR
boston = load_boston()
X = boston.data
y = boston.target
svr = SVR(kernel='linear')
svr.fit(X,y);
print('weights: ')
print(svr.coef_)
print('Intercept: ')
print(svr.intercept_)
输出是:
weights:
[[-0.14125916 0.03619729 -0.01672455 1.35506651 -2.42367649 5.19249046
-0.0307062 -0.91438543 0.17264082 -0.01115169 -0.64903308 0.01144761
-0.33160831]]
Intercept:
[ 11.03647437]
对于线性内核,您的拟合模型是一个超平面 (ω^[T] x+ b = 0),其中 ω 是权重向量,b 是截距。
关于python - 在scikit-learn中拟合后如何得到方程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39012611/