summaryrefslogblamecommitdiff
path: root/site/docs/1.5.0/api/java/org/apache/spark/mllib/evaluation/RankingMetrics.html
blob: ccafbccf06df21516a353ade271afd4650fc062c (plain) (tree)
1
2
3
4
5
6
7



                                                                                                      
                                                                                
                             
                                       





























                                                                                               

                                                                                                                                                                                        




















































































































































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

                                                                                                                                                                                        








































                                                                                                                                                                                               
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_51) on Wed Sep 16 15:55:12 PDT 2015 -->
<title>RankingMetrics</title>
<meta name="date" content="2015-09-16">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="RankingMetrics";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/spark/mllib/evaluation/MultilabelMetrics.html" title="class in org.apache.spark.mllib.evaluation"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/spark/mllib/evaluation/RegressionMetrics.html" title="class in org.apache.spark.mllib.evaluation"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/spark/mllib/evaluation/RankingMetrics.html" target="_top">Frames</a></li>
<li><a href="RankingMetrics.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.spark.mllib.evaluation</div>
<h2 title="Class RankingMetrics" class="title">Class RankingMetrics&lt;T&gt;</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.spark.mllib.evaluation.RankingMetrics&lt;T&gt;</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd>java.io.Serializable, <a href="../../../../../org/apache/spark/Logging.html" title="interface in org.apache.spark">Logging</a></dd>
</dl>
<hr>
<br>
<pre>public class <span class="strong">RankingMetrics&lt;T&gt;</span>
extends java.lang.Object
implements <a href="../../../../../org/apache/spark/Logging.html" title="interface in org.apache.spark">Logging</a>, scala.Serializable</pre>
<div class="block">::Experimental::
 Evaluator for ranking algorithms.
 <p>
 Java users should use <code>RankingMetrics$.of</code> to create a <a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html" title="class in org.apache.spark.mllib.evaluation"><code>RankingMetrics</code></a> instance.
 <p>
 param:  predictionAndLabels an RDD of (predicted ranking, ground truth set) pairs.</div>
<dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../serialized-form.html#org.apache.spark.mllib.evaluation.RankingMetrics">Serialized Form</a></dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!--   -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html#RankingMetrics(org.apache.spark.rdd.RDD, scala.reflect.ClassTag)">RankingMetrics</a></strong>(<a href="../../../../../org/apache/spark/rdd/RDD.html" title="class in org.apache.spark.rdd">RDD</a>&lt;scala.Tuple2&lt;java.lang.Object,java.lang.Object&gt;&gt;&nbsp;predictionAndLabels,
              scala.reflect.ClassTag&lt;<a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html" title="type parameter in RankingMetrics">T</a>&gt;&nbsp;evidence$1)</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html#meanAveragePrecision()">meanAveragePrecision</a></strong>()</code>
<div class="block">Returns the mean average precision (MAP) of all the queries.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html#ndcgAt(int)">ndcgAt</a></strong>(int&nbsp;k)</code>
<div class="block">Compute the average NDCG value of all the queries, truncated at ranking position k.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static &lt;E,T extends java.lang.Iterable&lt;E&gt;&gt;&nbsp;<br><a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html" title="class in org.apache.spark.mllib.evaluation">RankingMetrics</a>&lt;E&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html#of(org.apache.spark.api.java.JavaRDD)">of</a></strong>(<a href="../../../../../org/apache/spark/api/java/JavaRDD.html" title="class in org.apache.spark.api.java">JavaRDD</a>&lt;scala.Tuple2&lt;T,T&gt;&gt;&nbsp;predictionAndLabels)</code>
<div class="block">Creates a <a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html" title="class in org.apache.spark.mllib.evaluation"><code>RankingMetrics</code></a> instance (for Java users).</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html#precisionAt(int)">precisionAt</a></strong>(int&nbsp;k)</code>
<div class="block">Compute the average precision of all the queries, truncated at ranking position k.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_org.apache.spark.Logging">
<!--   -->
</a>
<h3>Methods inherited from interface&nbsp;org.apache.spark.<a href="../../../../../org/apache/spark/Logging.html" title="interface in org.apache.spark">Logging</a></h3>
<code><a href="../../../../../org/apache/spark/Logging.html#initializeIfNecessary()">initializeIfNecessary</a>, <a href="../../../../../org/apache/spark/Logging.html#initializeLogging()">initializeLogging</a>, <a href="../../../../../org/apache/spark/Logging.html#isTraceEnabled()">isTraceEnabled</a>, <a href="../../../../../org/apache/spark/Logging.html#log_()">log_</a>, <a href="../../../../../org/apache/spark/Logging.html#log()">log</a>, <a href="../../../../../org/apache/spark/Logging.html#logDebug(scala.Function0)">logDebug</a>, <a href="../../../../../org/apache/spark/Logging.html#logDebug(scala.Function0, java.lang.Throwable)">logDebug</a>, <a href="../../../../../org/apache/spark/Logging.html#logError(scala.Function0)">logError</a>, <a href="../../../../../org/apache/spark/Logging.html#logError(scala.Function0, java.lang.Throwable)">logError</a>, <a href="../../../../../org/apache/spark/Logging.html#logInfo(scala.Function0)">logInfo</a>, <a href="../../../../../org/apache/spark/Logging.html#logInfo(scala.Function0, java.lang.Throwable)">logInfo</a>, <a href="../../../../../org/apache/spark/Logging.html#logName()">logName</a>, <a href="../../../../../org/apache/spark/Logging.html#logTrace(scala.Function0)">logTrace</a>, <a href="../../../../../org/apache/spark/Logging.html#logTrace(scala.Function0, java.lang.Throwable)">logTrace</a>, <a href="../../../../../org/apache/spark/Logging.html#logWarning(scala.Function0)">logWarning</a>, <a href="../../../../../org/apache/spark/Logging.html#logWarning(scala.Function0, java.lang.Throwable)">logWarning</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!--   -->
</a>
<h3>Constructor Detail</h3>
<a name="RankingMetrics(org.apache.spark.rdd.RDD, scala.reflect.ClassTag)">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>RankingMetrics</h4>
<pre>public&nbsp;RankingMetrics(<a href="../../../../../org/apache/spark/rdd/RDD.html" title="class in org.apache.spark.rdd">RDD</a>&lt;scala.Tuple2&lt;java.lang.Object,java.lang.Object&gt;&gt;&nbsp;predictionAndLabels,
              scala.reflect.ClassTag&lt;<a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html" title="type parameter in RankingMetrics">T</a>&gt;&nbsp;evidence$1)</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="of(org.apache.spark.api.java.JavaRDD)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>of</h4>
<pre>public static&nbsp;&lt;E,T extends java.lang.Iterable&lt;E&gt;&gt;&nbsp;<a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html" title="class in org.apache.spark.mllib.evaluation">RankingMetrics</a>&lt;E&gt;&nbsp;of(<a href="../../../../../org/apache/spark/api/java/JavaRDD.html" title="class in org.apache.spark.api.java">JavaRDD</a>&lt;scala.Tuple2&lt;T,T&gt;&gt;&nbsp;predictionAndLabels)</pre>
<div class="block">Creates a <a href="../../../../../org/apache/spark/mllib/evaluation/RankingMetrics.html" title="class in org.apache.spark.mllib.evaluation"><code>RankingMetrics</code></a> instance (for Java users).</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>predictionAndLabels</code> - a JavaRDD of (predicted ranking, ground truth set) pairs</dd>
<dt><span class="strong">Returns:</span></dt><dd>(undocumented)</dd></dl>
</li>
</ul>
<a name="precisionAt(int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>precisionAt</h4>
<pre>public&nbsp;double&nbsp;precisionAt(int&nbsp;k)</pre>
<div class="block">Compute the average precision of all the queries, truncated at ranking position k.
 <p>
 If for a query, the ranking algorithm returns n (n < k) results, the precision value will be
 computed as #(relevant items retrieved) / k. This formula also applies when the size of the
 ground truth set is less than k.
 <p>
 If a query has an empty ground truth set, zero will be used as precision together with
 a log warning.
 <p>
 See the following paper for detail:
 <p>
 IR evaluation methods for retrieving highly relevant documents. K. Jarvelin and J. Kekalainen
 <p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>k</code> - the position to compute the truncated precision, must be positive</dd>
<dt><span class="strong">Returns:</span></dt><dd>the average precision at the first k ranking positions</dd></dl>
</li>
</ul>
<a name="meanAveragePrecision()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>meanAveragePrecision</h4>
<pre>public&nbsp;double&nbsp;meanAveragePrecision()</pre>
<div class="block">Returns the mean average precision (MAP) of all the queries.
 If a query has an empty ground truth set, the average precision will be zero and a log
 warining is generated.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>(undocumented)</dd></dl>
</li>
</ul>
<a name="ndcgAt(int)">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>ndcgAt</h4>
<pre>public&nbsp;double&nbsp;ndcgAt(int&nbsp;k)</pre>
<div class="block">Compute the average NDCG value of all the queries, truncated at ranking position k.
 The discounted cumulative gain at position k is computed as:
    sum,,i=1,,^k^ (2^{relevance of ''i''th item}^ - 1) / log(i + 1),
 and the NDCG is obtained by dividing the DCG value on the ground truth set. In the current
 implementation, the relevance value is binary.
 <p>
 If a query has an empty ground truth set, zero will be used as ndcg together with
 a log warning.
 <p>
 See the following paper for detail:
 <p>
 IR evaluation methods for retrieving highly relevant documents. K. Jarvelin and J. Kekalainen
 <p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>k</code> - the position to compute the truncated ndcg, must be positive</dd>
<dt><span class="strong">Returns:</span></dt><dd>the average ndcg at the first k ranking positions</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/spark/mllib/evaluation/MultilabelMetrics.html" title="class in org.apache.spark.mllib.evaluation"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/spark/mllib/evaluation/RegressionMetrics.html" title="class in org.apache.spark.mllib.evaluation"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/spark/mllib/evaluation/RankingMetrics.html" target="_top">Frames</a></li>
<li><a href="RankingMetrics.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<script defer="defer" type="text/javascript" src="../../../../../lib/jquery.js"></script><script defer="defer" type="text/javascript" src="../../../../../lib/api-javadocs.js"></script></body>
</html>