Package cc.mallet.types
Class ROCData
- java.lang.Object
-
- cc.mallet.types.ROCData
-
- All Implemented Interfaces:
AlphabetCarrying
,java.io.Serializable
public class ROCData extends java.lang.Object implements AlphabetCarrying, java.io.Serializable
Tracks ROC data for instances inTrial
results.- Author:
- Michael Bond mikejbond@gmail.com
- See Also:
Trial
,InstanceList
,Classifier
,Classification
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
FALSE_NEGATIVE
static int
FALSE_POSITIVE
static int
TRUE_NEGATIVE
static int
TRUE_POSITIVE
-
Constructor Summary
Constructors Constructor Description ROCData(double[] thresholds, LabelAlphabet labelAlphabet)
Constructs a new object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Classification classification)
Adds classification results to the ROC datavoid
add(Trial trial)
Adds trial results to the ROC datavoid
add(ROCData rocData)
Adds existing ROC data to this ROC dataAlphabet
getAlphabet()
Alphabet[]
getAlphabets()
int[][]
getCounts(Label label)
Gets the raw counts for a specified label.int[]
getCounts(Label label, double threshold)
Gets the raw counts for a specified label and threshold.LabelAlphabet
getLabelAlphabet()
Gets the label alphabetdouble
getPositivePercent(Label label, double threshold)
Gets the estimated percentage of training events that exceed the threshold.double
getPrecision(Label label, double threshold)
Gets the precision for a specified label and threshold.double
getPrecisionForScore(Label label, double score)
Gets the precision for a specified label and score.double
getRecall(Label label, double threshold)
Gets the recall rate for a specified label and threshold.double[]
getThresholds()
Gets the thresholds being trackedvoid
setCounts(Label label, double threshold, int[] newCounts)
Sets the raw counts for a specified label and threshold.java.lang.String
toString()
-
-
-
Field Detail
-
TRUE_POSITIVE
public static final int TRUE_POSITIVE
- See Also:
- Constant Field Values
-
FALSE_POSITIVE
public static final int FALSE_POSITIVE
- See Also:
- Constant Field Values
-
FALSE_NEGATIVE
public static final int FALSE_NEGATIVE
- See Also:
- Constant Field Values
-
TRUE_NEGATIVE
public static final int TRUE_NEGATIVE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ROCData
public ROCData(double[] thresholds, LabelAlphabet labelAlphabet)
Constructs a new object- Parameters:
thresholds
- Array of thresholds to track counts forlabelAlphabet
- Label alphabet for instances inTrial
-
-
Method Detail
-
add
public void add(Classification classification)
Adds classification results to the ROC data- Parameters:
trial
- Trial results to add to ROC data
-
add
public void add(Trial trial)
Adds trial results to the ROC data- Parameters:
trial
- Trial results to add to ROC data
-
add
public void add(ROCData rocData)
Adds existing ROC data to this ROC data- Parameters:
rocData
- ROC data to add
-
getAlphabet
public Alphabet getAlphabet()
- Specified by:
getAlphabet
in interfaceAlphabetCarrying
-
getAlphabets
public Alphabet[] getAlphabets()
- Specified by:
getAlphabets
in interfaceAlphabetCarrying
-
getCounts
public int[][] getCounts(Label label)
Gets the raw counts for a specified label.- Parameters:
label
- Label to get counts for- Returns:
- Array of raw counts for specified label
- See Also:
TRUE_POSITIVE
,FALSE_POSITIVE
,FALSE_NEGATIVE
,TRUE_NEGATIVE
-
getCounts
public int[] getCounts(Label label, double threshold)
Gets the raw counts for a specified label and threshold. If data was not collected for the exact threshold specified, then results for the highest threshold <= the specified threshold will be returned.- Parameters:
label
- Label to get counts forthreshold
- Threshold to get counts for- Returns:
- Array of raw counts for specified label and threshold
- See Also:
TRUE_POSITIVE
,FALSE_POSITIVE
,FALSE_NEGATIVE
,TRUE_NEGATIVE
-
getLabelAlphabet
public LabelAlphabet getLabelAlphabet()
Gets the label alphabet
-
getPrecision
public double getPrecision(Label label, double threshold)
Gets the precision for a specified label and threshold. If data was not collected for the exact threshold specified, then results will for the highest threshold <= the specified threshold will be returned.- Parameters:
label
- Label to get precision forthreshold
- Threshold to get precision for- Returns:
- Precision for specified label and threshold
-
getPrecisionForScore
public double getPrecisionForScore(Label label, double score)
Gets the precision for a specified label and score. This differs from {@link ROCData.getPrecision(Label, double)} in that it is the precision for only scores falling in the one score value, not for all scores above the threshold. If data was not collected for the exact threshold specified, then results will for the highest threshold <= the specified threshold will be returned.- Parameters:
label
- Label to get precision forthreshold
- Threshold to get precision for- Returns:
- Precision for specified label and score
-
getPositivePercent
public double getPositivePercent(Label label, double threshold)
Gets the estimated percentage of training events that exceed the threshold.- Parameters:
label
- Label to get precision forthreshold
- Threshold to get precision for- Returns:
- Estimated percentage of events exceeding threshold
-
getRecall
public double getRecall(Label label, double threshold)
Gets the recall rate for a specified label and threshold. If data was not collected for the exact threshold specified, then results will for the highest threshold <= the specified threshold will be returned.- Parameters:
label
- Label to get recall forthreshold
- Threshold to get recall for- Returns:
- Recall rate for specified label and threshold
-
getThresholds
public double[] getThresholds()
Gets the thresholds being tracked- Returns:
- Array of thresholds
-
setCounts
public void setCounts(Label label, double threshold, int[] newCounts)
Sets the raw counts for a specified label and threshold. If data is not collected for the exact threshold specified, then counts for the highest threshold <= the specified threshold will be set.- Parameters:
label
- Label to get counts forthreshold
- Threshold to get counts fornewCounts
- New count values for the label and threshold- See Also:
TRUE_POSITIVE
,FALSE_POSITIVE
,FALSE_NEGATIVE
,TRUE_NEGATIVE
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-