qminer
Version:
A C++ based data analytics platform for processing large-scale real-time streams containing structured and unstructured data
491 lines (483 loc) • 20.4 kB
HTML
<html>
<head>
<meta name="generator" content="JSDoc 3">
<meta charset="utf-8">
<title>Class: PredictionCurve</title>
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
<div id="jsdoc-navbar-container">
<div id="jsdoc-navbar-content">
<a href="index.html" class="jsdoc-navbar-package-name">QMiner JavaScript API v9.4.0</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-main" role="main">
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span> <span class="label label-static">static</span></div>
<h1><small><a href="module-analytics.html">analytics</a>~<wbr><a href="module-analytics-metrics.html">metrics</a>.<wbr></small><span class="symbol-name">PredictionCurve</span></h1>
<p class="source-link">Source: <a href="analyticsdoc.js.html#source-line-3578">analyticsdoc.<wbr>js:3578</a></p>
<div class="symbol-classdesc">
<p>Used for computing ROC curve and other related measures such as AUC.</p>
</div>
<dl class="dl-compact">
</dl>
</header>
<section id="summary">
<div class="summary-callout">
<h2 class="summary-callout-heading">Properties</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-analytics-metrics.PredictionCurve.html#allNegatives">allNegatives</a></dt>
<dd>
</dd>
<dt><a href="module-analytics-metrics.PredictionCurve.html#allPositives">allPositives</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-analytics-metrics.PredictionCurve.html#grounds">grounds</a></dt>
<dd>
</dd>
<dt><a href="module-analytics-metrics.PredictionCurve.html#length">length</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-analytics-metrics.PredictionCurve.html#predictions">predictions</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
<div class="summary-callout">
<h2 class="summary-callout-heading">Methods</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-analytics-metrics.PredictionCurve.html#auc">auc([sample])</a></dt>
<dd>
</dd>
<dt><a href="module-analytics-metrics.PredictionCurve.html#bestF1">bestF1()</a></dt>
<dd>
</dd>
<dt><a href="module-analytics-metrics.PredictionCurve.html#breakEvenPoint">breakEvenPoint()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-analytics-metrics.PredictionCurve.html#desiredPrecision">desiredPrecision(desiredPrecision)</a></dt>
<dd>
</dd>
<dt><a href="module-analytics-metrics.PredictionCurve.html#desiredRecall">desiredRecall(desiredRecall)</a></dt>
<dd>
</dd>
<dt><a href="module-analytics-metrics.PredictionCurve.html#precisionRecallCurve">precisionRecallCurve([sample])</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-analytics-metrics.PredictionCurve.html#push">push(ground, predicted)</a></dt>
<dd>
</dd>
<dt><a href="module-analytics-metrics.PredictionCurve.html#roc">roc([sample])</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
</section>
<section>
<h2 id="PredictionCurve">new <span class="symbol-name">PredictionCurve</span><span class="signature"><span class="signature-params">(yTrue, yPred)</span></span></h2>
<p>Class implements several prediction curve measures (ROC, AOC, Precision-Recall, ...).</p>
<section>
<h3>
Example
</h3>
<div>
<pre class="prettyprint"><code>// import metrics module
var metrics = require('qminer').analytics.metrics;
// true and predicted lables
var true_lables = [0, 1, 0, 0, 1];
var pred_prob = [0.3, 0.5, 0.2, 0.5, 0.8];
// create predictionCurve instance
var predictionCurve = new metrics.PredictionCurve();
// simulate data flow
for (var i in true_lables) {
// push new value
predictionCurve.push(true_lables[i], pred_prob[i]);
}
var roc = predictionCurve.roc(); // get ROC
var auc = predictionCurve.auc(); // get AUC
var pr = predictionCurve.precisionRecallCurve() // get precision-recall curve</code></pre>
</div>
</section>
<section>
<h3>Parameters</h3>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>yTrue</p>
</td>
<td>
<p>(Array of number or <a href="module-la.Vector.html">module:la.Vector</a>)</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>Ground truth (correct) lable(s) of binary classification in range {-1, 1} or {0, 1}.</p>
</td>
</tr>
<tr>
<td>
<p>yPred</p>
</td>
<td>
<p>(Array of number or <a href="module-la.Vector.html">module:la.Vector</a>)</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>Estimated probabilities.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
</section>
<section>
<h2>Properties</h2>
<section>
<h3 id="allNegatives"><span class="symbol-name">allNegatives</span><small class="property-type">
number</small></h3>
<p>Count of all negative examples.</p>
<dl class="dl-compact">
</dl>
<h3 id="allPositives"><span class="symbol-name">allPositives</span><small class="property-type">
number</small></h3>
<p>Count of all positive examples.</p>
<dl class="dl-compact">
</dl>
<h3 id="grounds"><span class="symbol-name">grounds</span><small class="property-type">
<a href="module-la.Vector.html">module:la.Vector</a></small></h3>
<p>Store of ground truths.</p>
<dl class="dl-compact">
</dl>
<h3 id="length"><span class="symbol-name">length</span><small class="property-type">
number</small></h3>
<p>Count of all examples.</p>
<dl class="dl-compact">
</dl>
<h3 id="predictions"><span class="symbol-name">predictions</span><small class="property-type">
<a href="module-la.Vector.html">module:la.Vector</a></small></h3>
<p>Store of predictions.</p>
<dl class="dl-compact">
</dl>
</section>
<h2>Methods</h2>
<section>
<h3 id="auc"><span class="symbol-name">auc</span><span class="signature"><span class="signature-params">([sample])</span> → <span class="signature-returns"> number</span></span></h3>
<p>Get Area Under the Curve (AUC) of the current curve.</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>sample</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Desired number of samples in output.</p>
<p>Defaults to <code>10</code>.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>number</code>B Area under ROC curve.</p>
</dd>
</dl>
<h3 id="bestF1"><span class="symbol-name">bestF1</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> number</span></span></h3>
<p>Gets threshold for prediction score, which results in the highest F1.</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>number</code>B Threshold with highest F1 score.</p>
</dd>
</dl>
<h3 id="breakEvenPoint"><span class="symbol-name">breakEvenPoint</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> number</span></span></h3>
<p>Get break-even point, the value where precision and recall intersect.</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>number</code>B Break-even point.</p>
</dd>
</dl>
<h3 id="desiredPrecision"><span class="symbol-name">desiredPrecision</span><span class="signature"><span class="signature-params">(desiredPrecision)</span> → <span class="signature-returns"> number</span></span></h3>
<p>Gets threshold for prediction score, nearest to specified precision.</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>desiredPrecision</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>Desired precision score.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>number</code>B Threshold for prediction score, nearest to specified <code>precision</code>.</p>
</dd>
</dl>
<h3 id="desiredRecall"><span class="symbol-name">desiredRecall</span><span class="signature"><span class="signature-params">(desiredRecall)</span> → <span class="signature-returns"> number</span></span></h3>
<p>Gets threshold for prediction score, nearest to specified recall.</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>desiredRecall</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>Desired recall score.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>number</code>B Recal Score Threshold. Threshold for recall score, nearest to specified <code>recall</code>.</p>
</dd>
</dl>
<h3 id="precisionRecallCurve"><span class="symbol-name">precisionRecallCurve</span><span class="signature"><span class="signature-params">([sample])</span> → <span class="signature-returns"> <a href="module-la.Matrix.html">module:la.Matrix</a></span></span></h3>
<p>Get precision recall curve sampled on <code>sample</code> points.</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>sample</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Desired number of samples in output.</p>
<p>Defaults to <code>10</code>.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code><a href="module-la.Matrix.html">module:la.Matrix</a></code>B Precision-recall pairs.</p>
</dd>
</dl>
<h3 id="push"><span class="symbol-name">push</span><span class="signature"><span class="signature-params">(ground, predicted)</span></span></h3>
<p>Add new measurement with ground score (1 or -1) and predicted value
or integer array (when there are zero or more then one lables).</p>
<section>
<h4>Parameters</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>ground</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>Correct lable.</p>
</td>
</tr>
<tr>
<td>
<p>predicted</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>Estimated probabilities.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<h3 id="roc"><span class="symbol-name">roc</span><span class="signature"><span class="signature-params">([sample])</span> → <span class="signature-returns"> <a href="module-la.Matrix.html">module:la.Matrix</a></span></span></h3>
<p>Get Receiver Operating Characteristic (ROC) parametrization sampled on <code>sample</code> points.</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>sample</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Desired number of samples in output.</p>
<p>Defaults to <code>10</code>.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code><a href="module-la.Matrix.html">module:la.Matrix</a></code>B A matrix with increasing false and true positive rates.</p>
</dd>
</dl>
</section>
</section>
</div>
</div>
<nav id="jsdoc-toc-nav" role="navigation"></nav>
</div>
</div>
<footer id="jsdoc-footer" class="jsdoc-footer">
<div id="jsdoc-footer-container">
<p>
</p>
</div>
</footer>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tree.jquery.js"></script>
<script src="scripts/prettify.js"></script>
<script src="scripts/jsdoc-toc.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/scrollanchor.js"></script>
</body>
</html>