cylab-be/php-roc

This package is abandoned and no longer maintained. The author suggests using the cylab/php-roc package instead.

Maintainers

Details

gitlab.cylab.be/cylab/php-roc

1.2.3 2021-09-26 12:10 UTC

This package is auto-updated.

Last update: 2021-09-26 12:10:46 UTC


README

pipeline status coverage report Packagist Version

PHP library for computing Receiver Operating Characteristic (ROC) and Area Under the Curve (AUC).

source: https://en.wikipedia.org/wiki/Receiver_operating_characteristic

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 plotted 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 interesting 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

composer require cylab/php-roc

Usage

Array of values

namespace Cylab\ROC;

require __DIR__ . "/../vendor/autoload.php";

// for each value, we indicate if it is a true detection (true)
// or a false alarm (false)
$values = [];
$values[] = new SimpleValue(0.22568639331762, true);
$values[] = new SimpleValue(0.33365791865329, true);
$values[] = new SimpleValue(0.74073486204293, true);
$values[] = new SimpleValue(0.47706215198946, false);
$values[] = new SimpleValue(0.049798118439409, false);
$values[] = new SimpleValue(0.083663045933313, true);

$roc = ROC::fromValues($values);

// Get the Area Under the Curve (AUC)
echo "AUC : " . $roc->getAUC() . "\n";

// Inpect the points that draw the ROC
var_dump($roc->getPoints());

// Save ROC to png image
$roc->saveToPNG("/tmp/php-roc.png", 800, 600);

The ROC is built from an array of `Valueobjects. AValue` contains a score (between 0 and 1) and indicates if this is a true alert (true) or false alarm (false).

Once built, you can get:

  • the Area Under the Curve : `getAUC()`
  • the coordinates of the points that draw the ROC: `getPoints()`
  • save the ROC as a png image: `saveToPNG($filename, $width, $height)`

php-roc