0
下面是我的审判代码:我用线性回归简单的预测不会执行
from sklearn import linear_model
# plt.title("Time-independent variant student performance analysis")
x_train = [5, 9, 33, 25, 4]
y_train = [35, 2, 14 ,9, 7]
x_test = [14, 2, 8, 1, 11]
# create linear regression object
linear = linear_model.LinearRegression()
#train the model using the training sets and check score
linear.fit(x_train, y_train)
linear.score(x_train, y_train)
# predict output
predicted = linear.predict(x_test)
运行时,这是输出:
ValueError: Found arrays with inconsistent numbers of samples: [1 5]
我已经运行了简单回归,但没有显示输出。为什么?我究竟做错了什么? – user2979063
打印'预测'。这是你的预测。@ user2979063 – Farseer
import numpy as np x_train = np.array([5,9,33,25,4]) y_train = np.array([35,2,14,9,7]) x_test = np.array([14,...]) – user2979063