|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.metrics.Metric
weka.core.metrics.LearnableMetric
Interface to distance metrics that can be learned
Field Summary | |
protected double[] |
m_attrWeights
Weights of individual attributes |
Classifier |
m_classifier
|
protected java.lang.String |
m_classifierClassName
|
protected boolean |
m_classifierRequiresNominalClass
Certain classifiers may use non-nominal class attributes |
protected int |
m_numPosDiffInstances
The maximum number of same-class examples to construct diff-instances from |
protected double |
m_posNegDiffInstanceRatio
Proportion of different-class versus same-class diff-instances |
protected boolean |
m_trainable
True if metric learning is used. |
Fields inherited from class weka.core.metrics.Metric |
m_attrIdxs, m_classIndex, m_numAttributes |
Constructor Summary | |
LearnableMetric()
|
Method Summary | |
java.lang.Object |
clone()
Create a copy of this metric |
abstract Instance |
createDiffInstance(Instance instance1,
Instance instance2)
Create an instance with features corresponding to components of the two given instances |
abstract Instance |
getCentroidInstance(Instances instances,
boolean fastMode,
boolean normalized)
Given a cluster of instances, return the centroid of that cluster |
boolean |
getExternal()
Get the value of m_external |
abstract double[] |
getGradients(Instance instance1,
Instance instance2)
Get the values of the partial derivates for the metric components for a particular instance pair |
int |
getNumPosDiffInstances()
Set the number of positive instances to be used for training |
double |
getPosNegDiffInstanceRatio()
Get the ratio of positive and negative instances to be used for training |
boolean |
getTrainable()
Get the value of metricTraining |
double[] |
getWeights()
Get the feature weights |
abstract void |
learnMetric(Instances data)
Train the distance metric. |
double[] |
meanOrMode(Instances insts)
Fast version of meanOrMode - streamlined from Instances.meanOrMode for efficiency Does not check for missing attributes, assumes numeric attributes, assumes Sparse instances |
void |
normalizeInstanceWeighted(Instance inst)
Normalizes the values of an Instance utilizing feature weights |
abstract void |
resetMetric()
Reset all values that have been learned |
void |
setExternal(boolean external)
Set the value of m_external |
void |
setNumPosDiffInstances(int numPosInstances)
Set the number of positive instances to be used for training |
void |
setPosNegDiffInstanceRatio(double ratio)
Set the ratio of positive and negative instances to be used for training |
void |
setTrainable(boolean metricTraining)
Set the value of metricTraining |
void |
setWeights(double[] _weights)
Set the feature weights |
void |
useClassifier(java.lang.String classifierClassName,
boolean classifierRequiresNominalClass)
switch from calculating the metric to pair-space classification |
void |
useNoClassifier()
switch from using a classifier in difference-space to vanilla L-1 norm distance |
boolean |
usesClassifier()
Is this metric defined in vanilla space, or difference space? |
Methods inherited from class weka.core.metrics.Metric |
buildMetric, buildMetric, buildMetric, distance, distanceNonWeighted, forName, getAttrIdxs, getAttrIdxsWithoutLastClass, getAttrIndxs, getClassIndex, getNumAttributes, isDistanceBased, length, normalizeInstance, setAttrIdxs, setAttrIdxs, setClassIndex, similarity, similarityNonWeighted |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected double[] m_attrWeights
protected int m_numPosDiffInstances
protected double m_posNegDiffInstanceRatio
protected java.lang.String m_classifierClassName
public Classifier m_classifier
protected boolean m_classifierRequiresNominalClass
protected boolean m_trainable
Constructor Detail |
public LearnableMetric()
Method Detail |
public abstract void learnMetric(Instances data) throws java.lang.Exception
java.lang.Exception
public void useClassifier(java.lang.String classifierClassName, boolean classifierRequiresNominalClass) throws java.lang.Exception
classifierClassName
- Some classifier that classifies pairs of pointsclassifierRequiresNominalClass
- does classifier need a nominal class attribute?
Using DistributionClassifier because it actually reports a margin
SMO is first, will try others as well
java.lang.Exception
public void useNoClassifier()
public boolean usesClassifier()
public abstract void resetMetric() throws java.lang.Exception
java.lang.Exception
public abstract Instance createDiffInstance(Instance instance1, Instance instance2)
instance1
- first instanceinstance2
- second instancepublic abstract double[] getGradients(Instance instance1, Instance instance2) throws java.lang.Exception
instance1
- the first instanceinstance2
- the first instance
java.lang.Exception
public void setWeights(double[] _weights) throws java.lang.Exception
java.lang.Exception
public double[] getWeights()
public abstract Instance getCentroidInstance(Instances instances, boolean fastMode, boolean normalized)
instances
- data points belonging to a cluster
public double[] meanOrMode(Instances insts)
public boolean getTrainable()
public void setTrainable(boolean metricTraining)
metricTraining
- Value of metricTrainingpublic boolean getExternal()
public void setExternal(boolean external)
external
- if true, an external estimator will be used for distancepublic void setNumPosDiffInstances(int numPosInstances)
numPosInstances
- the number amounts of positive examples (diff-instances)public int getNumPosDiffInstances()
public void setPosNegDiffInstanceRatio(double ratio)
ratio
- the relative amounts of negative examples compared to positive examples.
If -1, all possible negatives will be used (use with care!)public double getPosNegDiffInstanceRatio()
public void normalizeInstanceWeighted(Instance inst) throws java.lang.Exception
inst
- Instance to be normalized
java.lang.Exception
public java.lang.Object clone()
clone
in class Metric
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |