jsat.classifiers
Class CategoricalResults
- java.lang.Object
-
- jsat.classifiers.CategoricalResults
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class CategoricalResults extends java.lang.Object implements java.lang.Cloneable, java.io.SerializableThis class represents the probabilities for each possible result classification.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description CategoricalResults(double[] probabilities)Creates a new Categorical Result using the given array.CategoricalResults(int numCategories)Create a new Categorical Results, values will default to all zero.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description CategoricalResultsclone()Creates a deep clone of thisvoiddivideConst(double c)Divides all the probabilities by a constant value in order to scale themdoublegetProb(int cat)Returns the stored probability for the given categoryVecgetVecView()voidincProb(int cat, double prob)Increments the stored probability that a sample belongs to a given categoryintmostLikely()Returns the category that is the most likely according to the current probability valuesvoidnormalize()Adjusts the probabilities by dividing each value by the total sum, so that all values are in the range [0, 1]voidsetProb(int cat, double prob)Sets the probability that a sample belongs to a given category.intsize()Returns the number of classes that are in the result.java.lang.StringtoString()
-
-
-
Constructor Detail
-
CategoricalResults
public CategoricalResults(int numCategories)
Create a new Categorical Results, values will default to all zero.- Parameters:
numCategories- the number of options to support.
-
CategoricalResults
public CategoricalResults(double[] probabilities)
Creates a new Categorical Result using the given array. It will use only a reference to the given array, and will assume the values are already normalized and sum to one.- Parameters:
probabilities- the array of probabilities for each outcome
-
-
Method Detail
-
size
public int size()
Returns the number of classes that are in the result.- Returns:
- the class count
-
setProb
public void setProb(int cat, double prob)Sets the probability that a sample belongs to a given category.- Parameters:
cat- the categoryprob- the value to set, may be greater then one.- Throws:
java.lang.IndexOutOfBoundsException- if a non existent category is specifiedjava.lang.ArithmeticException- if the value set is negative or not a number
-
incProb
public void incProb(int cat, double prob)Increments the stored probability that a sample belongs to a given category- Parameters:
cat- the categoryprob- the value to increment by, may be greater then one.- Throws:
java.lang.IndexOutOfBoundsException- if a non existent category is specifiedjava.lang.ArithmeticException- if the value set is negative or not a number
-
mostLikely
public int mostLikely()
Returns the category that is the most likely according to the current probability values- Returns:
- the the most likely category
-
divideConst
public void divideConst(double c)
Divides all the probabilities by a constant value in order to scale them- Parameters:
c- the constant to divide all probabilities by
-
normalize
public void normalize()
Adjusts the probabilities by dividing each value by the total sum, so that all values are in the range [0, 1]
-
getVecView
public Vec getVecView()
-
getProb
public double getProb(int cat)
Returns the stored probability for the given category- Parameters:
cat- the category- Returns:
- the associated probability
-
clone
public CategoricalResults clone()
Creates a deep clone of this- Overrides:
clonein classjava.lang.Object- Returns:
- a deep clone
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG