map(平均平均精度
Disclaimer: this was created for my clients because it’s rather challenging to explain such a complex metric in simple words, so don’t expect to see much of math or equations here. And remember that I try to keep it simple.
免责声明 :这是为我的客户创建的,因为用一个简单的词来解释这样一个复杂的指标是相当困难的,因此不要期望在这里看到太多的数学或方程式。 并记住,我尝试使其保持简单。
准确性 (Accuracy)
Accuracy is the most vanilla metric out there. Imagine we are doing classification of whether there is a dog in a picture. In order to test our classifier, we prepare a test set with pictures of both containing dogs and not. We then apply our classifier to every picture and get the predicted classes.
准确性是目前最常用的指标。 假设我们正在对图片中是否有狗进行分类。 为了测试我们的分类器,我们准备了一个包含不包含狗的图片的测试集。 然后,我们将分类器应用于每张图片,并获得预测的分类。
So we can then calculate accuracy using this simple formula.
这样我们就可以使用此简单公式来计算准确性。
精度和召回率 (Precision and recall)
There are many more ways to determine how well a model works and two others are precision and recall. They show a bit different things and usually go in a pair.
还有许多方法可以确定模型的运行状况,还有两种方法可以提高精度和召回率 。 它们显示出一些不同的东西,通常成对出现。
Going on with our dog recognizer, precision shows how many of predicted dogs are actually dogs.
继续我们的狗识别器, 精度显示出实际上有多少只预测的狗。
And recall is the ratio of correctly predicted dogs to the amount of dogs in our test set.
回忆是正确预测的狗与测试集中狗的数量之比。
例 (Example)
Let’s imagine that our test set contains 12 pictures with dogs and 8 pictures with no dogs. We apply our classifier and get 8 pictures predicted as “dog” and the rest 12 are “no dog”. And out of those 8 marked as “dog” only 5 are actually “dog” and the rest are just wrong.
假设我们的测试集包含12张有狗的图片和8张无狗的图片。 我们应用分类器,得到8张预测为“狗”的图片,其余12张为“无狗”。 在这8个标记为“狗”的动物中,只有5个实际上是“狗”,其余的都是错误的。
So our precision is
所以我们的精度是
And our recall is
我们的回忆是
Why to use precision and recall?
为什么要使用精度和召回率?
This two metrics give us a deeper understanding of errors that our model makes, hence allowing us to analyze and create better solutions. And because of this in-depth understanding we stick to them and not to the accuracy metric.
这两个指标使我们对模型所产生的错误有更深入的了解,从而使我们能够分析和创建更好的解决方案。 并且由于这种深入的了解,我们坚持使用它们而不是准确性指标。
联合路口 (Intersection over union)
In order to fully understand the mean average precision metric we need to know what intersection over union is.
为了完全理解平均平均精度度量,我们需要知道什么是联合的交集。
It comes up when we create object detection solutions and is needed for determining how well we find an object in a picture.
当我们创建对象检测解决方案时,它就会出现,这是确定我们在图片中找到对象的程度所需要的。
![Image for post](https://miro.medium.com/max/9999/0*O5f-vohhQINmMxeF.png)
Not only do we need to classify an object but also to locate it. Those little colourful rectangles are called bounding boxes.
我们不仅需要对对象进行分类,还需要对其进行定位。 那些小的彩色矩形称为边界框。
So let’s say we have an object detection model but in a what way do we measure how well it detects? That’s when intersection over union (IoU) comes in handy.
因此,假设我们有一个对象检测模型,但是以什么方式衡量它的检测效果呢? 那时,联合交叉口(IoU)派上了用场。
In order to compute this we need a test set with so called ground truth bounding boxes and, of course, they must be labeled at first, so that when it comes to testing we can compare the real data with the predicted data.
为了计算这一点,我们需要一个带有所谓的地面真实边界框的测试集,当然,它们必须首先被标记,以便在进行测试时,我们可以将真实数据与预测数据进行比较。
Let’s say that the green boxes are our ground truth bounding boxes (the boxes we labeled beforehand by our human hands and eyes) and the red ones are predicted by our model.
假设绿色框是我们的地面真值边界框(我们用人的手和眼睛预先标记的框),红色框是我们的模型预测的。
![Image for post](https://miro.medium.com/max/9999/0*B0f3XtdenxW9Li7n.png)
And the formula is now very simple
现在公式很简单
![Image for post](https://miro.medium.com/max/9999/0*gIc-Dw5Fcuwpnb7F.jpg)
To clarify, it’s a ratio of the overlapping (or intersecting) area between a ground truth bounding box and a predicted one and the union area of those two.
为了阐明这一点,它是地面真值边界框和预测的边界框之间的重叠(或相交)区域与这两个区域的并集区域之比。
平均平均精度 (Mean Average Precision)
So what is mean average precision (mAP) then? To calculate it we need to set a threshold value for IoU, for example, 0.5. It means that we say that the object is detected when we located 50% of that object in a bounding box.
那么什么是平均精度 (mAP)呢? 要计算它,我们需要为IoU设置一个阈值,例如0.5。 这意味着当我们在边界框中找到该对象的50%时,便表示已检测到该对象。
Then all we have to do is to calculate precision and recall values. There is a way to combine those two into one value but it’s a bit more advanced so we are not going to cover it here.
然后,我们要做的就是计算精度和召回值。 有一种方法可以将这两个值合并为一个值,但是它要先进一些,因此我们不在这里介绍。
And after that we change the threshold value for IoU with a tiny step. For instance, the next threshold will be 0.55. Then again computing precision and recall values.
之后,我们只需一步就可以更改IoU的阈值。 例如,下一个阈值将是0.55。 然后再次计算精度并调用值。
And again changing the threshold value for IoU. Now it will be 0.6. Again calculating precision and recall values. Usually those threshold values begin with 0.5 and go on up to 0.9 with a step of 0.05.
并再次更改IoU的阈值。 现在将是0.6。 再次计算精度和召回值。 通常,这些阈值以0.5开头,然后以0.05为步长直到0.9。
And then mean average precision is that combined value of precision and recall averaged over all the thresholds.
然后,平均平均精度是指在所有阈值上平均的精度和召回率的总和。
它显示什么? (What does it show?)
It shows how well a model classifies objects with different detection threshold values. The higher the value, the better the model. Results are vary highly but usually a well working model has mAP of 0.45–0.5 on a complex task.
它显示了模型对具有不同检测阈值的对象进行分类的效果。 值越高,模型越好。 结果差异很大,但正常工作的模型通常在复杂任务上的mAP为0.45-0.5。
You can check out example of models’ mAP on COCO dataset here: https://pjreddie.com/darknet/yolo/.
您可以在以下位置查看COCO数据集上模型的mAP示例: https ://pjreddie.com/darknet/yolo/。
Hope, it helps you.
希望对您有帮助。
Connect with me on Twitter, LinkedIn, Facebook and follow on GitHub!
在 Twitter , LinkedIn , Facebook 上与我联系 , 然后在 GitHub上关注我 !
翻译自: https://medium.com/@poddiachyi/mean-average-precision-for-clients-aecb0b039ac9
map(平均平均精度