且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

混淆矩阵给出不好的结果,但验证准确度约为95%

更新时间:2023-12-03 23:05:40

假设您的预测数组类似于:

Let's say your predictions array is something like:

preds_sigmoid = np.array([[0.8451], [0.454], [0.5111]])

包含这些值的

作为S型,将它们压缩在[0,1]的范围内.当您像以前一样应用 argmax 时,由于 argmax 返回指定轴上的最大索引,因此每次都会获得索引0.

containing these values as sigmoid squeeze them in a range of [0,1]. When you apply argmax as you did, you will get index 0 everytime because argmax returns the maximum index at specified axis.

pred = np.argmax(preds_sigmoid , axis = 1) # pred is full of zeros.

您应该对预测进行评估,例如它是否大于某个阈值,比如说0.5,它属于第二类.您可以为此使用列表理解:

You should evaluate the predictions like if it is bigger than some threshold, let's say 0.5, it belongs to second class. You can use list comprehension for this:

pred = [1 * (x[0]>=0.5) for x in preds_sigmoid]

因此,预测将得到正确处理.

Therefore predictions will be handled properly.