繁体   English   中英

多元线性回归值错误

[英]Multiple Linear Regression ValueError

我一直试图让我的线性回归 model 来预测到某个目的地的票价,但是,我一直收到这个错误:

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 3 is different from 1)

我的代码:

df = pd.read_csv("data.csv")
df.dropna(inplace=True)
x = df[["Distances","Flight_time","Total_Staff_Pay"]]
y = df[["Price"]]
x_train, x_test, y_train, y_test = train_test_split(x, y, train_size = 0.5, test_size = 0.5, random_state=1)
regression = LinearRegression()
regression.fit(x_train,y_train)


#predicting airport
a = [[3417.33],[7.30178432893716],[4804.57408844065]]
print(regression.predict(a))

我看过其他问题/答案,它们并没有真正帮助。

这应该工作

a = [[3417.33,7.30178432893716,4804.57408844065]]

一行代表一个观察结果,因此应该作为1x3而不是3x1传递

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM