[英]Confusion_matrix ValueError: Classification metrics can't handle a mix of binary and continuous-multioutput targets
can anyone fix undersampling confusion matrix error from the line: undersample_cm = confusion_matrix(original_ytest, undersample_fraud_predictions) I think the problem is from the import or original_ytest and undersample_fraud_predictions任何人都可以从以下行修复欠采样混淆矩阵错误:undersample_cm = chaos_matrix(original_ytest, undersample_fraud_predictions) 我认为问题出在导入或original_ytest和undersample_fraud_predictions
undersample_cm = confusion_matrix(original_ytest, undersample_fraud_predictions)
actual_cm = confusion_matrix(original_ytest, original_ytest)
labels = ['No Fraud', 'Fraud']
confusion_matrix works with two arrays of same size, same type of data.混淆矩阵与两个大小相同、数据类型相同的 arrays 一起使用。
y_true = [1, 0, 0, 1, 0, 1]
y_pred = [0, 0, 0, 0, 0, 1]
confusion_matrix(y_true, y_pred)
I guess there is a continuous variable in any of your arrays.我猜你的任何 arrays 中都有一个连续变量。 For this, if you run the actual_cm line first, you can see which array is the problem.为此,如果您先运行 actual_cm 行,您可以看到问题所在的数组。 One of your arrays, namely original_ytest, contains integer values as it should, but you're probably getting an error because it contains continuous values in the undersample_fraud_predictions array.您的 arrays 之一,即 original_ytest,包含应有的 integer 值,但您可能会遇到错误,因为它在 undersample_fraud_predictions 数组中包含连续值。
original_ytest = [1, 0, 0, 1, 0, 1]
undersample_fraud_predictions = [1, 0, 0, 0, 0, 1.5]
confusion_matrix(original_ytest , undersample_fraud_predictions )
When you run the code I want to explain above, the error you get will be the same (Classification metrics can't handle a mix of binary and continuous targets).当您运行我上面要解释的代码时,您得到的错误将是相同的(分类指标无法处理二进制和连续目标的混合)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.