Set attribute evaluator. Evaluator spec should contain the full
class name of an attribute evaluator followed by any options.
- See Also:
- Serialized Form
Field Summary |
protected java.lang.String |
m_mFile
Name of the Matlab program file that computes NMF |
Method Summary |
void |
buildEvaluator(Instances data)
Initializes NMF. |
Instance |
convertInstance(Instance instance)
Transform an instance in original (unnormalized) format. |
double |
evaluateAttribute(int att)
Evaluates the merit of a transformed attribute. |
java.lang.String |
evaluatorTipText()
Returns the tip text for this property |
ASEvaluation |
getEvaluator()
Gets the attribute evaluator used |
protected java.lang.String |
getEvaluatorSpec()
Gets the evaluator specification string, which contains the class
name of the attribute evaluator and any options to it |
int |
getIterations()
Gets the number of iterations for gradient descent. |
boolean |
getNormalize()
Gets whether or not input data is to be normalized |
int |
getObjectiveFunction()
Gets the objective function. |
java.lang.String[] |
getOptions()
Gets the current settings of MatlabNMF |
int |
getRank()
Gets the rank of the basis matrix W. |
java.lang.String |
globalInfo()
Returns a string describing this attribute transformer |
java.lang.String |
iterationsTipText()
Returns the tip text for this property |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options. |
static void |
main(java.lang.String[] argv)
Main method for testing this class |
java.lang.String |
normalizeTipText()
Returns the tip text for this property |
java.lang.String |
objectiveFunctionTipText()
Returns the tip text for this property |
java.lang.String |
rankTipText()
Returns the tip text for this property |
void |
readVector(double[] vector,
java.lang.String name)
Read a column vector from a text file |
double[][] |
readVectors(java.lang.String name,
int maxVectors)
Read column vectors from a text file |
static void |
runMatlab(java.lang.String inFile)
Run matlab in command line with a given argument |
void |
setEvaluator(ASEvaluation evaluator)
Sets the attribute evaluator |
void |
setIterations(int i)
Sets the number of iterations for gradient descent. |
void |
setNormalize(boolean n)
Set whether input data will be normalized. |
void |
setObjectiveFunction(int i)
Sets the objective function. |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
void |
setRank(int r)
Sets the rank of the basis matrix W. |
java.lang.String |
toString()
Returns a description of this attribute transformer |
Instances |
transformedData()
Gets the transformed training data. |
Instances |
transformedHeader()
Returns just the header for the transformed data (ie. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
m_mFile
protected java.lang.String m_mFile
- Name of the Matlab program file that computes NMF
MatlabNMF
public MatlabNMF()
globalInfo
public java.lang.String globalInfo()
- Returns a string describing this attribute transformer
- Returns:
- a description of the evaluator suitable for
displaying in the explorer/experimenter gui
listOptions
public java.util.Enumeration listOptions()
- Returns an enumeration describing the available options.
- Specified by:
listOptions
in interface OptionHandler
- Returns:
- an enumeration of all the available options.
setOptions
public void setOptions(java.lang.String[] options)
throws java.lang.Exception
- Parses a given list of options.
Valid options are:
-D
Don't normalize the input data.
-R
Set rank of the basis matrix. Default=5.
-n
Set number of iterations. Default=20.
-O
Set objective function. Default=1.
[1: sum_{i,u}[V_{iu}log(WH)_{iu}-(WH)_{iu}]; 2: norm(V-WH);
3: D(V||WH)]
-E
Set attribute evaluator. Evaluator spec should contain the full
class name of an attribute evaluator followed by any options.
- Specified by:
setOptions
in interface OptionHandler
- Parameters:
options
- the list of options as an array of strings
- Throws:
java.lang.Exception
- if an option is not supported
normalizeTipText
public java.lang.String normalizeTipText()
- Returns the tip text for this property
- Returns:
- tip text for this property suitable for
displaying in the explorer/experimenter gui
setNormalize
public void setNormalize(boolean n)
- Set whether input data will be normalized.
- Parameters:
n
- true if input data is to be normalized
getNormalize
public boolean getNormalize()
- Gets whether or not input data is to be normalized
- Returns:
- true if input data is to be normalized
rankTipText
public java.lang.String rankTipText()
- Returns the tip text for this property
- Returns:
- tip text for this property suitable for
displaying in the explorer/experimenter gui
setRank
public void setRank(int r)
- Sets the rank of the basis matrix W.
- Parameters:
r
- the rank of the basis matrix
getRank
public int getRank()
- Gets the rank of the basis matrix W.
- Returns:
- the rank of the basis matrix
iterationsTipText
public java.lang.String iterationsTipText()
- Returns the tip text for this property
- Returns:
- tip text for this property suitable for
displaying in the explorer/experimenter gui
setIterations
public void setIterations(int i)
- Sets the number of iterations for gradient descent.
- Parameters:
i
- the number of iterations
getIterations
public int getIterations()
- Gets the number of iterations for gradient descent.
- Returns:
- the nubmer of iterations
objectiveFunctionTipText
public java.lang.String objectiveFunctionTipText()
- Returns the tip text for this property
- Returns:
- tip text for this property suitable for
displaying in the explorer/experimenter gui
setObjectiveFunction
public void setObjectiveFunction(int i)
- Sets the objective function.
- Parameters:
i
- the objective function
getObjectiveFunction
public int getObjectiveFunction()
- Gets the objective function.
- Returns:
- the objective function
evaluatorTipText
public java.lang.String evaluatorTipText()
- Returns the tip text for this property
- Returns:
- tip text for this property suitable for
displaying in the explorer/experimenter gui
setEvaluator
public void setEvaluator(ASEvaluation evaluator)
- Sets the attribute evaluator
- Parameters:
evaluator
- the evaluator with all options set.
getEvaluator
public ASEvaluation getEvaluator()
- Gets the attribute evaluator used
- Returns:
- the attribute evaluator
getEvaluatorSpec
protected java.lang.String getEvaluatorSpec()
- Gets the evaluator specification string, which contains the class
name of the attribute evaluator and any options to it
- Returns:
- the evaluator string.
getOptions
public java.lang.String[] getOptions()
- Gets the current settings of MatlabNMF
- Specified by:
getOptions
in interface OptionHandler
- Returns:
- an array of strings suitable for passing to setOptions()
buildEvaluator
public void buildEvaluator(Instances data)
throws java.lang.Exception
- Initializes NMF.
- Specified by:
buildEvaluator
in class ASEvaluation
- Parameters:
data
- the instances to analyze
- Throws:
java.lang.Exception
- if analysis fails
readVectors
public double[][] readVectors(java.lang.String name,
int maxVectors)
throws java.lang.Exception
- Read column vectors from a text file
- Parameters:
name
- file namemaxVectors
- max number of vectors to read, -1 to read all
- Returns:
- double[][] array corresponding to vectors
- Throws:
java.lang.Exception
readVector
public void readVector(double[] vector,
java.lang.String name)
throws java.lang.Exception
- Read a column vector from a text file
- Parameters:
vector
- array into which the column vector is storedname
- file name
- Throws:
java.lang.Exception
transformedHeader
public Instances transformedHeader()
throws java.lang.Exception
- Returns just the header for the transformed data (ie. an empty
set of instances. This is so that AttributeSelection can
determine the structure of the transformed data without actually
having to get all the transformed data through getTransformedData().
- Specified by:
transformedHeader
in interface AttributeTransformer
- Returns:
- the header of the transformed data.
- Throws:
java.lang.Exception
- if the header of the transformed data can't
be determined.
transformedData
public Instances transformedData()
throws java.lang.Exception
- Gets the transformed training data.
- Specified by:
transformedData
in interface AttributeTransformer
- Returns:
- the transformed training data
- Throws:
java.lang.Exception
- if transformed data can't be returned
evaluateAttribute
public double evaluateAttribute(int att)
throws java.lang.Exception
- Evaluates the merit of a transformed attribute.
- Specified by:
evaluateAttribute
in class AttributeEvaluator
- Parameters:
att
- the attribute to be evaluated
- Returns:
- the merit of a transformed attribute
- Throws:
java.lang.Exception
- if attribute can't be evaluated
runMatlab
public static void runMatlab(java.lang.String inFile)
- Run matlab in command line with a given argument
- Parameters:
inFile
- file to be input to Matlab
toString
public java.lang.String toString()
- Returns a description of this attribute transformer
- Returns:
- a String describing this attribute transformer
convertInstance
public Instance convertInstance(Instance instance)
throws java.lang.Exception
- Transform an instance in original (unnormalized) format. Convert back
to the original space if requested.
- Specified by:
convertInstance
in interface AttributeTransformer
- Parameters:
instance
- an instance in the original (unnormalized) format
- Returns:
- a transformed instance
- Throws:
java.lang.Exception
- if instance cant be transformed
main
public static void main(java.lang.String[] argv)
- Main method for testing this class
- Parameters:
argv
- should contain the command line arguments to the
evaluator/transformer (see AttributeSelection)