jsat.classifiers.trees
Class ImpurityScore
- java.lang.Object
-
- jsat.classifiers.trees.ImpurityScore
-
- All Implemented Interfaces:
- java.lang.Cloneable
public class ImpurityScore extends java.lang.Object implements java.lang.CloneableImpurityScore provides a measure of the impurity of a set of data points respective to their class labels. The impurity score is maximized when the classes are evenly distributed, and minimized when all points belong to one class.
The gain in purity can be computed using the static gain methods of the class. However, not all impurity measures can be used for arbitrary data and splits. Some may only support binary splits, and some may only support binary target classes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classImpurityScore.ImpurityMeasureDifferent methods of measuring the impurity in a set of data points based on nominal class labels
-
Constructor Summary
Constructors Constructor and Description ImpurityScore(int classCount, ImpurityScore.ImpurityMeasure impurityMeasure)Creates a new impurity score that can be updated
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddPoint(DataPoint dp, int targetClass)Adds one more point to the impurity scorevoidaddPoint(double weight, int targetClass)Adds one more point to the impurity scorestatic doublegain(ImpurityScore wholeData, double wholeScale, ImpurityScore... splits)Computes the gain in score from a splitting of the data setstatic doublegain(ImpurityScore wholeData, ImpurityScore... splits)Computes the gain in score from a splitting of the data setImpurityScore.ImpurityMeasuregetImpurityMeasure()Returns the impurity measure being usedCategoricalResultsgetResults()Obtains the current categorical results by prior probabilitydoublegetScore()Computes the current impurity score for the points that have been added.doublegetSumOfWeights()Returns the sum of the weights for all points currently in the impurity scorevoidremovePoint(DataPoint dp, int targetClass)Removes one point from the impurity scorevoidremovePoint(double weight, int targetClass)Removes one point from the impurity score
-
-
-
Constructor Detail
-
ImpurityScore
public ImpurityScore(int classCount, ImpurityScore.ImpurityMeasure impurityMeasure)Creates a new impurity score that can be updated- Parameters:
classCount- the number of target class valuesimpurityMeasure-
-
-
Method Detail
-
removePoint
public void removePoint(DataPoint dp, int targetClass)
Removes one point from the impurity score- Parameters:
dp- the data point to addtargetClass- the class of the point to add
-
removePoint
public void removePoint(double weight, int targetClass)Removes one point from the impurity score- Parameters:
weight- the weight of the point to addtargetClass- the class of the point to add
-
addPoint
public void addPoint(DataPoint dp, int targetClass)
Adds one more point to the impurity score- Parameters:
dp- the data point to addtargetClass- the class of the point to add
-
addPoint
public void addPoint(double weight, int targetClass)Adds one more point to the impurity score- Parameters:
weight- the weight of the point to addtargetClass- the class of the point to add
-
getScore
public double getScore()
Computes the current impurity score for the points that have been added. A higher score is worse, a score of zero indicates a perfectly pure set of points (all one class).- Returns:
- the impurity score
-
getSumOfWeights
public double getSumOfWeights()
Returns the sum of the weights for all points currently in the impurity score- Returns:
- the sum of weights
-
getImpurityMeasure
public ImpurityScore.ImpurityMeasure getImpurityMeasure()
Returns the impurity measure being used- Returns:
- the impurity measure being used
-
getResults
public CategoricalResults getResults()
Obtains the current categorical results by prior probability- Returns:
- the categorical results for the current score
-
gain
public static double gain(ImpurityScore wholeData, ImpurityScore... splits)
Computes the gain in score from a splitting of the data set- Parameters:
wholeData- the score for the whole data setsplits- the scores for each of the splits- Returns:
- the gain for the values given
-
gain
public static double gain(ImpurityScore wholeData, double wholeScale, ImpurityScore... splits)
Computes the gain in score from a splitting of the data set- Parameters:
wholeData- the score for the whole data setwholeScale- a constant to scale the wholeData counts and sums by, useful for handling missing value casessplits- the scores for each of the splits- Returns:
- the gain for the values given
-
-
DataMelt 3.0 © DataMelt by jWork.ORG