All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
NetworKit::EvaluationMetric Class Referenceabstract

Abstract base class for evaluation curves. More...

#include <EvaluationMetric.h>

Public Member Functions

 EvaluationMetric ()
 
 EvaluationMetric (const Graph &testGraph)
 
virtual ~EvaluationMetric ()=default
 Default destructor. More...
 
void setTestGraph (const Graph &newTestGraph)
 Sets a new graph to use as ground truth for evaluation. More...
 
virtual std::pair< std::vector
< double >, std::vector
< double > > 
getCurve (std::vector< LinkPredictor::prediction > predictions, count numThresholds=1000)
 Returns a pair of X- and Y-vectors describing the evaluation curve generated from the predictions. More...
 
virtual double getAreaUnderCurve (std::pair< std::vector< double >, std::vector< double >> curve) const
 Returns the area under the given curve by using the trapezoidal rule. More...
 
virtual double getAreaUnderCurve () const
 Returns the area under the curve that was most recently calculated by this instance. More...
 

Protected Attributes

std::pair< std::vector< double >
, std::vector< double > > 
generatedPoints
 Points describing the generated curve. Will be set after a call to getCurve. More...
 
const GraphtestGraph
 Used to evaluate the binary predictions at the thresholds. More...
 
std::vector
< LinkPredictor::prediction
predictions
 Predictions that should be evaluated. More...
 
std::vector< indexthresholds
 Indices for the thresholds to use. All node-pairs with an index < thresholds[i] will be regarded as links. More...
 
count numPositives
 Absolute number of positive instances in the prediction-set. More...
 
count numNegatives
 Absolute number of negative instances in the prediction-set. More...
 
std::vector< counttruePositives
 True positives regarding the corresponding threshold. More...
 
std::vector< countfalsePositives
 False positives regarding the corresponding threshold. More...
 
std::vector< counttrueNegatives
 True negatives regarding the corresponding threshold. More...
 
std::vector< countfalseNegatives
 False negatives regarding the corresponding threshold. More...
 

Detailed Description

Abstract base class for evaluation curves.

The evualation curves are generated based on the predictions calculated by the link predictor and a testGraph to compare against.

Constructor & Destructor Documentation

NetworKit::EvaluationMetric::EvaluationMetric ( )
NetworKit::EvaluationMetric::EvaluationMetric ( const Graph testGraph)
explicit
Parameters
testGraphGraph containing the links to use for evaluation
predictionsDyad-score-pairs whose prediction quality will be evaluated
virtual NetworKit::EvaluationMetric::~EvaluationMetric ( )
virtualdefault

Default destructor.

Member Function Documentation

double NetworKit::EvaluationMetric::getAreaUnderCurve ( std::pair< std::vector< double >, std::vector< double >>  curve) const
virtual

Returns the area under the given curve by using the trapezoidal rule.

Parameters
curveCurve whose AUC to determine
Returns
the area under the given curve
double NetworKit::EvaluationMetric::getAreaUnderCurve ( ) const
virtual

Returns the area under the curve that was most recently calculated by this instance.

This implies that getCurve() has to get called beforehand.

Returns
area under the most recently calculated curve
std::pair< std::vector< double >, std::vector< double > > NetworKit::EvaluationMetric::getCurve ( std::vector< LinkPredictor::prediction predictions,
count  numThresholds = 1000 
)
virtual

Returns a pair of X- and Y-vectors describing the evaluation curve generated from the predictions.

The latest y-value will be used as a tie-breaker in case there are multiple y-values for one x-value. Note that the given number of thresholds (numThresholds) is an upper bound for the number of points returned. This is due to the fact that multiple y-values can map to one x-value in which case the tie-breaking behaviour described above will intervene.

Parameters
predictionsPredictions to evaluate
numThresholdsThe number of thresholds to use the metric on
Returns
a pair of vectors where the first vectors contains all x-values and the second one contains the corresponding y-value
void NetworKit::EvaluationMetric::setTestGraph ( const Graph newTestGraph)

Sets a new graph to use as ground truth for evaluation.

Note that this won't reset the most recently calculated curve and as a consequence getAreaUnderCurve() const will still behave as expected by returning the AUC of the most recent curve.

Parameters
newTestGraphNew graph to use as ground truth

Member Data Documentation

std::vector<count> NetworKit::EvaluationMetric::falseNegatives
protected

False negatives regarding the corresponding threshold.

std::vector<count> NetworKit::EvaluationMetric::falsePositives
protected

False positives regarding the corresponding threshold.

std::pair<std::vector<double>, std::vector<double> > NetworKit::EvaluationMetric::generatedPoints
protected

Points describing the generated curve. Will be set after a call to getCurve.

count NetworKit::EvaluationMetric::numNegatives
protected

Absolute number of negative instances in the prediction-set.

count NetworKit::EvaluationMetric::numPositives
protected

Absolute number of positive instances in the prediction-set.

std::vector<LinkPredictor::prediction> NetworKit::EvaluationMetric::predictions
protected

Predictions that should be evaluated.

const Graph* NetworKit::EvaluationMetric::testGraph
protected

Used to evaluate the binary predictions at the thresholds.

std::vector<index> NetworKit::EvaluationMetric::thresholds
protected

Indices for the thresholds to use. All node-pairs with an index < thresholds[i] will be regarded as links.

std::vector<count> NetworKit::EvaluationMetric::trueNegatives
protected

True negatives regarding the corresponding threshold.

std::vector<count> NetworKit::EvaluationMetric::truePositives
protected

True positives regarding the corresponding threshold.


The documentation for this class was generated from the following files: