无法从 scikit 学习中导入名称 'balanced_accuracy_score'
cannot import name 'balanced_accuracy_score' from scikit learn
我有一个不平衡的数据,想用 "balanced_accuracy_score" 来评估我的模型。但是,尽管我已经将 scikit learn 更新到 0.20,但它对我不起作用。
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-63-266614be2a70> in <module>()
----> 1 from sklearn.metrics import balanced_accuracy_score
2
ImportError: cannot import name 'balanced_accuracy_score'
有人遇到过这个问题并且知道如何解决吗?或者是否有任何替代方法可用于评估二进制分类任务的不平衡数据集。
谢谢!
运行 from sklearn.metrics import balanced_accuracy_score
在我的机器上运行 scikit-learn 0.20.3。如果您可以导入 sklearn
的其余部分,那么这就是奇怪的行为。
但是,如果您无法从 sklearn
导入任何其他内容,请打开您的 shell 并确保命令 pip list
returns 包含以下软件包的列表sklearn
的正确版本。这可能是您的环境管理存在问题。这意味着即使您安装了 sklearn 0.20
,您的 IDE 环境也不会接收它。
如果 pip list
包含正确的包,则尝试 运行 python
在您的 shell 中并在那里导入包。如果可行,这可能意味着您的 IDE 没有选择正确的 python 安装/没有选择您的 venv。
关于问题 the sklearn documentation for balanced accuracy score states that their definition of this function is equivilent to using accuracy_score 中的最后一点,样本权重 class 平衡。
Some literature promotes alternative definitions of balanced accuracy. Our definition is equivalent to accuracy_score with class-balanced sample weights, and shares desirable properties with the binary case.
您可能还想查看其他指标,例如:roc
、f-scores
并绘制带有样本权重的混淆矩阵。
我有一个不平衡的数据,想用 "balanced_accuracy_score" 来评估我的模型。但是,尽管我已经将 scikit learn 更新到 0.20,但它对我不起作用。
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-63-266614be2a70> in <module>()
----> 1 from sklearn.metrics import balanced_accuracy_score
2
ImportError: cannot import name 'balanced_accuracy_score'
有人遇到过这个问题并且知道如何解决吗?或者是否有任何替代方法可用于评估二进制分类任务的不平衡数据集。
谢谢!
运行 from sklearn.metrics import balanced_accuracy_score
在我的机器上运行 scikit-learn 0.20.3。如果您可以导入 sklearn
的其余部分,那么这就是奇怪的行为。
但是,如果您无法从 sklearn
导入任何其他内容,请打开您的 shell 并确保命令 pip list
returns 包含以下软件包的列表sklearn
的正确版本。这可能是您的环境管理存在问题。这意味着即使您安装了 sklearn 0.20
,您的 IDE 环境也不会接收它。
如果 pip list
包含正确的包,则尝试 运行 python
在您的 shell 中并在那里导入包。如果可行,这可能意味着您的 IDE 没有选择正确的 python 安装/没有选择您的 venv。
关于问题 the sklearn documentation for balanced accuracy score states that their definition of this function is equivilent to using accuracy_score 中的最后一点,样本权重 class 平衡。
Some literature promotes alternative definitions of balanced accuracy. Our definition is equivalent to accuracy_score with class-balanced sample weights, and shares desirable properties with the binary case.
您可能还想查看其他指标,例如:roc
、f-scores
并绘制带有样本权重的混淆矩阵。