【问题标题】:ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 13 is different from 2)ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 13 is different from 2)
【发布时间】:2021-09-23 14:49:59
【问题描述】:
variables = df.iloc[:,:13]
results = df1.iloc[:,14:]
regression = linear_model.LinearRegression()
regression.fit(variables,results)
print(variables.shape,results.shape)
input_values = [2,2]
prediction = regression.predict([input_values])
prediction = [round(x,2) for x in prediction[0]]
print(prediction)

错误是 ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 13与 2) 不同。 变量形状为 (51, 13) (51, 11)。

这是多输出回归,当我做预测部分时,存在错误。但我不知道如何解决它,请帮助我。

【问题讨论】:

    标签: python machine-learning


    【解决方案1】:

    问题是您的输入中有 13 个特征,但在预测部分,您只传递了 2 个值。您必须传递一个维度数组 (x, 13),其中 x 属于某个自然数。如果它解决了您的问题,请给绿色勾号并投票。

    【讨论】:

      猜你喜欢
      • 2021-01-11
      • 2021-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-21
      • 2020-09-29
      • 2018-06-18
      • 1970-01-01
      相关资源
      最近更新 更多