비선형 회귀
import math
import numpy as np
import matplotlib.pyplot as plt
from sklearn import linear_model
from sklearn import svm
from sklearn import ensemble
from sklearn import neighbors
x = np.random.rand(1000,1)
x = x * 20 - 10
y = np.array([math.sin(v) for v in x])
y += np.random.randn(1000)
#model = linear_model.LinearRegression()
#model = svm.SVR()
model = ensemble.RandomForestRegressor()
#model = neighbors.KNeighborsRegressor()
model.fit(x,y)
#print(model.coef_)
#print(model.intercept_)
print(model.score(x,y))
plt.scatter(x,y,marker = 'o') # expected
plt.scatter(x,model.predict(x),marker = 'x') # predicted
plt.show()