Class ClassesToClusters
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.gui.tools.wekainvestigator.evaluation.AbstractEvaluation<ClusterTab,ResultItem>
-
- adams.gui.tools.wekainvestigator.tab.clustertab.evaluation.AbstractClustererEvaluation
-
- adams.gui.tools.wekainvestigator.tab.clustertab.evaluation.ClassesToClusters
-
- All Implemented Interfaces:
GlobalInfoSupporter,LoggingSupporter,SizeOfHandler,StatusMessageHandler,Serializable
public class ClassesToClusters extends AbstractClustererEvaluation
Tries to map the clusters of the built clusterer to the class labels in the dataset.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected BaseComboBox<String>m_ComboBoxClassthe class attribute.protected BaseComboBox<String>m_ComboBoxTestthe test set.protected BaseComboBox<String>m_ComboBoxTrainthe train set.protected DefaultComboBoxModel<String>m_ModelClassthe class attribute model.protected DefaultComboBoxModel<String>m_ModelDatasetsthe datasets model.protected ParameterPanelm_PanelParametersthe panel with the parameters.-
Fields inherited from class adams.gui.tools.wekainvestigator.evaluation.AbstractEvaluation
m_Owner, m_PanelOptions
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description ClassesToClusters()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate(int index)Activates the specified dataset.StringcanEvaluate(weka.clusterers.Clusterer clusterer)Tests whether the clusterer can be evaluated.protected intclassIndex(weka.core.Instances data)Returns the index of the selected class attribute in the provided dataset.voiddeserialize(Map<String,Object> data, MessageCollection errors)Restores the objects.protected voiddoEvaluate(weka.clusterers.Clusterer clusterer, ResultItem item)Evaluates the clusterer and updates the result item.StringgetName()Returns the name of the evaluation (displayed in combobox).StringglobalInfo()Returns a string describing the object.ResultIteminit(weka.clusterers.Clusterer clusterer)Initializes the result item.protected voidinitGUI()Initializes the widgets.protected intnumClasses()Returns the number of classes in the test set.protected weka.core.InstancesremoveClassAttribute(weka.core.Instances data)Removes the class attribute from the dataset (if present).Map<String,Object>serialize(Set<AbstractInvestigatorTab.SerializationOption> options)Returns the objects for serialization.protected StringtoMatrixString(int numClusters, int[][] counts, int[] clusterTotals, weka.core.Instances inst)Returns a "confusion" style matrix of classes to clusters assignmentsvoidupdate()Updates the settings panel.-
Methods inherited from class adams.gui.tools.wekainvestigator.tab.clustertab.evaluation.AbstractClustererEvaluation
evaluate, getEvaluations
-
Methods inherited from class adams.gui.tools.wekainvestigator.evaluation.AbstractEvaluation
addObjectSize, addToHistory, getOwner, getPanel, getProperties, getTestingUpdateInterval, initialize, isValidDataIndex, listOrArray, setOwner, showStatus, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_PanelParameters
protected ParameterPanel m_PanelParameters
the panel with the parameters.
-
m_ComboBoxTrain
protected BaseComboBox<String> m_ComboBoxTrain
the train set.
-
m_ComboBoxTest
protected BaseComboBox<String> m_ComboBoxTest
the test set.
-
m_ModelDatasets
protected DefaultComboBoxModel<String> m_ModelDatasets
the datasets model.
-
m_ComboBoxClass
protected BaseComboBox<String> m_ComboBoxClass
the class attribute.
-
m_ModelClass
protected DefaultComboBoxModel<String> m_ModelClass
the class attribute model.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Returns:
- a description suitable for displaying in the gui
-
initGUI
protected void initGUI()
Initializes the widgets.- Overrides:
initGUIin classAbstractEvaluation<ClusterTab,ResultItem>
-
getName
public String getName()
Returns the name of the evaluation (displayed in combobox).- Specified by:
getNamein classAbstractEvaluation<ClusterTab,ResultItem>- Returns:
- the name
-
canEvaluate
public String canEvaluate(weka.clusterers.Clusterer clusterer)
Tests whether the clusterer can be evaluated.- Specified by:
canEvaluatein classAbstractClustererEvaluation- Parameters:
clusterer- the current clusterer- Returns:
- null if successful, otherwise error message
-
init
public ResultItem init(weka.clusterers.Clusterer clusterer) throws Exception
Initializes the result item.- Specified by:
initin classAbstractClustererEvaluation- Parameters:
clusterer- the current clusterer- Returns:
- the initialized history item
- Throws:
Exception- if initialization fails
-
numClasses
protected int numClasses()
Returns the number of classes in the test set.- Returns:
- the number of classes, -1 in case of error
-
classIndex
protected int classIndex(weka.core.Instances data)
Returns the index of the selected class attribute in the provided dataset.- Parameters:
data- the dataset to get the class index for- Returns:
- the class index, -1 if failed to locate attribute
-
removeClassAttribute
protected weka.core.Instances removeClassAttribute(weka.core.Instances data)
Removes the class attribute from the dataset (if present).- Parameters:
data- the dataset to process- Returns:
- the clean dataset
-
toMatrixString
protected String toMatrixString(int numClusters, int[][] counts, int[] clusterTotals, weka.core.Instances inst) throws Exception
Returns a "confusion" style matrix of classes to clusters assignments- Parameters:
counts- the counts of classes for each clusterclusterTotals- total number of examples in each clusterinst- the training instances (with class)- Returns:
- the "confusion" style matrix as string
- Throws:
Exception- if matrix can't be generated
-
doEvaluate
protected void doEvaluate(weka.clusterers.Clusterer clusterer, ResultItem item) throws ExceptionEvaluates the clusterer and updates the result item.- Specified by:
doEvaluatein classAbstractClustererEvaluation- Parameters:
clusterer- the current clustereritem- the item to update- Throws:
Exception- if evaluation fails
-
update
public void update()
Updates the settings panel.- Specified by:
updatein classAbstractEvaluation<ClusterTab,ResultItem>
-
activate
public void activate(int index)
Activates the specified dataset.- Specified by:
activatein classAbstractEvaluation<ClusterTab,ResultItem>- Parameters:
index- the index of the dataset
-
serialize
public Map<String,Object> serialize(Set<AbstractInvestigatorTab.SerializationOption> options)
Returns the objects for serialization.- Overrides:
serializein classAbstractEvaluation<ClusterTab,ResultItem>- Parameters:
options- what to serialize- Returns:
- the mapping of the objects to serialize
-
deserialize
public void deserialize(Map<String,Object> data, MessageCollection errors)
Restores the objects.- Overrides:
deserializein classAbstractEvaluation<ClusterTab,ResultItem>- Parameters:
data- the data to restoreerrors- for storing errors
-
-