java-roc
Java library for computing Receiver Operating Characteristic (ROC) and Area Under the Curve (AUC).
A Receiver Operating Characteristic curve (ROC curve) is a a graphical plot that illustrates the diagnostic ability of a binary classifier system when its discrimination threshold is varied. The ROC curve is plotting with the False Positive Rate (False alarm) on the X axis and the True Positive Rate (true detection) on the Y axis. It is a very interresting tool to determine the efficiency of a classifier in machine learning. The Area Under the Curve (AUC) is a simple way to compare different ROC curves and to determine the best one. Closer to 1 is the AUC value better is the classifier.
Installation
Usage
Arrays as argument
public static void main(final String[] args) {
double[] score = new double[10];
//Generate elements
for (int i = 0; i < score.length; i++) {
score[i] = Math.random();
}
//Creation of array true_alert
boolean[] true_alert = new boolean[] {
false,
true,
false,
true,
true,
false,
true,
true,
false,
false
};
//Creation of Roc object
Roc roc = new Roc(score, true_alert);
//AUC computation and printing
System.out.println(roc.computeAUC());
//Roc points computation
List<RocCoordinates> roc_coordinates = roc.computeRocPoints();
//Save RocCoordinates in a CSV file
Utils.storeRocCoordinatesInCSVFile(roc_coordinates, "/home/alex/Desktop/Test.csv");
}
- ROC object takes an array of double (between 0 and 1) and an array of boolean elements.
- Method computeRocPoints return a list of RocCoordinates. RocCoordinates represents the X and Y coordinates of a point in the ROC space.
- Method storeRocCoordinatesInCSVFile takes a list of RocCoordinates and String (file path) and store all elements un a CSV file.
From CSV file
public static void main(final String[] args) {
//Creation of Roc object
Roc roc = new Roc("Data.csv");
//AUC computation and printing
System.out.println(roc.computeAUC());
//Roc points computation
List<RocCoordinates> roc_coordinates = roc.computeRocPoints();
//Save RocCoordinates in a CSV file
Utils.storeRocCoordinatesInCSVFile(roc_coordinates, "/home/alex/Desktop/Test.csv");
}
- The CSV file used to build the Roc object must have score elements in the first column (double) and true alert elements in the second (boolean).