|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.tuwien.ifs.somtoolbox.data.SOMLibClassInformation
public class SOMLibClassInformation
This class provides information about class labels for the InputData
input vectors.
The file format consists of a header
and the content as follows:
InputData.numVectors()
). See also an example file from the Iris data set.
Alternatively, the file format can be more simple, and not contain any file header. Then, there is only a list of
lines with two tabulator-seperated Strings
in the form of labelName className
.
The number of classes, and the indices of those classes, are computer automatically.
Finally, the simplest form of the file is to have lines with just the class label; then, this class is assigned to
the input datum with the index of the line number.
The number of classes, and the indices of those classes, are computer automatically.
Field Summary | |
---|---|
protected String |
classInformationFileName
The file name to read from. |
private int[] |
classMemberCount
The number of inputs in each class. |
private String[] |
classNames
The names of the classes. |
private ArrayList<String> |
classNamesTemp
|
private int[] |
dataClasses
A mapping input index => class index, for fast lookup. |
private HashMap<String,Comparable> |
dataHash
Mapping class name => class index, for fast lookup. |
private String[] |
dataNames
|
private ArrayList<String> |
dataNamesTemp
|
private static Logger |
logger
|
private int |
numClasses
The number of classes. |
protected int |
numData
The number of input vectors. |
private org.jfree.util.PaintList |
paintList
|
Constructor Summary | |
---|---|
SOMLibClassInformation()
Constructor intended to be used e.g. |
|
SOMLibClassInformation(Map<String,String> classAssignment)
|
|
SOMLibClassInformation(String classInformationFileName)
Creates a new class information object by trying to read the given file in both the versions with a file header ( readSOMLibClassInformationFile() ) and the tab-separated file (readTabSepClassInformationFile()
). |
|
SOMLibClassInformation(String[] classNames,
String[][] dataName)
Constructor intended to be used when generating data. |
Method Summary | |
---|---|
void |
addItem(String label,
String classname)
|
String[] |
classNames()
Returns all the distinct class names. |
int[] |
computeClassDistribution(String[] labelNames)
computes the percentages of class membership for the given label names |
Color |
getClassColor(int index)
Get the colour for the given class index. |
Color[] |
getClassColors()
Get all class colours. |
int |
getClassIndex(String className)
Gets the index number for a given class label. |
int |
getClassIndexForInput(String vectorName)
|
String |
getClassName(int index)
Gets the class label name for a given input vector index. |
String |
getClassName(String vectorName)
Gets the class name for a vector name. |
String[] |
getClassNames()
Returns the names of the classes. |
String[] |
getDataNames()
|
String[] |
getDataNamesInClass(String className)
|
String[][] |
getDataNamesPerClass()
Returns an array of data names for each class. |
int |
getNumberOfClassMembers(int classIndex)
Gets the number of input vectors in the given class. |
org.jfree.util.PaintList |
getPaintList()
Get the class colours as PaintList . |
double |
getPercentageOfClassMembers(int classIndex)
|
boolean |
hasClassAssignmentForName(String vectorName)
|
private void |
initPaintList()
Initialise a standard paint list |
boolean |
loadClassColours(File file)
Load colours from an external (non-classinfo) file. |
static void |
main(String[] args)
Method for stand-alone execution to convert a file to the SOMLibClassInformation format. |
int |
numClasses()
Gets the number of classes, as read from $NUM_CLASSES, or computed. |
void |
processItems(boolean sort)
|
private void |
readSimple()
|
protected void |
readSOMLibClassInformationFile()
Reads a class information file containing a header and class indices. |
private void |
readTabSepClassInformationFile()
Reads a class information file containing no header, and tab-separated String entries for the input vector and class labels. |
void |
removeNotPresentElements(SOMLibSparseInputData inputData)
|
void |
setClassColor(int index,
Color color)
Get the colour for the given class index. |
private void |
throwClassInfoReadingError(String classInformationFileName,
IOException e)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger logger
protected String classInformationFileName
private int numClasses
private String[] classNames
private int[] classMemberCount
protected int numData
private String[] dataNames
private int[] dataClasses
private HashMap<String,Comparable> dataHash
private ArrayList<String> classNamesTemp
private ArrayList<String> dataNamesTemp
private org.jfree.util.PaintList paintList
Constructor Detail |
---|
public SOMLibClassInformation()
SOMPAKInputData
public SOMLibClassInformation(Map<String,String> classAssignment)
public SOMLibClassInformation(String[] classNames, String[][] dataName)
public SOMLibClassInformation(String classInformationFileName) throws SOMToolboxException
readSOMLibClassInformationFile()
) and the tab-separated file (readTabSepClassInformationFile()
).
classInformationFileName
- The file to read from
SOMToolboxException
- if there is any error in the file formatMethod Detail |
---|
public String[] getClassNames()
public String[][] getDataNamesPerClass()
public String[] getDataNames()
private void throwClassInfoReadingError(String classInformationFileName, IOException e) throws SOMLibFileFormatException
SOMLibFileFormatException
private void readTabSepClassInformationFile() throws SOMToolboxException, IOException
SOMToolboxException
- if there is any error in the file format
IOException
private void readSimple() throws SOMToolboxException, IOException
SOMToolboxException
IOException
public void processItems(boolean sort)
public void addItem(String label, String classname)
protected void readSOMLibClassInformationFile() throws IOException, SOMToolboxException
IOException
SOMToolboxException
public int numClasses()
public String[] classNames()
public int getClassIndex(String className)
className
- the class label.
public String getClassName(int index)
index
- index of the input vector.
public String getClassName(String vectorName) throws SOMLibFileFormatException
vectorName
- the name of the input vector.
SOMLibFileFormatException
- If there is no class information available for the given vector name/labelpublic boolean hasClassAssignmentForName(String vectorName)
public int getClassIndexForInput(String vectorName) throws SOMLibFileFormatException
SOMLibFileFormatException
public int getNumberOfClassMembers(int classIndex)
classIndex
- the index of the class.
public double getPercentageOfClassMembers(int classIndex)
public String[] getDataNamesInClass(String className)
public int[] computeClassDistribution(String[] labelNames)
private void initPaintList()
public org.jfree.util.PaintList getPaintList()
PaintList
.
public Color[] getClassColors()
public Color getClassColor(int index)
public void setClassColor(int index, Color color)
public boolean loadClassColours(File file)
public void removeNotPresentElements(SOMLibSparseInputData inputData)
public static void main(String[] args) throws SOMToolboxException, IOException
SOMToolboxException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |