我正在运行一个前馈神经网络,并希望得到一个带有直线的混淆矩阵
sklearn.metrics.confusion_matrix(goldLabel_array, predictions, sample_weight=None, labels=None)
但是当我运行它时,它在标题中给出了错误消息。 我安装了 scikit-learn 和 sklearn。当我运行“pip list”时,会列出 sklearn,但版本为 0.0.0。当我运行 conda install sklearn 时,它会给我以下信息:
Collecting package metadata (current_repodata.json): done Solving environment: failed with current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): done Solving environment: failed PackagesNotFoundError: The following packages are not available from current channels: - sklearn Current channels: - https://conda.anaconda.org/loopbio/win-64 - https://conda.anaconda.org/loopbio/noarch - https://repo.anaconda.com/pkgs/main/win-64 - https://repo.anaconda.com/pkgs/main/noarch - https://repo.anaconda.com/pkgs/r/win-64 - https://repo.anaconda.com/pkgs/r/noarch - https://repo.anaconda.com/pkgs/msys2/win-64 - https://repo.anaconda.com/pkgs/msys2/noarch - https://conda.anaconda.org/conda-forge/win-64 - https://conda.anaconda.org/conda-forge/noarch To search for alternate channels that may provide the conda package you're looking for, navigate to https://anaconda.org and use the search bar at the top of the page.
最佳答案
错误与安装无关。它告诉你你没有将库导入到你在代码中调用它的地方。
编辑 您正在直接导入 confusion_matrix
,因此您需要直接引用它,而不是通过 sklearn。
confusion_matrix(goldLabel_array, predictions, sample_weight=None, labels=None)
和你的其他电话一样。
关于python - 名称错误 : name 'sklearn' is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57364290/