sklearn中svr(支援向量機迴歸)
阿新 • • 發佈:2019-01-07
支援向量機也可以用來回歸
from sklearn.svm import SVR
import numpy as np
n_samples, n_features = 10, 5
np.random.seed(0)
y = np.random.randn(n_samples)
X = np.random.randn(n_samples, n_features)
clf = SVR(C=1.0, epsilon=0.2)
print(X)
print(y)
clf.fit(X, y)
SVR(C=1.0, cache_size=200, coef0=0.0, degree=3, epsilon=0.2, gamma='auto' ,
kernel='rbf', max_iter=-1, shrinking=True, tol=0.001, verbose=False)
結果
[[ 0.14404357 1.45427351 0.76103773 0.12167502 0.44386323]
[ 0.33367433 1.49407907 -0.20515826 0.3130677 -0.85409574]
[-2.55298982 0.6536186 0.8644362 -0.74216502 2.26975462]
[-1.45436567 0.04575852 -0.18718385 1.53277921 1.46935877 ]
[ 0.15494743 0.37816252 -0.88778575 -1.98079647 -0.34791215]
[ 0.15634897 1.23029068 1.20237985 -0.38732682 -0.30230275]
[-1.04855297 -1.42001794 -1.70627019 1.9507754 -0.50965218]
[-0.4380743 -1.25279536 0.77749036 -1.61389785 -0.21274028]
[-0.89546656 0.3869025 -0.51080514 -1.18063218 -0.02818223]
[ 0.42833187 0.06651722 0.3024719 -0.63432209 -0.36274117]]
[ 1.76405235 0.40015721 0.97873798 2.2408932 1.86755799 -0.97727788
0.95008842 -0.15135721 -0.10321885 0.4105985 ]
http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVR.html