Traceback (most recent call last): File "D:\chulishuju\main.py", line 401, in <module> main() File "D:\chulishuju\main.py", line 394, in main sns.heatmap(confusion_matrix, annot=True, cmap="Blues", fmt="d", xticklabels=labels, yticklabels=labels) File "D:\2023.5.21\lib\site-packages\seaborn\matrix.py", line 446, in heatmap plotter = _HeatMapper(data, vmin, vmax, cmap, center, robust, annot, fmt, File "D:\2023.5.21\lib\site-packages\seaborn\matrix.py", line 110, in __init__ data = pd.DataFrame(plot_data) File "D:\2023.5.21\lib\site-packages\pandas\core\frame.py", line 722, in __init__ mgr = ndarray_to_mgr( File "D:\2023.5.21\lib\site-packages\pandas\core\internals\construction.py", line 329, in ndarray_to_mgr values = _prep_ndarraylike(values, copy=copy_on_sanitize) File "D:\2023.5.21\lib\site-packages\pandas\core\internals\construction.py", line 583, in _prep_ndarraylike raise ValueError(f"Must pass 2-d input. shape={values.shape}") ValueError: Must pass 2-d input. shape=()
时间: 2023-07-07 20:32:42 浏览: 87
linux 下 pip3 报错“ File “/usr/bin/pip3”, line 9, in from pip import mainImportError: canno”处理
5星 · 资源好评率100%
这个错误是由于传递给 `sns.heatmap()` 函数的数据不是二维的而引起的。 `sns.heatmap()` 函数需要一个二维的数据结构,例如 Pandas DataFrame 或 NumPy 数组。您需要检查传递给函数的数据是否正确,并确保其是二维的。您可以尝试使用 `reshape` 函数将数据转换为二维数组,然后再传递给 `sns.heatmap()` 函数。
阅读全文