Class EvaluationMetric

Inheritance Relationships

Derived Types

Class Documentation

class EvaluationMetric

Abstract base class for evaluation curves. The evaluation curves are generated based on the predictions calculated by the link predictor and a testGraph to compare against.

Subclassed by NetworKit::PrecisionRecallMetric, NetworKit::ROCMetric

Public Functions

EvaluationMetric()
explicit EvaluationMetric(const Graph &testGraph)
Parameters:
  • testGraphGraph containing the links to use for evaluation

  • predictions – Dyad-score-pairs whose prediction quality will be evaluated

virtual ~EvaluationMetric() = default

Default destructor.

void 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:

newTestGraph – New graph to use as ground truth

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. 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 behavior described above will intervene.

Parameters:
  • predictions – Predictions to evaluate

  • numThresholds – The 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

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.

Parameters:

curve – Curve whose AUC to determine

Returns:

the area under the given curve

virtual double getAreaUnderCurve() const

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

Protected Attributes

std::pair<std::vector<double>, std::vector<double>> generatedPoints

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

const Graph *testGraph

Used to evaluate the binary predictions at the thresholds.

std::vector<LinkPredictor::prediction> predictions

Predictions that should be evaluated.

std::vector<index> thresholds

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

count numPositives

Absolute number of positive instances in the prediction-set.

count numNegatives

Absolute number of negative instances in the prediction-set.

std::vector<count> truePositives

True positives regarding the corresponding threshold.

std::vector<count> falsePositives

False positives regarding the corresponding threshold.

std::vector<count> trueNegatives

True negatives regarding the corresponding threshold.

std::vector<count> falseNegatives

False negatives regarding the corresponding threshold.