jsat.classifiers
Class DataPoint
- java.lang.Object
-
- jsat.classifiers.DataPoint
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class DataPoint extends java.lang.Object implements java.lang.Cloneable, java.io.SerializableThis is the general class object for representing a singular data point in a data set. Every data point is made up of either categorical variables, numerical variables, or a combination of the two.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DataPoint(Vec numericalValues)Creates a new data point that has no categorical variables and a weight of 1.0DataPoint(Vec numericalValues, double weight)Creates a new data point that has no categorical variablesDataPoint(Vec numericalValues, int[] categoricalValues, CategoricalData[] categoricalData)Creates a new data point with the default weight of 1.0DataPoint(Vec numericalValues, int[] categoricalValues, CategoricalData[] categoricalData, double weight)Creates a new data point
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description DataPointclone()Creates a deep clone of this data point, such that altering either data point does not effect the other one.booleancontainsCategoricalData()Returns true if this data point contains any categorical variables, false otherwise.booleancontainsNumericalData()Returns true if the data point contains any numerical variables, false otherwise.CategoricalData[]getCategoricalData()Returns the array of Categorical Data informationintgetCategoricalValue(int i)int[]getCategoricalValues()Returns the array of values for each category.VecgetNumericalValues()Returns the vector containing the numerical values.doublegetWeight()Returns the weight that this data point carries.intnumCategoricalValues()Returns the number of categorical variables in this data point.intnumNumericalValues()Returns the number of numerical variables in this data point.voidsetWeight(double weight)Set the weight that this data point should carry.java.lang.StringtoString()
-
-
-
Constructor Detail
-
DataPoint
public DataPoint(Vec numericalValues, int[] categoricalValues, CategoricalData[] categoricalData)
Creates a new data point with the default weight of 1.0- Parameters:
numericalValues- a vector containing the numerical values for this data pointcategoricalValues- an array of the category values for this data pointcategoricalData- an array of the category information of this data point
-
DataPoint
public DataPoint(Vec numericalValues, int[] categoricalValues, CategoricalData[] categoricalData, double weight)
Creates a new data point- Parameters:
numericalValues- a vector containing the numerical values for this data pointcategoricalValues- an array of the category values for this data pointcategoricalData- an array of the category information of this data pointweight- a double indicating how much weight this data point has, 1.0 being the standard weight. Not all algorithms make use of data points that have different weights.
-
DataPoint
public DataPoint(Vec numericalValues, double weight)
Creates a new data point that has no categorical variables- Parameters:
numericalValues- a vector containing the numerical values for this data pointweight- a double indicating how much weight this data point has, 1.0 being the standard weight. Not all algorithms make use of data points that have different weights.
-
DataPoint
public DataPoint(Vec numericalValues)
Creates a new data point that has no categorical variables and a weight of 1.0- Parameters:
numericalValues- a vector containing the numerical values for this data point
-
-
Method Detail
-
getWeight
public double getWeight()
Returns the weight that this data point carries.- Returns:
- the weight that this data point carries.
-
setWeight
public void setWeight(double weight)
Set the weight that this data point should carry. The norm is 1.0- Parameters:
weight- the new weight value- Throws:
java.lang.ArithmeticException- if the weight value is not a number > 0
-
containsCategoricalData
public boolean containsCategoricalData()
Returns true if this data point contains any categorical variables, false otherwise.- Returns:
- true if this data point contains any categorical variables, false otherwise.
-
getNumericalValues
public Vec getNumericalValues()
Returns the vector containing the numerical values. Altering this vector will effect this data point. If changes are going to be made, a clone of the vector should be made by the caller.- Returns:
- the vector containing the numerical values.
-
containsNumericalData
public boolean containsNumericalData()
Returns true if the data point contains any numerical variables, false otherwise.- Returns:
- true if the data point contains any numerical variables, false otherwise.
-
numNumericalValues
public int numNumericalValues()
Returns the number of numerical variables in this data point.- Returns:
- the number of numerical variables in this data point.
-
getCategoricalValues
public int[] getCategoricalValues()
Returns the array of values for each category. Altering this array will effect this data point. If changes are going to be made, a clone of the array should be made by the caller.- Returns:
- the array of values for each category.
-
numCategoricalValues
public int numCategoricalValues()
Returns the number of categorical variables in this data point.- Returns:
- the number of categorical variables in this data point.
-
getCategoricalValue
public int getCategoricalValue(int i)
- Parameters:
i- the i'th categorical variable- Returns:
- the value of the i'th categorical variable
-
getCategoricalData
public CategoricalData[] getCategoricalData()
Returns the array of Categorical Data information- Returns:
- the array of Categorical Data information
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clone
public DataPoint clone()
Creates a deep clone of this data point, such that altering either data point does not effect the other one.- Overrides:
clonein classjava.lang.Object- Returns:
- a deep clone of this data point.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG