Catalano.MachineLearning.Dataset
Class DatasetClassification
- java.lang.Object
-
- Catalano.MachineLearning.Dataset.DatasetClassification
-
- All Implemented Interfaces:
- IDataset<double[][],int[]>, java.io.Serializable
public class DatasetClassification extends java.lang.Object implements IDataset<double[][],int[]>
Dataset for classification.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DatasetClassification(java.lang.String filepath)Initializes a new instance of the DatasetClassification class.DatasetClassification(java.lang.String name, double[][] input, int[] output)Initializes a new instance of the DatasetClassification class.DatasetClassification(java.lang.String name, double[][] input, int[] output, DecisionVariable[] attributes)Initializes a new instance of the DatasetClassification class.DatasetClassification(java.lang.String name, double[][] input, int[] output, DecisionVariable[] attributes, int classIndex)Initializes a new instance of the DatasetClassification class.DatasetClassification(java.lang.String filepath, java.lang.String name)Initializes a new instance of the DatasetClassification class.DatasetClassification(java.lang.String filepath, java.lang.String name, boolean ignoreAttributeInfo)Initializes a new instance of the DatasetClassification class.DatasetClassification(java.lang.String filepath, java.lang.String name, boolean ignoreAttributeInfo, int classIndex)Initializes a new instance of the DatasetClassification class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static DatasetClassificationFromCSV(java.lang.String filepath, java.lang.String name)Read dataset from a CSV structure.static DatasetClassificationFromCSV(java.lang.String filepath, java.lang.String name, boolean ignoreAttributeInfo)Read dataset from a CSV structure.static DatasetClassificationFromCSV(java.lang.String filepath, java.lang.String name, boolean ignoreAttributeInfo, int classIndex)Construct a dataset from an CSV file.intgetClassIndex()Get the class index.CodebookgetCodebook()Get Codebook.DecisionVariable[]getDecisionVariables()Get the decision variables.IFeatureScalinggetFeatureScaling()Get normalization.double[][]getInput()Get the input data.double[][]getInput(int label)Get all the instances with the related label.java.lang.StringgetName()Get the name of the dataset.intgetNumberOfAttributes()Get the number of all the attributes.intgetNumberOfClasses()Get the number of classes.intgetNumberOfContinuous()Get the number of type continuous.intgetNumberOfDiscrete()Get the number of type discrete.intgetNumberOfInstances()Get the number of instances.int[]getOutput()Get the output data.StatisticsDataset[]getStatistics()Get the statistics from the dataset.voidImputation(IImputation filter)Perform imputation algorithms.voidKeepAttributes(int[] indexes)Keep the selected attributes and remove the rest.voidNormalize()Normalize all continuous data.voidNormalize(double min, double max)Normalize all continuous data.voidNormalize(IFeatureScaling normalization)Normalize all continuous data.voidRemoveAttribute(int index)Remove an attribute.voidRemoveAttribute(int[] indexes)Remove attributes.voidRemoveClass(int id)Remove all instances within related class.voidRemoveMissingInstances()Remove all the instances where is missing values.voidsetClassIndex(int classIndex)Set the class index.voidsetInput(double[][] input, DecisionVariable[] variables)Set the input data.voidShuffle()Shuffle the dataset.voidShuffle(long seed)Shuffle the dataset.voidSort()Sort the dataset in relation of the labels.DatasetClassificationSplit(float percentage)Split the percentange of the dataset in Trainning and the rest in Validation.DatasetClassificationSplit(float percentage, java.lang.String name)Split the percentange of the dataset in Trainning and the rest in Validation.voidStandartize()Standartize all continuous data.voidWriteAsARFF(java.lang.String filename)Write dataset as ARFF file.voidWriteAsARFF(java.lang.String filename, int decimalPlaces)Write dataset as ARFF file.voidWriteAsCSV(java.lang.String filename)Write the dataset as CSV file.voidWriteAsCSV(java.lang.String filename, int decimalPlaces)Write the dataset as CSV file.voidWriteAsCSV(java.lang.String filename, int decimalPlaces, char delimiter)Write the dataset as CSV file.voidWriteAsCSV(java.lang.String filename, int decimalPlaces, char delimiter, java.lang.String newLine)voidWriteAsCSV(java.lang.String filename, int decimalPlaces, char delimiter, java.lang.String newLine, boolean writeHeader)Write the dataset as CSV file.
-
-
-
Constructor Detail
-
DatasetClassification
public DatasetClassification(java.lang.String filepath)
Initializes a new instance of the DatasetClassification class.- Parameters:
filepath- File path.
-
DatasetClassification
public DatasetClassification(java.lang.String filepath, java.lang.String name)Initializes a new instance of the DatasetClassification class.- Parameters:
filepath- File path.name- Name of the dataset.
-
DatasetClassification
public DatasetClassification(java.lang.String filepath, java.lang.String name, boolean ignoreAttributeInfo)Initializes a new instance of the DatasetClassification class.- Parameters:
filepath- File path.name- Name of the dataset.ignoreAttributeInfo- Ignore first line (Attribute information).
-
DatasetClassification
public DatasetClassification(java.lang.String filepath, java.lang.String name, boolean ignoreAttributeInfo, int classIndex)Initializes a new instance of the DatasetClassification class.- Parameters:
filepath- File path.name- Name of the dataset.classIndex- Class index.ignoreAttributeInfo- Ignore first line (Attribute information).
-
DatasetClassification
public DatasetClassification(java.lang.String name, double[][] input, int[] output)Initializes a new instance of the DatasetClassification class.- Parameters:
name- Name of the dataset.input- Input data.output- Output data.
-
DatasetClassification
public DatasetClassification(java.lang.String name, double[][] input, int[] output, DecisionVariable[] attributes)Initializes a new instance of the DatasetClassification class.- Parameters:
name- Name of the dataset.attributes- Decision variables.input- Input data.output- Output data.
-
DatasetClassification
public DatasetClassification(java.lang.String name, double[][] input, int[] output, DecisionVariable[] attributes, int classIndex)Initializes a new instance of the DatasetClassification class.- Parameters:
name- Name of the dataset.attributes- Decision variables.input- Input data.output- Output data.classIndex- Class index.
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the name of the dataset.- Returns:
- Name.
-
getInput
public double[][] getInput()
Get the input data.
-
setInput
public void setInput(double[][] input, DecisionVariable[] variables)Description copied from interface:IDatasetSet the input data.
-
getOutput
public int[] getOutput()
Get the output data.
-
getClassIndex
public int getClassIndex()
Get the class index.- Returns:
- Class index.
-
setClassIndex
public void setClassIndex(int classIndex)
Set the class index.- Parameters:
classIndex- Class index.
-
getDecisionVariables
public DecisionVariable[] getDecisionVariables()
Get the decision variables.- Specified by:
getDecisionVariablesin interfaceIDataset<double[][],int[]>- Returns:
- Decision Variables.
-
getNumberOfInstances
public int getNumberOfInstances()
Get the number of instances.- Returns:
- Number of instances.
-
getNumberOfAttributes
public int getNumberOfAttributes()
Get the number of all the attributes. Number of feature + class.- Returns:
- Number of attributes.
-
getNumberOfClasses
public int getNumberOfClasses()
Get the number of classes.- Returns:
- Number of classes.
-
getNumberOfContinuous
public int getNumberOfContinuous()
Get the number of type continuous.- Returns:
- Number of type continuous.
-
getNumberOfDiscrete
public int getNumberOfDiscrete()
Get the number of type discrete.- Returns:
- Number of type discrete.
-
getFeatureScaling
public IFeatureScaling getFeatureScaling()
Get normalization.- Returns:
- Normalization.
-
getCodebook
public Codebook getCodebook()
Get Codebook.- Returns:
- Codebook.
-
FromCSV
public static DatasetClassification FromCSV(java.lang.String filepath, java.lang.String name)
Read dataset from a CSV structure. The last column of CSV is interpreted as output.- Parameters:
filepath- File path.name- Name of the dataset.- Returns:
- Classification Dataset.
-
FromCSV
public static DatasetClassification FromCSV(java.lang.String filepath, java.lang.String name, boolean ignoreAttributeInfo)
Read dataset from a CSV structure. The last column of CSV is interpreted as output.- Parameters:
filepath- File path.name- Name of the dataset.ignoreAttributeInfo- Ignore attribute information.- Returns:
- Classification dataset.
-
FromCSV
public static DatasetClassification FromCSV(java.lang.String filepath, java.lang.String name, boolean ignoreAttributeInfo, int classIndex)
Construct a dataset from an CSV file.- Parameters:
filepath- File.name- Name of the dataset.classIndex- Index of the attribute for to be setup as output.ignoreAttributeInfo- Ignore attribute information.- Returns:
- Classification Dataset.
-
getInput
public double[][] getInput(int label)
Get all the instances with the related label.- Parameters:
label- Label.- Returns:
- Data.
-
Imputation
public void Imputation(IImputation filter)
Perform imputation algorithms.- Parameters:
filter- Filter.
-
Normalize
public void Normalize()
Normalize all continuous data. Default: (0..1).
-
Normalize
public void Normalize(double min, double max)Normalize all continuous data.- Parameters:
min- Minimum value.max- Maximum value.
-
Normalize
public void Normalize(IFeatureScaling normalization)
Normalize all continuous data.- Parameters:
normalization- Normalization.
-
RemoveAttribute
public void RemoveAttribute(int index)
Remove an attribute.- Parameters:
index- Index of the attribute.
-
RemoveAttribute
public void RemoveAttribute(int[] indexes)
Remove attributes.- Parameters:
indexes- Indexes of the attributes.
-
KeepAttributes
public void KeepAttributes(int[] indexes)
Keep the selected attributes and remove the rest.- Parameters:
indexes- Indexes of the attributes.
-
RemoveClass
public void RemoveClass(int id)
Remove all instances within related class. The labels will be reindexed.- Parameters:
id- Class.
-
RemoveMissingInstances
public void RemoveMissingInstances()
Remove all the instances where is missing values.
-
Split
public DatasetClassification Split(float percentage)
Split the percentange of the dataset in Trainning and the rest in Validation.- Parameters:
percentage- Percentage.- Returns:
- Validation dataset.
-
Split
public DatasetClassification Split(float percentage, java.lang.String name)
Split the percentange of the dataset in Trainning and the rest in Validation.- Parameters:
percentage- Percentage.name- Name of the validation dataset.- Returns:
- Validation dataset.
-
Shuffle
public void Shuffle()
Shuffle the dataset.
-
Shuffle
public void Shuffle(long seed)
Shuffle the dataset.- Parameters:
seed- Random seed.
-
Sort
public void Sort()
Sort the dataset in relation of the labels.
-
Standartize
public void Standartize()
Standartize all continuous data. x = (x - u) / s
-
getStatistics
public StatisticsDataset[] getStatistics()
Description copied from interface:IDatasetGet the statistics from the dataset.- Specified by:
getStatisticsin interfaceIDataset<double[][],int[]>- Returns:
- Statistics.
-
WriteAsCSV
public void WriteAsCSV(java.lang.String filename)
Write the dataset as CSV file.- Parameters:
filename- Filename.
-
WriteAsCSV
public void WriteAsCSV(java.lang.String filename, int decimalPlaces)Write the dataset as CSV file.- Parameters:
filename- Filename.decimalPlaces- Decimal places for continous data.
-
WriteAsCSV
public void WriteAsCSV(java.lang.String filename, int decimalPlaces, char delimiter)Write the dataset as CSV file.- Parameters:
filename- Filename.decimalPlaces- Decimal places for continous data.delimiter- Delimiter.
-
WriteAsCSV
public void WriteAsCSV(java.lang.String filename, int decimalPlaces, char delimiter, java.lang.String newLine)
-
WriteAsCSV
public void WriteAsCSV(java.lang.String filename, int decimalPlaces, char delimiter, java.lang.String newLine, boolean writeHeader)Write the dataset as CSV file.- Parameters:
filename- Filename.decimalPlaces- Decimal places.delimiter- Delimiter.newLine- Newline char.writeHeader- Save the file with no header information.
-
WriteAsARFF
public void WriteAsARFF(java.lang.String filename)
Write dataset as ARFF file.- Parameters:
filename- Filename.
-
WriteAsARFF
public void WriteAsARFF(java.lang.String filename, int decimalPlaces)Write dataset as ARFF file.- Parameters:
filename- Filename.decimalPlaces- Decimal places.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG