온라인 Support vector regression(SVR)

6293 단어 sklearnsvmPythonSVR
안녕하세요.
"awerries/online-svr "(GiitHub) 찾았어요. 그래서 한번 돌려봤어요.그리고 sklearn.svm.SVR(오프라인) 결과와 차이가 나는 이유는 불분명하다.

svr.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np
import random
import matplotlib.pyplot as plt
from sklearn import svm

import online_svr

N = 100
X = np.linspace(0, 8, N)
y = np.sin(X*np.pi/4) + [random.gauss(0, 0.1) for _ in range(N)]
X = X[:, np.newaxis]

OSVR = online_svr.OnlineSVR(numFeatures=1, C=1, eps=0.1, kernelParam=1, bias=0, debug=False)
for i in range(N):
    OSVR.learn(X[i], y[i])
plt.plot(X, OSVR.predict(X), color='red', label='on-line')

svr = svm.SVR(kernel='rbf', gamma=1, C=1.0, epsilon=0.1, shrinking=False, verbose=True)
svr.fit(X, y)
plt.plot(X, svr.predict(X), color='purple', label='off-line')

plt.scatter(X, y, s=5)
plt.legend()
plt.grid()
plt.show()

좋은 웹페이지 즐겨찾기