【发布时间】:2014-04-29 00:24:22
【问题描述】:
我正在尝试一些代码来制作学习曲线:
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state = 7)
from sklearn.linear_model import LinearRegression
estimator = LinearRegression()
estimator.fit(X_train, y_train)
y_predicted = estimator.predict(X_test)
fig = plt.figure()
plt.xlabel("Data")
plt.ylabel("MSE")
plt.ylim(-4, 14)
plt.scatter(X_train.ravel(), y_train, color = 'green')#<<<<<<<ERROR HERE
plt.plot(X_test.ravel(), y_predicted, color = 'blue')
plt.show()
结果:
ValueError: x and y must be the same size
打印X_train 和y_train 形状输出:
(1317, 11)
(1317,)
我该如何解决这个问题?
【问题讨论】:
标签: python python-2.7 matplotlib scikit-learn