我正在尝试建立线性回归模型。请帮忙
database = pd.read_csv('Salary_Data.csv')
x = database.iloc[:,0].values
y = database.iloc[:,1].values
x_train = x_train.reshape(1,-1)
y_train = y_train.reshape(1,-1)
x_test = x_test.reshape(1,-1)
y_test = y_test.reshape(1,-1)
from sklearn.linear_model import LinearRegression
regressor= LinearRegression()
regressor.fit(x_train, y_train)
#predicting the test set results
y_pred = regressor.predict(x_test)
错误是:
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 20 is different from 10)
答案 0 :(得分:0)
我认为在重塑后,您的x_train
(我认为是10个维度)的尺寸与x_test
(20个维度)不同,因此matmul
函数会出错。您应该检查