jsat.classifiers
Class ClassificationDataSet
- java.lang.Object
-
- jsat.DataSet<ClassificationDataSet>
-
- jsat.classifiers.ClassificationDataSet
-
public class ClassificationDataSet extends DataSet<ClassificationDataSet>
ClassificationDataSet is a data set meant specifically for classification problems. The true class of each data point is stored separately from the data point, so that it can be feed into a learning algorithm and not interfere.
Additional functionality specific to classification problems is also available.
-
-
Constructor Summary
Constructors Constructor and Description ClassificationDataSet(DataSet dataSet, int predicting)Creates a new data set for classification problems.ClassificationDataSet(int numerical, CategoricalData[] categories, CategoricalData predicting)Creates a new, empty, data set for classification problems.ClassificationDataSet(java.util.List<DataPoint> data, int predicting)Creates a new data set for classification problems from the given list of data points.ClassificationDataSet(java.util.List<DataPointPair<java.lang.Integer>> data, CategoricalData predicting)Creates a new data set for classification problems from the given list of data points.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddDataPoint(DataPoint dp, int classification)Creates a new data point and add itvoidaddDataPoint(Vec v, int classification)Creates a new data point with no categorical variables and adds it to this data set.voidaddDataPoint(Vec v, int[] classes, int classification)Creates a new data point and adds it to this data set.voidaddDataPoint(Vec v, int[] classes, int classification, double weight)Creates a new data point and add its to this data set.voidaddDataPoint(Vec v, int classification, double weight)Creates a new data point with no categorical variables and adds it to this data set.intclassSampleCount(int targetClass)Returns the number of data points that belong to the specified class, irrespective of the weights of the individual points.static ClassificationDataSetcomineAllBut(java.util.List<ClassificationDataSet> list, int exception)A helper method meant to be used withDataSet.cvSet(int), this combines all classification data sets in a given list, but holding out the indicated list.java.util.List<DataPointPair<java.lang.Integer>>getAsDPPList()Returns the data set as a list ofDataPointPair.java.util.List<DataPointPair<java.lang.Double>>getAsFloatDPPList()Returns the data set as a list ofDataPointPair.intgetClassSize()Returns the number of target classes in this classification data set.DataPointgetDataPoint(int i)Returns the i'th data point from the data setintgetDataPointCategory(int i)Returns the integer value corresponding to the true category of the i'th data point.DataPointPair<java.lang.Integer>getDataPointPair(int i)Returns the i'th data point from the data set, paired with the integer indicating its true classCategoricalDatagetPredicting()double[]getPriors()Computes the prior probabilities of each class, and returns an array containing the values.java.util.List<DataPoint>getSamples(int category)Returns the list of all examples that belong to the given category.intgetSampleSize()Returns the number of data points in this data setVecgetSampleVariableVector(int category, int n)This method is a counter part toDataSet.getNumericColumn(int).ClassificationDataSetgetTwiceShallowClone()Returns a new version of this data set that is of the same type, and contains a different listing pointing to shallow data point copies.voidsetDataPoint(int i, DataPoint dp)Replaces an already existing data point with the one given.ClassificationDataSetshallowClone()Returns a new version of this data set that is of the same type, and contains a different list pointing to the same data points.java.util.List<ClassificationDataSet>stratSet(int folds, java.util.Random rnd)-
Methods inherited from class jsat.DataSet
applyTransform, applyTransform, applyTransform, applyTransform, countMissingValues, cvSet, cvSet, getCategories, getCategoryName, getColumnMeanVariance, getDataMatrix, getDataMatrixView, getDataPointIterator, getDataPoints, getDataVectors, getDataWeights, getMissingDropped, getNumCategoricalVars, getNumericColumn, getNumericColumns, getNumericColumns, getNumericName, getNumFeatures, getNumNumericalVars, getOnlineColumnStats, getOnlineDenseStats, getSparsityStats, randomSplit, randomSplit, replaceNumericFeatures, setNumericName
-
-
-
-
Constructor Detail
-
ClassificationDataSet
public ClassificationDataSet(DataSet dataSet, int predicting)
Creates a new data set for classification problems.- Parameters:
dataSet- the source data setpredicting- the categorical attribute to use as the target class
-
ClassificationDataSet
public ClassificationDataSet(java.util.List<DataPoint> data, int predicting)
Creates a new data set for classification problems from the given list of data points. It is assume the data points are consistent.- Parameters:
data- the list of data points for the problem.predicting- the categorical attribute to use as the target class
-
ClassificationDataSet
public ClassificationDataSet(java.util.List<DataPointPair<java.lang.Integer>> data, CategoricalData predicting)
Creates a new data set for classification problems from the given list of data points. The class value is paired with each data point.- Parameters:
data- the list of data points, paired with their class valuespredicting- the information about the target class
-
ClassificationDataSet
public ClassificationDataSet(int numerical, CategoricalData[] categories, CategoricalData predicting)Creates a new, empty, data set for classification problems.- Parameters:
numerical- the number of numerical attributes for the problemcategories- the information about each categorical variable in the problem.predicting- the information about the target class
-
-
Method Detail
-
getClassSize
public int getClassSize()
Returns the number of target classes in this classification data set. This value can also be obtained by callinggetPredicting().getNumOfCategories()- Returns:
- the number of target classes for prediction
-
comineAllBut
public static ClassificationDataSet comineAllBut(java.util.List<ClassificationDataSet> list, int exception)
A helper method meant to be used withDataSet.cvSet(int), this combines all classification data sets in a given list, but holding out the indicated list.- Parameters:
list- a list of data setsexception- the one data set in the list NOT to combine into one file- Returns:
- a combination of all the data sets in list except the one at index exception
-
getDataPoint
public DataPoint getDataPoint(int i)
Returns the i'th data point from the data set- Specified by:
getDataPointin classDataSet<ClassificationDataSet>- Parameters:
i- the i'th data point in this set- Returns:
- the ith data point in this set
-
getDataPointPair
public DataPointPair<java.lang.Integer> getDataPointPair(int i)
Returns the i'th data point from the data set, paired with the integer indicating its true class- Parameters:
i- the i'th data point in this set- Returns:
- the i'th data point from the data set, paired with the integer indicating its true class
-
setDataPoint
public void setDataPoint(int i, DataPoint dp)Description copied from class:DataSetReplaces an already existing data point with the one given. Any values associated with the data point, but not apart of it, will remain intact.- Specified by:
setDataPointin classDataSet<ClassificationDataSet>- Parameters:
i- the i'th dataPoint to set.dp- the data point to set at the specified index
-
getDataPointCategory
public int getDataPointCategory(int i)
Returns the integer value corresponding to the true category of the i'th data point.- Parameters:
i- the i'th data point.- Returns:
- the integer value for the category of the i'th data point.
- Throws:
java.lang.IndexOutOfBoundsException- if i is not a valid index into the data set.
-
stratSet
public java.util.List<ClassificationDataSet> stratSet(int folds, java.util.Random rnd)
-
addDataPoint
public void addDataPoint(Vec v, int[] classes, int classification)
Creates a new data point and adds it to this data set.- Parameters:
v- the numerical values for the data pointclasses- the categorical values for the data pointclassification- the true class value for the data point- Throws:
java.lang.IllegalArgumentException- if the given values are inconsistent with the data this class stores.
-
addDataPoint
public void addDataPoint(Vec v, int classification)
Creates a new data point with no categorical variables and adds it to this data set.- Parameters:
v- the numerical values for the data pointclassification- the true class value for the data point- Throws:
java.lang.IllegalArgumentException- if the given values are inconsistent with the data this class stores.
-
addDataPoint
public void addDataPoint(Vec v, int classification, double weight)
Creates a new data point with no categorical variables and adds it to this data set.- Parameters:
v- the numerical values for the data pointclassification- the true class value for the data pointweight- the weight value to give to the data point- Throws:
java.lang.IllegalArgumentException- if the given values are inconsistent with the data this class stores.
-
addDataPoint
public void addDataPoint(Vec v, int[] classes, int classification, double weight)
Creates a new data point and add its to this data set.- Parameters:
v- the numerical values for the data pointclasses- the categorical values for the data pointclassification- the true class value for the data pointweight- the weight value to give to the data point- Throws:
java.lang.IllegalArgumentException- if the given values are inconsistent with the data this class stores.
-
addDataPoint
public void addDataPoint(DataPoint dp, int classification)
Creates a new data point and add it- Parameters:
dp- the data point to add to this setclassification- the label for this data point
-
getSamples
public java.util.List<DataPoint> getSamples(int category)
Returns the list of all examples that belong to the given category.- Parameters:
category- the category desired- Returns:
- all given examples that belong to the given category
-
getSampleVariableVector
public Vec getSampleVariableVector(int category, int n)
This method is a counter part toDataSet.getNumericColumn(int). Instead of returning all values for a given attribute, all values for the attribute that are members of a specific class are returned.- Parameters:
category- the category desiredn- the n'th numerical variable- Returns:
- a vector of all the values for the n'th numerical variable for the given category
-
getPredicting
public CategoricalData getPredicting()
- Returns:
- the
CategoricalDataobject for the variable that is to be predicted
-
getAsDPPList
public java.util.List<DataPointPair<java.lang.Integer>> getAsDPPList()
Returns the data set as a list ofDataPointPair. Each data point is paired with it's true class value. Altering the data points will effect the data set. Altering the list will not.
The list of data points will come in the same order they would be retrieved in usinggetDataPoint(int)- Returns:
- a list of each data point paired with its class value
-
getAsFloatDPPList
public java.util.List<DataPointPair<java.lang.Double>> getAsFloatDPPList()
Returns the data set as a list ofDataPointPair. Each data point is paired with it's true class value, which is stored in a double. Altering the data points will effect the data set. Altering the list will not.
The list of data points will come in the same order they would be retrieved in usinggetDataPoint(int)- Returns:
- a list of each data point paired with its class value stored in a double
-
getPriors
public double[] getPriors()
Computes the prior probabilities of each class, and returns an array containing the values.- Returns:
- the array of prior probabilities
-
classSampleCount
public int classSampleCount(int targetClass)
Returns the number of data points that belong to the specified class, irrespective of the weights of the individual points.- Parameters:
targetClass- the target class- Returns:
- how many data points belong to the given class
-
getSampleSize
public int getSampleSize()
Description copied from class:DataSetReturns the number of data points in this data set- Specified by:
getSampleSizein classDataSet<ClassificationDataSet>- Returns:
- the number of data points in this data set
-
shallowClone
public ClassificationDataSet shallowClone()
Description copied from class:DataSetReturns a new version of this data set that is of the same type, and contains a different list pointing to the same data points.- Specified by:
shallowClonein classDataSet<ClassificationDataSet>- Returns:
- a shallow copy of this data set
-
getTwiceShallowClone
public ClassificationDataSet getTwiceShallowClone()
Description copied from class:DataSetReturns a new version of this data set that is of the same type, and contains a different listing pointing to shallow data point copies. Because the data point object contains the weight itself, the weight is not shared - while the vector and array information is. This allows altering the weights of the data points while preserving the original weights.
Altering the list or weights of the returned data set will not be reflected in the original. Altering the feature values will.- Overrides:
getTwiceShallowClonein classDataSet<ClassificationDataSet>- Returns:
- a shallow copy of shallow data point copies for this data set.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG