↰ Return to documentation for file (include/networkit/linkprediction/EvaluationMetric.hpp
)
/*
* EvaluationMetric.hpp
*
* Created on: 17.03.2015
* Author: Kolja Esders
*/
#ifndef NETWORKIT_LINKPREDICTION_EVALUATION_METRIC_HPP_
#define NETWORKIT_LINKPREDICTION_EVALUATION_METRIC_HPP_
#include <networkit/graph/Graph.hpp>
#include <networkit/linkprediction/LinkPredictor.hpp>
namespace NetworKit {
class EvaluationMetric {
virtual std::pair<std::vector<double>, std::vector<double>> generatePoints() = 0;
void calculateStatisticalMeasures();
// The following three helper methods generate statistical measures for every threshold
// based on the given predictions. The names should be self-explanatory.
void setPositivesAndNegatives();
void setTrueAndFalsePositives();
void setTrueAndFalseNegatives();
void sortPointsOfCurve(std::pair<std::vector<double>, std::vector<double>> &curve) const;
protected:
std::pair<std::vector<double>, std::vector<double>>
generatedPoints;
const Graph *testGraph;
std::vector<LinkPredictor::prediction> predictions;
std::vector<index> thresholds;
count numPositives;
count numNegatives;
std::vector<count> truePositives;
std::vector<count> falsePositives;
std::vector<count> trueNegatives;
std::vector<count> falseNegatives;
public:
EvaluationMetric();
explicit EvaluationMetric(const Graph &testGraph);
virtual ~EvaluationMetric() = default;
void setTestGraph(const Graph &newTestGraph);
virtual std::pair<std::vector<double>, std::vector<double>>
getCurve(std::vector<LinkPredictor::prediction> predictions, count numThresholds = 1000);
virtual double
getAreaUnderCurve(std::pair<std::vector<double>, std::vector<double>> curve) const;
virtual double getAreaUnderCurve() const;
};
} // namespace NetworKit
#endif // NETWORKIT_LINKPREDICTION_EVALUATION_METRIC_HPP_