kds库提供了AttributeError:模块“kds”没有属性“metrics”

2024-09-28 05:23:14 发布

您现在位置:Python中文网/ 问答频道 /正文

您好,我正在尝试使用pypi kds包。 我已经安装了:pip install kds
我没有任何安装问题。但当我运行以下示例脚本时:

# REPRODUCABLE EXAMPLE
# Load Dataset and train-test split
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn import tree

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33,random_state=3)
clf = tree.DecisionTreeClassifier(max_depth=1,random_state=3)
clf = clf.fit(X_train, y_train)
y_prob = clf.predict_proba(X_test)

# The magic happens here
import kds
kds.metrics.report(y_test, y_prob)

它给出了一个错误:

AttributeError                            Traceback (most recent call last)
<ipython-input-4-fa00bcb248e7> in <module>
     13 # The magic happens here
     14 import kds
---> 15 kds.metrics.report(y_test, y_prob)

AttributeError: module 'kds' has no attribute 'metrics'

Tags: fromtestimporttreeirisloadtrainrandom
1条回答
网友
1楼 · 发布于 2024-09-28 05:23:14

问题已在最新版本中解决。请使用pip install kds更新包

也不要忘记最后一行中的y_prob[:,1]。(scikit学习的输出有2列,因此选择1列)

# The magic happens here
import kds
kds.metrics.plot_lift(y_test, y_prob[:,1])

相关问题 更多 >

    热门问题