|
||||||||||
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
weka.core.metrics.WeightedEuclidean
WeightedEuclidean class Implements weighted euclidean distance metric
Field Summary | |
static int |
CONVERSION_EXPONENTIAL
|
static int |
CONVERSION_LAPLACIAN
We can have different ways of converting from distance to similarity |
static int |
CONVERSION_UNIT
|
protected int |
m_conversionType
The method of converting, by default laplacian |
protected MetricLearner |
m_metricLearner
A metric learner responsible for training the parameters of the metric |
static Tag[] |
TAGS_CONVERSION
|
Fields inherited from class weka.core.metrics.LearnableMetric |
m_attrWeights, m_classifier, m_classifierClassName, m_classifierRequiresNominalClass, m_numPosDiffInstances, m_posNegDiffInstanceRatio, m_trainable |
Fields inherited from class weka.core.metrics.Metric |
m_attrIdxs, m_classIndex, m_numAttributes |
Constructor Summary | |
WeightedEuclidean()
Create a default new metric |
|
WeightedEuclidean(int numAttributes)
Create a new metric. |
|
WeightedEuclidean(int[] _attrIdxs)
Creates a new metric which takes specified attributes. |
Method Summary | |
void |
buildMetric(Instances data)
Create a new metric for operating on specified instances |
void |
buildMetric(int numAttributes)
Generates a new Metric. |
void |
buildMetric(int numAttributes,
java.lang.String[] options)
Generates a new Metric. |
java.lang.Object |
clone()
Create a copy of this metric |
Instance |
createDiffInstance(Instance instance1,
Instance instance2)
Create an instance with features corresponding to dot-product components of the two given instances |
protected Instance |
createDiffInstanceNonSparse(Instance instance1,
Instance instance2)
Create a nonsparse instance with features corresponding to dot-product components of the two given instances |
protected SparseInstance |
createDiffInstanceSparse(SparseInstance instance1,
SparseInstance instance2)
Create a sparse instance with features corresponding to dot-product components of the two given instances |
protected Instance |
createDiffInstanceSparseNonSparse(SparseInstance instance1,
Instance instance2)
Create an instance with features corresponding to dot-product components of the two given instances |
double |
distance(Instance instance1,
Instance instance2)
Returns a distance value between two instances. |
double |
distanceInternal(Instance instance1,
Instance instance2)
Returns a distance value between two instances. |
double |
distanceNonSparse(Instance instance1,
Instance instance2)
Returns a distance value between non-sparse instances without using the weights |
double |
distanceNonSparseNonWeighted(Instance instance1,
Instance instance2)
Returns a distance value between non-sparse instances (or a non-sparse instance and a sparse instance) without using the weights |
double |
distanceNonWeighted(Instance instance1,
Instance instance2)
Returns a distance value between two instances. |
double |
distanceSparse(SparseInstance instance1,
SparseInstance instance2)
Returns a distance value between two sparse instances. |
double |
distanceSparseNonSparse(SparseInstance instance1,
Instance instance2)
Returns a distance value between a non-sparse instance and a sparse instance |
double |
distanceSparseNonSparseNonWeighted(SparseInstance instance1,
Instance instance2)
Returns a distance value between a non-sparse instance and a sparse instance |
double |
distanceSparseNonWeighted(SparseInstance instance1,
SparseInstance instance2)
Returns a distance value between two sparse instances without using the weights. |
Instance |
getCentroidInstance(Instances instances,
boolean fastMode,
boolean normalized)
Given a cluster of instances, return the centroid of that cluster |
SelectedTag |
getConversionType()
return the type of distance to similarity conversion |
double[] |
getGradients(Instance instance1,
Instance instance2)
Get the values of the partial derivates for the metric components for a particular instance pair |
MetricLearner |
getMetricLearner()
Get the distance metric learner |
protected java.lang.String |
getMetricLearnerSpec()
Gets the classifier specification string, which contains the class name of the classifier and any options to the classifier |
java.lang.String[] |
getOptions()
Gets the current settings of WeightedEuclideanP. |
boolean |
isDistanceBased()
The computation of a metric can be either based on distance, or on similarity |
void |
learnMetric(Instances data)
Train the metric |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options. |
static void |
main(java.lang.String[] args)
|
void |
resetMetric()
Reset all values that have been learned |
void |
setConversionType(SelectedTag conversionType)
Set the type of distance to similarity conversion. |
void |
setMetricLearner(MetricLearner metricLearner)
Set the distance metric learner |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
double |
similarity(Instance instance1,
Instance instance2)
Returns a similarity estimate between two instances. |
double |
similarityNonWeighted(Instance instance1,
Instance instance2)
Returns a similarity estimate between two instances without using the weights. |
Methods inherited from class weka.core.metrics.LearnableMetric |
getExternal, getNumPosDiffInstances, getPosNegDiffInstanceRatio, getTrainable, getWeights, meanOrMode, normalizeInstanceWeighted, setExternal, setNumPosDiffInstances, setPosNegDiffInstanceRatio, setTrainable, setWeights, useClassifier, useNoClassifier, usesClassifier |
Methods inherited from class weka.core.metrics.Metric |
forName, getAttrIdxs, getAttrIdxsWithoutLastClass, getAttrIndxs, getClassIndex, getNumAttributes, length, normalizeInstance, setAttrIdxs, setAttrIdxs, setClassIndex |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int CONVERSION_LAPLACIAN
public static final int CONVERSION_UNIT
public static final int CONVERSION_EXPONENTIAL
public static final Tag[] TAGS_CONVERSION
protected int m_conversionType
protected MetricLearner m_metricLearner
Constructor Detail |
public WeightedEuclidean(int numAttributes) throws java.lang.Exception
numAttributes
- the number of attributes that the metric will work onpublic WeightedEuclidean()
public WeightedEuclidean(int[] _attrIdxs) throws java.lang.Exception
_attrIdxs
- An array containing attribute indeces that will
be used in the metricMethod Detail |
public void resetMetric() throws java.lang.Exception
resetMetric
in class LearnableMetric
java.lang.Exception
public void buildMetric(int numAttributes) throws java.lang.Exception
buildMetric
in class Metric
numAttributes
- the number of attributes that the metric will work on
java.lang.Exception
- if the distance metric has not been
generated successfully.public void buildMetric(int numAttributes, java.lang.String[] options) throws java.lang.Exception
buildMetric
in class Metric
options
- an array of options suitable for passing to setOptions.
May be null.numAttributes
- the number of attributes that the metric will work on
java.lang.Exception
- if the distance metric has not been
generated successfully.public void buildMetric(Instances data) throws java.lang.Exception
buildMetric
in class Metric
data
- instances that the metric will be used on
java.lang.Exception
public double distance(Instance instance1, Instance instance2) throws java.lang.Exception
distance
in class Metric
instance1
- First instance.instance2
- Second instance.
java.lang.Exception
- if distance could not be estimated.public double distanceInternal(Instance instance1, Instance instance2) throws java.lang.Exception
instance1
- First instance.instance2
- Second instance.
java.lang.Exception
- if distance could not be estimated.public double distanceSparse(SparseInstance instance1, SparseInstance instance2) throws java.lang.Exception
instance1
- First sparse instance.instance2
- Second sparse instance.
java.lang.Exception
- if distance could not be estimated.public double distanceSparseNonSparse(SparseInstance instance1, Instance instance2) throws java.lang.Exception
instance1
- sparse instance.instance2
- sparse instance.
java.lang.Exception
- if distance could not be estimated.public double distanceNonSparse(Instance instance1, Instance instance2) throws java.lang.Exception
instance1
- non-sparse instance.instance2
- non-sparse instance.
java.lang.Exception
- if distance could not be estimated.public double distanceNonWeighted(Instance instance1, Instance instance2) throws java.lang.Exception
distanceNonWeighted
in class Metric
instance1
- First instance.instance2
- Second instance.
java.lang.Exception
- if distance could not be estimated.public double distanceSparseNonWeighted(SparseInstance instance1, SparseInstance instance2) throws java.lang.Exception
instance1
- First sparse instance.instance2
- Second sparse instance.
java.lang.Exception
- if distance could not be estimated.public double distanceSparseNonSparseNonWeighted(SparseInstance instance1, Instance instance2) throws java.lang.Exception
instance1
- sparse instance.instance2
- sparse instance.
java.lang.Exception
- if distance could not be estimated.public double distanceNonSparseNonWeighted(Instance instance1, Instance instance2) throws java.lang.Exception
instance1
- non-sparse instance.instance2
- non-sparse instance.
java.lang.Exception
- if distance could not be estimated.public double similarity(Instance instance1, Instance instance2) throws java.lang.Exception
similarity
in class Metric
instance1
- First instance.instance2
- Second instance.
java.lang.Exception
- if similarity could not be estimated.public double similarityNonWeighted(Instance instance1, Instance instance2) throws java.lang.Exception
similarityNonWeighted
in class Metric
instance1
- First instance.instance2
- Second instance.
java.lang.Exception
- if similarity could not be estimated.public double[] getGradients(Instance instance1, Instance instance2) throws java.lang.Exception
getGradients
in class LearnableMetric
instance1
- the first instanceinstance2
- the first instance
java.lang.Exception
public void learnMetric(Instances data) throws java.lang.Exception
learnMetric
in class LearnableMetric
java.lang.Exception
public void setMetricLearner(MetricLearner metricLearner)
metricLearner
- the metric learnerpublic MetricLearner getMetricLearner()
public Instance createDiffInstance(Instance instance1, Instance instance2)
createDiffInstance
in class LearnableMetric
instance1
- first instanceinstance2
- second instanceprotected SparseInstance createDiffInstanceSparse(SparseInstance instance1, SparseInstance instance2)
instance1
- first sparse instanceinstance2
- second sparse instanceprotected Instance createDiffInstanceSparseNonSparse(SparseInstance instance1, Instance instance2)
instance1
- first sparse instanceinstance2
- second non-sparse instanceprotected Instance createDiffInstanceNonSparse(Instance instance1, Instance instance2)
instance1
- first nonsparse instanceinstance2
- second nonsparse instancepublic void setConversionType(SelectedTag conversionType)
public SelectedTag getConversionType()
public boolean isDistanceBased()
isDistanceBased
in class Metric
public Instance getCentroidInstance(Instances instances, boolean fastMode, boolean normalized)
getCentroidInstance
in class LearnableMetric
instances
- objects belonging to a clusterfastMode
- whether fast mode should be used for SparseInstancesnormalized
- normalize centroids for SPKMeans
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-N
Normalize the euclidean distance by vectors lengths
-E
Use exponential conversion from distance to similarity
(default laplacian conversion)
-U
Use unit conversion from similarity to distance (dist=1-sim)
(default laplacian conversion)
-R
The metric is trainable and will be trained using the current MetricLearner
(default non-trainable)
setOptions
in interface OptionHandler
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedprotected java.lang.String getMetricLearnerSpec()
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
public java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public java.lang.Object clone()
clone
in class LearnableMetric
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |