Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions MachineLearning/B/use_Ridge.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from sklearn.linear_model import Ridge
from sklearn import cross_validation
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
from sklearn.preprocessing import PolynomialFeatures

Expand All @@ -12,7 +12,7 @@
poly = PolynomialFeatures(6)
X = poly.fit_transform(x)

train_set_x, test_set_x, train_set_y, test_set_y = cross_validation.train_test_split(X,y,test_size=0.3,random_state=0)
train_set_x, test_set_x, train_set_y, test_set_y = train_test_split(X,y,test_size=0.3,random_state=0)
clf = Ridge(alpha=1.0,fit_intercept=True)
clf.fit(train_set_x,train_set_y)
clf.score(test_set_x,test_set_y)
Expand All @@ -25,4 +25,4 @@
plt.plot(time,y_pre[start,end],'r',label='predict')

plt.legend(loc='upper left')
plt.show()
plt.show()