`numpy ml.linear model.Linear Regression.prepit ()'在使用复制版码时生成`ValueError',但已安装的 pip 版本如预期一样有效!

作者: naveenmarthala创建于 2022年3月20日更新于 2022年3月20日
标签bug

系统信息

  • 操作系统平台和发行版(例如,Linux Ubuntu 16.04):Ubuntu 18.04
  • Python 版本:3.7.12
  • NumPy 版本:1.21.5 (环境是 2022 年 3 月 20 日的 Google Colab。)

描述当前行为 我从 GitHub 中复制了 numpy_ml.linear_model.LinearRegression 的代码,并对一些虚拟数据执行了 .fit().predict()。我在 .predict() 上得到 ValueError,如下所示:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-10-4be896198177>](https://localhost:8080/#) in <module>()
----> 1 npml_lin_reg2_preds = npml_lin_reg2.predict(X_val)
      2 npml_lin_reg2_preds[:10]
[<ipython-input-8-fc521849e158>](https://localhost:8080/#) in predict(self, X)
    206         if self.fit_intercept:
    207             X = np.c_[np.ones(X.shape[0]), X]
--> 208         return X @ self.beta
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 1 is different from 11)

描述预期行为 预期行为是,.predict() 不会生成 ValueError

内容来源: ddbourgin/numpy-ml