@@ -33,22 +33,22 @@ private case class BinaryConfusionMatrixImpl(
33
33
totalCount : LabelCounter ) extends BinaryConfusionMatrix with Serializable {
34
34
35
35
/** number of true positives */
36
- override def tp : Long = count.numPositives
36
+ override def numTruePositives : Long = count.numPositives
37
37
38
38
/** number of false positives */
39
- override def fp : Long = count.numNegatives
39
+ override def numFalsePositives : Long = count.numNegatives
40
40
41
41
/** number of false negatives */
42
- override def fn : Long = totalCount.numPositives - count.numPositives
42
+ override def numFalseNegatives : Long = totalCount.numPositives - count.numPositives
43
43
44
44
/** number of true negatives */
45
- override def tn : Long = totalCount.numNegatives - count.numNegatives
45
+ override def numTrueNegatives : Long = totalCount.numNegatives - count.numNegatives
46
46
47
47
/** number of positives */
48
- override def p : Long = totalCount.numPositives
48
+ override def numPositives : Long = totalCount.numPositives
49
49
50
50
/** number of negatives */
51
- override def n : Long = totalCount.numNegatives
51
+ override def numNegatives : Long = totalCount.numNegatives
52
52
}
53
53
54
54
/**
@@ -57,10 +57,10 @@ private case class BinaryConfusionMatrixImpl(
57
57
* @param scoreAndLabels an RDD of (score, label) pairs.
58
58
*/
59
59
class BinaryClassificationMetrics (scoreAndLabels : RDD [(Double , Double )])
60
- extends Serializable with Logging {
60
+ extends Serializable with Logging {
61
61
62
62
private lazy val (
63
- cumCounts : RDD [(Double , LabelCounter )],
63
+ cumulativeCounts : RDD [(Double , LabelCounter )],
64
64
confusions : RDD [(Double , BinaryConfusionMatrix )]) = {
65
65
// Create a bin for each distinct score value, count positives and negatives within each bin,
66
66
// and then sort by score values in descending order.
@@ -74,32 +74,32 @@ class BinaryClassificationMetrics(scoreAndLabels: RDD[(Double, Double)])
74
74
iter.foreach(agg += _)
75
75
Iterator (agg)
76
76
}, preservesPartitioning = true ).collect()
77
- val partitionwiseCumCounts =
77
+ val partitionwiseCumulativeCounts =
78
78
agg.scanLeft(new LabelCounter ())((agg : LabelCounter , c : LabelCounter ) => agg.clone() += c)
79
- val totalCount = partitionwiseCumCounts .last
79
+ val totalCount = partitionwiseCumulativeCounts .last
80
80
logInfo(s " Total counts: $totalCount" )
81
- val cumCounts = counts.mapPartitionsWithIndex(
81
+ val cumulativeCounts = counts.mapPartitionsWithIndex(
82
82
(index : Int , iter : Iterator [(Double , LabelCounter )]) => {
83
- val cumCount = partitionwiseCumCounts (index)
83
+ val cumCount = partitionwiseCumulativeCounts (index)
84
84
iter.map { case (score, c) =>
85
85
cumCount += c
86
86
(score, cumCount.clone())
87
87
}
88
88
}, preservesPartitioning = true )
89
- cumCounts .persist()
90
- val confusions = cumCounts .map { case (score, cumCount) =>
89
+ cumulativeCounts .persist()
90
+ val confusions = cumulativeCounts .map { case (score, cumCount) =>
91
91
(score, BinaryConfusionMatrixImpl (cumCount, totalCount).asInstanceOf [BinaryConfusionMatrix ])
92
92
}
93
- (cumCounts , confusions)
93
+ (cumulativeCounts , confusions)
94
94
}
95
95
96
96
/** Unpersist intermediate RDDs used in the computation. */
97
97
def unpersist () {
98
- cumCounts .unpersist()
98
+ cumulativeCounts .unpersist()
99
99
}
100
100
101
101
/** Returns thresholds in descending order. */
102
- def thresholds (): RDD [Double ] = cumCounts .map(_._1)
102
+ def thresholds (): RDD [Double ] = cumulativeCounts .map(_._1)
103
103
104
104
/**
105
105
* Returns the receiver operating characteristic (ROC) curve,
0 commit comments