CGAL 5.5.4 - Classification
CGAL::Classification::Evaluation Class Reference

#include <CGAL/Classification/Evaluation.h>

Definition

Class to compute several measurements to evaluate the quality of a classification output.

Constructors

 Evaluation (const Label_set &labels)
 instantiates an empty evaluation object. More...
 
template<typename GroundTruthIndexRange , typename ResultIndexRange >
 Evaluation (const Label_set &labels, const GroundTruthIndexRange &ground_truth, const ResultIndexRange &result)
 instantiates an evaluation object and computes all measurements. More...
 

Modification

template<typename GroundTruthIndexRange , typename ResultIndexRange >
void append (const GroundTruthIndexRange &ground_truth, const ResultIndexRange &result)
 appends more items to the evaluation object. More...
 

Label Evaluation

std::size_t confusion (Label_handle ground_truth, Label_handle result)
 returns the number of items whose ground truth is ground_truth and which were classified as result.
 
float precision (Label_handle label) const
 returns the precision of the training for the given label. More...
 
float recall (Label_handle label) const
 returns the recall of the training for the given label. More...
 
float f1_score (Label_handle label) const
 returns the \(F_1\) score of the training for the given label. More...
 
float intersection_over_union (Label_handle label) const
 returns the intersection over union of the training for the given label. More...
 

Global Evaluation

std::size_t number_of_misclassified_items () const
 returns the number of misclassified items.
 
std::size_t number_of_items () const
 returns the total number of items used for evaluation.
 
float accuracy () const
 returns the accuracy of the training. More...
 
float mean_f1_score () const
 returns the mean \(F_1\) score of the training over all labels (see f1_score()).
 
float mean_intersection_over_union () const
 returns the mean intersection over union of the training over all labels (see intersection_over_union()).
 

Output Formatting Functions

std::ostream & operator<< (std::ostream &os, const Evaluation &evaluation)
 outputs the evaluation in a simple ASCII format to the stream os.
 
static std::ostream & output_to_html (std::ostream &os, const Evaluation &evaluation)
 outputs the evaluation as an HTML page to the stream os.
 

Constructor & Destructor Documentation

◆ Evaluation() [1/2]

CGAL::Classification::Evaluation::Evaluation ( const Label_set labels)

instantiates an empty evaluation object.

Parameters
labelslabels used.

◆ Evaluation() [2/2]

template<typename GroundTruthIndexRange , typename ResultIndexRange >
CGAL::Classification::Evaluation::Evaluation ( const Label_set labels,
const GroundTruthIndexRange &  ground_truth,
const ResultIndexRange &  result 
)

instantiates an evaluation object and computes all measurements.

Parameters
labelslabels used.
ground_truthvector of label indices: it should contain the index of the corresponding label in the Label_set provided in the constructor. Input items that do not have a ground truth information should be given the value -1.
resultsimilar to ground_truth but contained the result of a classification.

Member Function Documentation

◆ accuracy()

float CGAL::Classification::Evaluation::accuracy ( ) const

returns the accuracy of the training.

Accuracy is the total number of true positives divided by the total number of provided inliers.

◆ append()

template<typename GroundTruthIndexRange , typename ResultIndexRange >
void CGAL::Classification::Evaluation::append ( const GroundTruthIndexRange &  ground_truth,
const ResultIndexRange &  result 
)

appends more items to the evaluation object.

Parameters
ground_truthvector of label indices: it should contain the index of the corresponding label in the Label_set provided in the constructor. Input items that do not have a ground truth information should be given the value -1.
resultsimilar to ground_truth but contained the result of a classification.

◆ f1_score()

float CGAL::Classification::Evaluation::f1_score ( Label_handle  label) const

returns the \(F_1\) score of the training for the given label.

\(F_1\) score is the harmonic mean of precision() and recall():

\[ F_1 = 2 \times \frac{precision \times recall}{precision + recall} \]

◆ intersection_over_union()

float CGAL::Classification::Evaluation::intersection_over_union ( Label_handle  label) const

returns the intersection over union of the training for the given label.

Intersection over union is the number of true positives divided by the sum of the true positives, of the false positives and of the false negatives.

◆ precision()

float CGAL::Classification::Evaluation::precision ( Label_handle  label) const

returns the precision of the training for the given label.

Precision is the number of true positives divided by the sum of the true positives and the false positives.

◆ recall()

float CGAL::Classification::Evaluation::recall ( Label_handle  label) const

returns the recall of the training for the given label.

Recall is the number of true positives divided by the sum of the true positives and the false negatives.