|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.tuwien.ifs.somtoolbox.layers.metrics.AbstractMetric
public abstract class AbstractMetric
Implements a static method for metric instantiation and a method for mean vector calculation. Furthermore, implements
the convenience methods to call the abstract method having two double arrays as arguments (see
distance(double[], double[])
). This method has to be implemented by classes actually implementing a certain
metric.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface at.tuwien.ifs.somtoolbox.layers.metrics.DistanceMetric |
---|
DistanceMetric.SparcseMetricModes |
Field Summary | |
---|---|
static String |
PACKAGE_NAME
|
Constructor Summary | |
---|---|
AbstractMetric()
|
Method Summary | |
---|---|
protected void |
checkDimensions(double[] vector1,
double[] vector2)
Performs a check on wether the given vectors have the same dimension. |
protected void |
checkDimensions(cern.colt.matrix.DoubleMatrix1D vector1,
cern.colt.matrix.DoubleMatrix1D vector2)
Performs a check on wether the given vectors have the same dimension. |
int |
compareTo(DistanceMetric o)
|
abstract double |
distance(double[] vector1,
double[] vector2)
Calculates the distance between two vectors provided by argument vector1 and vector2 . |
double |
distance(double[] vector1,
cern.colt.matrix.DoubleMatrix1D vector2)
Calculates the distance between two vectors provided by argument vector1 and vector2 . |
double |
distance(double[] vector,
InputDatum data)
Calculates the distance between two vectors provided by argument vector and datum . |
double |
distance(cern.colt.matrix.DoubleMatrix1D vector1,
double[] vector2)
Calculates the distance between two vectors provided by argument vector1 and vector2 . |
double |
distance(cern.colt.matrix.DoubleMatrix1D vector1,
cern.colt.matrix.DoubleMatrix1D vector2)
Calculates the distance between two vectors provided by argument vector1 and vector2 . |
double |
distance(cern.colt.matrix.DoubleMatrix1D vector,
InputDatum datum)
Calculates the distance between two vectors provided by argument vector and datum . |
double |
distance(InputDatum data,
double[] vector)
Calculates the distance between two vectors provided by argument datum and vector . |
double |
distance(InputDatum datum,
cern.colt.matrix.DoubleMatrix1D vector)
Calculates the distance between two vectors provided by argument datum and vector . |
double |
distance(InputDatum datum,
InputDatum datum2)
Calculates the distance between two vectors provided by argument datum and datum2 . |
static DistanceMetric |
instantiate(String mName)
Instantiates a certain distance metric class specified by argument mName .Note: for backwards compatibility, if the metric name contains the package prefix at.ec3.somtoolbox ,
this will be replaced by at.tuwien.ifs.somtoolbox . |
static DistanceMetric |
instantiateNice(String metricName)
Same as instantiate(String) , but tries to get the metric with the specified name, and then with the
package prefix, and throwing only a SOMToolboxException with the root cause nested. |
static double[] |
meanVector(double[] vector1,
double[] vector2)
Calculates the mean vector of two double array vectors. |
protected static void |
performanceTest(DistanceMetric metric,
int dim)
Can be used to do some performance testing to compare colt vs. |
void |
setMetricParams(String metricParamString)
Empty implementation, subclasses needing to set parameters have to override this class. |
double |
transformValue(double value)
|
double[] |
transformVector(double[] vector)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PACKAGE_NAME
Constructor Detail |
---|
public AbstractMetric()
Method Detail |
---|
public static DistanceMetric instantiate(String mName) throws ClassNotFoundException, InstantiationException, IllegalAccessException
mName
.prefix at.ec3.somtoolbox
,
this will be replaced by at.tuwien.ifs.somtoolbox
.
mName
- the name of the metric.
mName
.
ClassNotFoundException
- if class denoted by argument mName
is not found.
InstantiationException
- if if this Class represents an abstract class, an interface, an array class, a
primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails
for some other reason.
IllegalAccessException
- if the class or its nullary constructor is not accessible.public static DistanceMetric instantiateNice(String metricName) throws SOMToolboxException
instantiate(String)
, but tries to get the metric with the specified name, and then with the
package prefix, and throwing only a SOMToolboxException
with the root cause nested.
SOMToolboxException
public static double[] meanVector(double[] vector1, double[] vector2) throws MetricException
vector1
- first vector.vector2
- second vector.
MetricException
- if the dimensionalities of the two vectors differ.protected static void performanceTest(DistanceMetric metric, int dim)
public abstract double distance(double[] vector1, double[] vector2) throws MetricException
DistanceMetric
vector1
and vector2
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.
distance
in interface DistanceMetric
vector1
- first vector.vector2
- second vector.
vector1
and vector2
.
MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(double[], double[])
public double distance(double[] vector1, cern.colt.matrix.DoubleMatrix1D vector2) throws MetricException
DistanceMetric
vector1
and vector2
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.
distance
in interface DistanceMetric
vector1
- first vector.vector2
- second vector.
vector1
and vector2
.
MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(double[], cern.colt.matrix.DoubleMatrix1D)
public double distance(double[] vector, InputDatum data) throws MetricException
DistanceMetric
vector
and datum
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.
distance
in interface DistanceMetric
vector
- first vector.data
- input datum.
vector
and datum
.
MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(double[],
at.tuwien.ifs.somtoolbox.data.InputDatum)
public double distance(cern.colt.matrix.DoubleMatrix1D vector1, double[] vector2) throws MetricException
DistanceMetric
vector1
and vector2
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.
distance
in interface DistanceMetric
vector1
- first vector.vector2
- second vector.
vector1
and vector2
.
MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(cern.colt.matrix.DoubleMatrix1D, double[])
public double distance(cern.colt.matrix.DoubleMatrix1D vector1, cern.colt.matrix.DoubleMatrix1D vector2) throws MetricException
DistanceMetric
vector1
and vector2
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.
distance
in interface DistanceMetric
vector1
- first vector.vector2
- second vector.
vector1
and vector2
.
MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(cern.colt.matrix.DoubleMatrix1D,
cern.colt.matrix.DoubleMatrix1D)
public double distance(cern.colt.matrix.DoubleMatrix1D vector, InputDatum datum) throws MetricException
DistanceMetric
vector
and datum
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.
distance
in interface DistanceMetric
vector
- first vector.datum
- input datum.
vector
and datum
.
MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(cern.colt.matrix.DoubleMatrix1D,
at.tuwien.ifs.somtoolbox.data.InputDatum)
public double distance(InputDatum data, double[] vector) throws MetricException
DistanceMetric
datum
and vector
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.
distance
in interface DistanceMetric
data
- input datum.vector
- first vector.
datum
and vector
.
MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(at.tuwien.ifs.somtoolbox.data.InputDatum,
double[])
public double distance(InputDatum datum, cern.colt.matrix.DoubleMatrix1D vector) throws MetricException
DistanceMetric
datum
and vector
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.
distance
in interface DistanceMetric
datum
- input datum.vector
- first vector.
datum
and vector
.
MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(at.tuwien.ifs.somtoolbox.data.InputDatum,
cern.colt.matrix.DoubleMatrix1D)
public double distance(InputDatum datum, InputDatum datum2) throws MetricException
DistanceMetric
datum
and datum2
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.
distance
in interface DistanceMetric
datum
- first input datum.datum2
- second input datum.
datum
and vector
.
MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(at.tuwien.ifs.somtoolbox.data.InputDatum,
at.tuwien.ifs.somtoolbox.data.InputDatum)
protected void checkDimensions(double[] vector1, double[] vector2) throws MetricException
MetricException
- If the given vectors have different dimensions.protected void checkDimensions(cern.colt.matrix.DoubleMatrix1D vector1, cern.colt.matrix.DoubleMatrix1D vector2) throws MetricException
MetricException
- If the given vectors have different dimensions.public double transformValue(double value)
transformValue
in interface DistanceMetric
public double[] transformVector(double[] vector)
transformVector
in interface DistanceMetric
public void setMetricParams(String metricParamString) throws SOMToolboxException
setMetricParams
in interface DistanceMetric
SOMToolboxException
public int compareTo(DistanceMetric o)
compareTo
in interface Comparable<DistanceMetric>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |