precision_recall.h文件代码
时间: 2023-12-09 09:03:46 浏览: 99
以下是 pcl/evaluation/precision_recall.h 文件中的代码示例,包括 PrecisionRecallCurve 类和 confusionMatrix 函数的定义:
```c++
#ifndef PCL_EVALUATION_PRECISION_RECALL_H_
#define PCL_EVALUATION_PRECISION_RECALL_H_
#include <pcl/common/common.h>
#include <pcl/point_types.h>
#include <vector>
#include <map>
#include <iostream>
#include <string>
#include <utility>
namespace pcl
{
namespace evaluation
{
/** \brief A class that computes precision-recall curves.
* \author Radu Bogdan Rusu
* \ingroup evaluation
*/
template<typename PointT>
class PrecisionRecallCurve
{
public:
typedef typename pcl::PointCloud<PointT>::Ptr PointCloudPtr;
typedef typename pcl::PointCloud<PointT>::ConstPtr PointCloudConstPtr;
/** \brief Constructor. */
PrecisionRecallCurve () : tp_ (0), fp_ (0), tn_ (0), fn_ (0) {};
/** \brief Destructor. */
virtual ~PrecisionRecallCurve () {};
/** \brief Add ground truth data.
* \param[in] ground_truth the input ground truth data
*/
virtual void
addGroundTruth (const PointCloudPtr &ground_truth);
/** \brief Add computed data.
* \param[in] computed_data the input computed data
*/
virtual void
addComputedData (const PointCloudPtr &computed_data);
/** \brief Compute the precision-recall curve for the given data.
* \param[out] precision_recall_curve the output precision-recall curve
*/
virtual void
compute (std::vector<std::pair<float, float> > &precision_recall_curve);
/** \brief Reset the internal counters. */
virtual void
reset ();
protected:
/** \brief The number of true positives. */
unsigned int tp_;
/** \brief The number of false positives. */
unsigned int fp_;
/** \brief The number of true negatives. */
unsigned int tn_;
/** \brief The number of false negatives. */
unsigned int fn_;
};
/** \brief Compute the confusion matrix.
* \param[in] ground_truth the input ground truth data
* \param[in] computed_data the input computed data
* \param[out] confusion the output confusion matrix
*/
void
confusionMatrix (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &ground_truth,
const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &computed_data,
std::map<std::string, unsigned int> &confusion);
}
}
#include <pcl/evaluation/impl/precision_recall.hpp>
#endif // PCL_EVALUATION_PRECISION_RECALL_H_
```
其中,PrecisionRecallCurve 类提供了计算精度-召回率曲线的接口,addGroundTruth 和 addComputedData 函数用于添加实际标签和预测标签数据,compute 函数用于计算精度-召回率曲线,reset 函数用于重置内部计数器。confusionMatrix 函数用于计算混淆矩阵。
阅读全文