tpp
Class TPPModel

java.lang.Object
  extended by tpp.TPPModel
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
ScatterPlotModel

public class TPPModel
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A class that represents the TPP model: ie the original data, the current target and view, and the associated methods for manipulating these. This abstract base class does everything except initialise the projection.

See Also:
Serialized Form

Field Summary
static java.lang.String CLASS_UNKNOWN
          The value of the class attribute that indicates that the class of this instance is unknown.
 
Constructor Summary
TPPModel(int n)
          Construct a new TPP model with the given output dimension
 
Method Summary
 void addListener(TPPModelEventListener l)
           
 boolean arePointsSelected()
          Are any points selected?
 TPPModel clone()
           
 Attribute cluster(int numClusters)
          Create a new attribute that clusters the original data.
 Attribute[] createCrossValidation(Attribute at, Classifier cls)
          Perform 10-fold cross validation for the given attribute.
 void createHierarchicalClustering()
           
 void createSeries(Attribute indexAttribute, Attribute idAttribute)
          Create a series in the instances using the given index and id attributes (specified by name).
 Attribute createTestSet(int k)
          Create a test set comprising 1/k'th of the instances.
 Attribute getAttributeByName(java.lang.String name)
           
 java.util.Enumeration<Attribute> getAttributes()
           
 Matrix getCentroids(Attribute classification)
          Get the centroids of the data points for the classes defined by the given attribute
 Matrix getData()
          The normalised numeric data
 java.util.Vector<Attribute> getDateAttributes()
           
 java.lang.String getDescriptionOfAttributes(int[] as)
           
 java.lang.String getDescriptionOfInstance(int[] is)
           
 Graph getGraph()
           
 HierarchicalCluster getHierarchicalCluster()
           
 Instances getInstances()
          Get the underlying instances
 java.util.Vector<Attribute> getNominalAttributes()
           
 Matrix getNormalisedDistances()
           
 int getNumDataDimensions()
          The number of dimensions in the numeric data
 int getNumDataPoints()
          The number of points
 java.util.Vector<Attribute> getNumericAttributes()
           
 int getNumViewDimensions()
          Get the number of output dimensions
 java.lang.String[] getPointDescriptions()
          Create an array of descriptions of each point, based on any string attributes
 boolean[] getPointsInTrainingSet()
          Return a boolean array indicating whether each instance is a member of the training (true) or test (false) set.
 Matrix getProjection()
          The current projection
 ProjectionConstraint getProjectionConstraint()
          Return the constraint that any projection must meet.
 Attribute getSeparationAttribute()
           
 Series getSeries()
          Get the series defined within the data
 java.util.Vector<Attribute> getStringAttributes()
          Get the string attributes.
 Matrix getTarget()
           
 Attribute getTestAttribute()
          Return the attribute that defines the test/prediction set.
 Matrix getView()
          The view of the data
 java.lang.String getViewAsString()
           
 int indexOf(Attribute att)
          Get the index of the attribute within the instances (starting at 0; returns -1 if not found.
 int indexOf(Instance in)
          returns -1 if not found.
 boolean isPointInTestingSet(int p)
          Is a specific point in the testing set or is the classification of it unknown.
 boolean isPointSelected(int p)
           
 void loadGraph(Graph graph)
           
 void nominalToBinary(Attribute nominal)
          Convert a nominal attribute into N x binary numeric attributes
 void normalizeDataUnit()
          Normalize the numeric data from the filtered instances to the range [0,1] (ie the minimum data value will be reset to 0 and maximum to 1.
 void normalizeProjection()
           
 int numPointsSelected()
          How many points are currently selected
 void PCA()
           
 void project()
          Project the data to produce a new view.
 void pursueTarget()
          Pursue a projection that will map the target onto the projection until convergence.
 void pursueTargetSingleShot()
          Pursue a projection that will map the target onto the projection, but just take a single step.
 void randomProjection()
           
 double[] removeAttribute(Attribute at)
          Remove an attribute, returning the values
 void removeGraph()
           
 void removeSeries()
           
 void removeTestSet()
           
 void selectPoint(int p)
           
 void selectPoints(int[] p)
           
 void selectSingleAttribute(Attribute at)
          Select a single numeric attribute
 void setInstances(Instances in)
           
 void setProjectionConstraint(ProjectionConstraint constraint)
          Set a constraint on what constitutes a valid projection.
 void setProjectionValues(double[][] values)
           
 void setSeparationAttribute(Attribute at)
          The attribute used to separate points
 void setTarget(Matrix matrix)
          Set the target that the projection is pursuing
 java.lang.String toString(int point)
           
 void uniformProjection()
          Create uniform projection in which each attribute has unit weight.
 void unselectPoints()
           
 void zeroProjectionAttributes(int[] ats)
          Set the input from the selected attributes to zero -- ie remove them temporarily from teh projection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_UNKNOWN

public static final java.lang.String CLASS_UNKNOWN
The value of the class attribute that indicates that the class of this instance is unknown.

See Also:
Constant Field Values
Constructor Detail

TPPModel

public TPPModel(int n)
Construct a new TPP model with the given output dimension

Method Detail

getNumViewDimensions

public int getNumViewDimensions()
Get the number of output dimensions


setInstances

public void setInstances(Instances in)
                  throws java.lang.Exception
Throws:
java.lang.Exception

normalizeDataUnit

public void normalizeDataUnit()
                       throws java.lang.Exception
Normalize the numeric data from the filtered instances to the range [0,1] (ie the minimum data value will be reset to 0 and maximum to 1.

Throws:
java.lang.Exception

getAttributeByName

public Attribute getAttributeByName(java.lang.String name)

nominalToBinary

public void nominalToBinary(Attribute nominal)
                     throws java.lang.Exception
Convert a nominal attribute into N x binary numeric attributes

Throws:
java.lang.Exception

getDescriptionOfInstance

public java.lang.String getDescriptionOfInstance(int[] is)

getDescriptionOfAttributes

public java.lang.String getDescriptionOfAttributes(int[] as)

getSeries

public Series getSeries()
Get the series defined within the data


removeSeries

public void removeSeries()

createSeries

public void createSeries(Attribute indexAttribute,
                         Attribute idAttribute)
Create a series in the instances using the given index and id attributes (specified by name). Any existing series are removed.

Throws:
java.lang.Exception

createTestSet

public Attribute createTestSet(int k)
Create a test set comprising 1/k'th of the instances. If there are no series then the test set is chosen at random. If there are series defined the the test set is the last 1/kth of each series Any existing test set is replaced.

Parameters:
k -
Returns:
the attribute that defines the test set
Throws:
java.lang.Exception

getTestAttribute

public Attribute getTestAttribute()
Return the attribute that defines the test/prediction set.


removeTestSet

public void removeTestSet()

getPointsInTrainingSet

public boolean[] getPointsInTrainingSet()
Return a boolean array indicating whether each instance is a member of the training (true) or test (false) set. Returns null if no test set is defined.


isPointInTestingSet

public boolean isPointInTestingSet(int p)
Is a specific point in the testing set or is the classification of it unknown. Returns false if there is no testing set.


indexOf

public int indexOf(Attribute att)
Get the index of the attribute within the instances (starting at 0; returns -1 if not found.


indexOf

public int indexOf(Instance in)
returns -1 if not found. Get the index of the instance within the instances (starting at 0;


normalizeProjection

public void normalizeProjection()

randomProjection

public void randomProjection()

PCA

public void PCA()

getInstances

public Instances getInstances()
Get the underlying instances


getNormalisedDistances

public Matrix getNormalisedDistances()

getTarget

public Matrix getTarget()

getProjection

public Matrix getProjection()
The current projection


getView

public Matrix getView()
The view of the data


getViewAsString

public java.lang.String getViewAsString()

getData

public Matrix getData()
The normalised numeric data


getNumDataPoints

public int getNumDataPoints()
The number of points


getNumDataDimensions

public int getNumDataDimensions()
The number of dimensions in the numeric data

Returns:

getStringAttributes

public java.util.Vector<Attribute> getStringAttributes()
Get the string attributes. Returns an empty vector if there are none.


getNominalAttributes

public java.util.Vector<Attribute> getNominalAttributes()

getNumericAttributes

public java.util.Vector<Attribute> getNumericAttributes()

getDateAttributes

public java.util.Vector<Attribute> getDateAttributes()

setTarget

public void setTarget(Matrix matrix)
Set the target that the projection is pursuing


project

public void project()
Project the data to produce a new view.


pursueTarget

public void pursueTarget()
                  throws TPPException
Pursue a projection that will map the target onto the projection until convergence.

Throws:
TPPException

pursueTargetSingleShot

public void pursueTargetSingleShot()
                            throws TPPException
Pursue a projection that will map the target onto the projection, but just take a single step. Constraints are ignored

Throws:
TPPException

getProjectionConstraint

public ProjectionConstraint getProjectionConstraint()
Return the constraint that any projection must meet. returns null if no constraint has been defined.


setProjectionConstraint

public void setProjectionConstraint(ProjectionConstraint constraint)
Set a constraint on what constitutes a valid projection. If the projection is non null, then the nearest valid projection is found to the current one


cluster

public Attribute cluster(int numClusters)
Create a new attribute that clusters the original data. KMeans is used by default. returns the new attribute


toString

public java.lang.String toString(int point)

zeroProjectionAttributes

public void zeroProjectionAttributes(int[] ats)
Set the input from the selected attributes to zero -- ie remove them temporarily from teh projection


setSeparationAttribute

public void setSeparationAttribute(Attribute at)
The attribute used to separate points


getSeparationAttribute

public Attribute getSeparationAttribute()

createHierarchicalClustering

public void createHierarchicalClustering()

getHierarchicalCluster

public HierarchicalCluster getHierarchicalCluster()

isPointSelected

public boolean isPointSelected(int p)

arePointsSelected

public boolean arePointsSelected()
Are any points selected?


unselectPoints

public void unselectPoints()

selectPoint

public void selectPoint(int p)

selectPoints

public void selectPoints(int[] p)

numPointsSelected

public int numPointsSelected()
How many points are currently selected


createCrossValidation

public Attribute[] createCrossValidation(Attribute at,
                                         Classifier cls)
Perform 10-fold cross validation for the given attribute. Returns the attributes containing the new classification and the error

Parameters:
cls -

removeAttribute

public double[] removeAttribute(Attribute at)
Remove an attribute, returning the values


selectSingleAttribute

public void selectSingleAttribute(Attribute at)
                           throws java.lang.Exception
Select a single numeric attribute

Throws:
java.lang.Exception

uniformProjection

public void uniformProjection()
                       throws java.lang.Exception
Create uniform projection in which each attribute has unit weight.

Throws:
java.lang.Exception

getCentroids

public Matrix getCentroids(Attribute classification)
                    throws java.lang.Exception
Get the centroids of the data points for the classes defined by the given attribute

Throws:
java.lang.Exception

setProjectionValues

public void setProjectionValues(double[][] values)

getPointDescriptions

public java.lang.String[] getPointDescriptions()
Create an array of descriptions of each point, based on any string attributes


loadGraph

public void loadGraph(Graph graph)

removeGraph

public void removeGraph()

getGraph

public Graph getGraph()

getAttributes

public java.util.Enumeration<Attribute> getAttributes()

addListener

public void addListener(TPPModelEventListener l)

clone

public TPPModel clone()
Overrides:
clone in class java.lang.Object