【问题标题】:ValueError: Shape of passed values is (3, 3), indices imply (3, 7) site:stackoverflow.comValueError:传递值的形状为 (3, 3),索引暗示 (3, 7) 站点:stackoverflow.com
【发布时间】:2023-03-28 09:47:01
【问题描述】:

请尽快帮我...

这是代码

list_of_categories = categories +['Others']

print("Classification Report: \n Target: %s \n Labels: %s \n Classifier: %s:\n%s\n"
      % (target,list_of_categories,classifier, metrics.classification_report(y_test, y_pred)))

df_report = pd.DataFrame(data=metrics.confusion_matrix(y_test, y_pred),columns = list_of_categories)
df_report.index = [list_of_categories]
df_report

然后我有这个错误:

/usr/local/lib/python3.7/dist-packages/pandas/core/internals/managers.py in create_block_manager_from_blocks(blocks, axes)
   1679         blocks = [getattr(b, "values", b) for b in blocks]
   1680         tot_items = sum(b.shape[0] for b in blocks)
-> 1681         raise construction_error(tot_items, blocks[0].shape[1:], axes, e)

ValueError: Shape of passed values is (3, 3), indices imply (3, 7)

我不明白...请帮帮我!!!

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: python python-3.x pandas dataframe


【解决方案1】:
ValueError: Shape of passed values is (3, 3), indices imply (3, 7)

错误是指调用不存在的行的错误数据帧大小调用。

【讨论】:

  • 好吧,这不是问题的答案。
  • 是的,我同意@AbhyudayVaish
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-05-21
  • 1970-01-01
  • 2020-01-12
  • 2018-10-15
  • 2021-10-31
  • 2021-12-05
  • 2021-05-12
相关资源
最近更新 更多