|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.metrics.MetricLearner
weka.core.metrics.MatlabMetricLearner
MatlabMetricLearner - learns metric parameters by constructing "difference instances" and then learning weights that classify same-class instances as positive, and different-class instances as negative using an external Matlab program.
Field Summary | |
protected boolean |
m_debug
Debugging output |
protected java.lang.String |
m_negMatrixFilename
Name of the temporary file where the matrix representing the diff-class diff. |
protected java.lang.String |
m_posMatrixFilename
Name of the temporary file where the matrix representing the same-class diff. |
protected java.lang.String |
m_scriptFilename
Matlab program that is used for learning metric weights |
protected java.lang.String |
m_weightsFilename
Name of the temporary file where the weights will be stored by Matlab after calculation |
Constructor Summary | |
MatlabMetricLearner()
Create a new matlab metric learner |
Method Summary | |
void |
dumpInstanceList(java.util.ArrayList instanceList,
java.lang.String filename)
Dump a list of instances as a matrix of attribute values |
double |
getDistance(Instance instance1,
Instance instance2)
Use Matlab for an estimation of distance |
double |
getSimilarity(Instance instance1,
Instance instance2)
Use Matlab for an estimation of similarity |
protected static java.lang.String |
getTimestamp()
Gets a string containing current date and time. |
void |
prepareMatlabScript()
Create matlab m-file for PCA |
double[] |
readVector(java.lang.String name)
Read a column vector from a text file |
void |
runMatlab(java.lang.String inFile,
java.lang.String outFile)
Run matlab in command line with a given argument |
void |
trainMetric(LearnableMetric metric,
Instances instances)
Train a given metric using given training instances |
Methods inherited from class weka.core.metrics.MetricLearner |
createDiffInstanceLists, createDiffInstances, createDiffInstances, forName, getAttrInfoForDiffInstance |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String m_scriptFilename
protected java.lang.String m_posMatrixFilename
protected java.lang.String m_negMatrixFilename
protected java.lang.String m_weightsFilename
protected boolean m_debug
Constructor Detail |
public MatlabMetricLearner()
Method Detail |
public void trainMetric(LearnableMetric metric, Instances instances) throws java.lang.Exception
trainMetric
in class MetricLearner
metric
- the metric to traininstances
- data to train the metric on
java.lang.Exception
- if training has gone bad.public void prepareMatlabScript()
public void runMatlab(java.lang.String inFile, java.lang.String outFile)
inFile
- file to be input to MatlaboutFile
- file where results are storedprotected static java.lang.String getTimestamp()
public double[] readVector(java.lang.String name) throws java.lang.Exception
name
- file name
java.lang.Exception
public void dumpInstanceList(java.util.ArrayList instanceList, java.lang.String filename)
instanceList
- a list of instancesfilename
- name of the file where the matrix is savedpublic double getSimilarity(Instance instance1, Instance instance2) throws java.lang.Exception
getSimilarity
in class MetricLearner
instance1
- first instance of a pairinstance2
- second instance of a pair
java.lang.Exception
public double getDistance(Instance instance1, Instance instance2) throws java.lang.Exception
getDistance
in class MetricLearner
instance1
- first instance of a pairinstance2
- second instance of a pair
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |