I want to use scikit-learn for calculating the equation of some data. I used this code to fit a curve to my data:
svr_lin = SVR(kernel='linear', C=1e3)
y_lin = svr_lin.fit(X, y).predict(Xp)
But I don't know what I should do to get the exact equation of the fitted model. Do you know how I can get these equations?
Here is an example:
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_)
the output is:
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]
And for a linear kernel, your fitted model is a hyperplane (ω^[T] x+ b = 0), where ω is the vector of weights and b is the intercept.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With