Python ValueError:不支持未知格式:ROC曲线
我刚刚将python版本从3.5更新到3.7,在构建ROC曲线时出现了一个错误。我没有更改代码中的任何内容,但它给出了一些未知错误 代码Python ValueError:不支持未知格式:ROC曲线,python,python-3.x,pandas,numpy,scikit-learn,Python,Python 3.x,Pandas,Numpy,Scikit Learn,我刚刚将python版本从3.5更新到3.7,在构建ROC曲线时出现了一个错误。我没有更改代码中的任何内容,但它给出了一些未知错误 代码 # ROC Curve from sklearn.metrics import confusion_matrix, accuracy_score, roc_auc_score, roc_curve y_pred_proba = predictions[::, 1] print("y_pred_proba", y_pred_proba) p
# ROC Curve
from sklearn.metrics import confusion_matrix, accuracy_score, roc_auc_score, roc_curve
y_pred_proba = predictions[::, 1]
print("y_pred_proba", y_pred_proba)
print("y_test", y_test)
fpr, tpr, _ = roc_curve(y_test, y_pred_proba)
auc = roc_auc_score(y_test, y_pred_proba)
plt.figure(figsize=(7, 3))
from sklearn.metrics import confusion_matrix, accuracy_score, roc_auc_score, roc_curve
y_pred_proba = predictions[::, 1]
y_test = y_test.astype(int)
fpr, tpr, _ = roc_curve(y_test, y_pred_proba)
auc = roc_auc_score(y_test, y_pred_proba)
plt.figure(figsize=(7, 3))
值
y_pred_proba[0.1746994 0.22792926 0.60020134 0.60857445 0.38630289 0.1631328
0.20503542 0.76781874 0.89951127 0.13657112 0.36836385 0.23833946
0.43924601 0.9874083 0.98404103 0.1003149 0.94596688 0.36480605
0.48716601 0.04158647 0.8624937 0.93881636 0.54065999 0.38538261
0.48002784 0.9874083 0.76781874 0.95791353 0.48002784 0.2448756
0.98404103 0.06473023 0.34080482 0.11897602 0.07883822 0.08000581
0.38630289 0.2546955 0.95515939 0.47123327 0.93544655 0.52027235
0.23231433 0.45185196 0.78456432 0.92415415 0.22408711 0.82322069
0.12670252 0.50150037 0.2546955 0.93881636 0.33043862 0.52027235
0.07964735 0.11961717 0.79551265 0.0378607 0.34080482 0.87411928
0.85397911 0.9874083 0.18885285 0.93140091 0.87411928 0.52027235
0.48716601 0.19411124 0.06473023 0.79551265 0.76781874 0.81180605
0.06833817 0.45406719 0.54006639 0.48002784 0.12468554 0.38630289
0.18068918 0.9874083 0.79551265 0.43924601 0.86979492 0.15120609
0.56046085 0.27958234 0.50261158 0.23231433 0.42496329 0.98404103
0.93881636 0.96244002 0.38049589 0.9874083 0.38354959 0.8624937
0.48716601 0.89951127 0.98404103 0.37245044 0.38630289 0.49835809
0.9874083 0.27773467 0.98404103 0.40968608 0.3587635 0.1003149
0.2572435 0.52492011 0.19933781 0.38538261 0.24401876 0.06473023
0.82322069]
y_检验[1 0 1 0 0 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 0 0 1 1
0 1 1 1 0 0 1 0 1 0 1 0 1 1 1 1 1 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 0 1
1 0 0 0 0 1 1 0 1 0 0 0 0 0 0 1 1 1 0 1 0 1 1 1 1 0 0 1 1 0 1 0 0 0 1 0 0
0 0 0 1 0 0 0 0 1 0 1 0 0 0 1 1 0 1 0 0 1 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0
01 11 0 01 11 01]
Traceback (most recent call last):
File "/home/khawar/deepface/tests/Ensemble-Face-Recognition.py", line 897, in <module>
fpr, tpr, _ = roc_curve(y_test, y_pred_proba)
File "/home/khawar/.local/lib/python3.6/site-packages/sklearn/utils/validation.py", line 72, in inner_f
return f(**kwargs)
File "/home/khawar/.local/lib/python3.6/site-packages/sklearn/metrics/_ranking.py", line 776, in roc_curve
y_true, y_score, pos_label=pos_label, sample_weight=sample_weight)
File "/home/khawar/.local/lib/python3.6/site-packages/sklearn/metrics/_ranking.py", line 539, in _binary_clf_curve
raise ValueError("{0} format is not supported".format(y_type))
ValueError: unknown format is not supported
回溯(最近一次呼叫最后一次):
文件“/home/khawar/deepface/tests/emosemble Face Recognition.py”,第897行,在
fpr,tpr,u=roc_曲线(y_检验,y_预测概率)
文件“/home/khawar/.local/lib/python3.6/site-packages/sklearn/utils/validation.py”,第72行,内部
返回f(**kwargs)
roc_曲线中的文件“/home/khawar/.local/lib/python3.6/site packages/sklearn/metrics/_ranking.py”,第776行
y_为真,y_分数,位置标签=位置标签,样本重量=样本重量)
文件“/home/khawar/.local/lib/python3.6/site packages/sklearn/metrics/_ranking.py”,第539行,在二元曲线中
raise VALUERROR(“{0}格式不受支持”。格式(y_类型))
ValueError:不支持未知格式
如果我们打印目标类型的值(y\u测试)
输出值为“未知”。现在,我们必须将未知值改为整数。所以我们会这样做
y_test = y_test.astype(int)
总体代码
# ROC Curve
from sklearn.metrics import confusion_matrix, accuracy_score, roc_auc_score, roc_curve
y_pred_proba = predictions[::, 1]
print("y_pred_proba", y_pred_proba)
print("y_test", y_test)
fpr, tpr, _ = roc_curve(y_test, y_pred_proba)
auc = roc_auc_score(y_test, y_pred_proba)
plt.figure(figsize=(7, 3))
from sklearn.metrics import confusion_matrix, accuracy_score, roc_auc_score, roc_curve
y_pred_proba = predictions[::, 1]
y_test = y_test.astype(int)
fpr, tpr, _ = roc_curve(y_test, y_pred_proba)
auc = roc_auc_score(y_test, y_pred_proba)
plt.figure(figsize=(7, 3))
如果我们打印
type\u的值(y\u测试)
则输出值为“未知”。现在,我们必须将未知值改为整数。所以我们会这样做
y_test = y_test.astype(int)
总体代码
# ROC Curve
from sklearn.metrics import confusion_matrix, accuracy_score, roc_auc_score, roc_curve
y_pred_proba = predictions[::, 1]
print("y_pred_proba", y_pred_proba)
print("y_test", y_test)
fpr, tpr, _ = roc_curve(y_test, y_pred_proba)
auc = roc_auc_score(y_test, y_pred_proba)
plt.figure(figsize=(7, 3))
from sklearn.metrics import confusion_matrix, accuracy_score, roc_auc_score, roc_curve
y_pred_proba = predictions[::, 1]
y_test = y_test.astype(int)
fpr, tpr, _ = roc_curve(y_test, y_pred_proba)
auc = roc_auc_score(y_test, y_pred_proba)
plt.figure(figsize=(7, 3))
更新python后您是否使用相同的
sklearn
版本?对不起,我不记得我使用的是相同的版本还是不同的版本。更新python后您是否使用相同的sklearn
版本?对不起,我不记得我使用的是相同的版本还是不同的版本