|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.metrics.Metric
Abstract Metric class
Field Summary | |
protected int[] |
m_attrIdxs
indeces of attributes which the metric works on |
protected int |
m_classIndex
index of the class attribute |
protected int |
m_numAttributes
number of attributes |
Constructor Summary | |
Metric()
|
Method Summary | |
abstract void |
buildMetric(Instances data)
Create a new metric for operating on specified instances |
abstract void |
buildMetric(int numAttributes)
Generates a new Metric with a specified number of attributes. |
abstract void |
buildMetric(int numAttributes,
java.lang.String[] options)
Generates a new Metric. |
java.lang.Object |
clone()
Create a copy of this metric |
abstract double |
distance(Instance instance1,
Instance instance2)
Returns a distance value between two instances. |
abstract double |
distanceNonWeighted(Instance instance1,
Instance instance2)
Returns distance between two instances without using the weights. |
static Metric |
forName(java.lang.String metricName,
java.lang.String[] options)
Creates a new instance of a metric given it's class name and (optional) arguments to pass to it's setOptions method. |
int[] |
getAttrIdxs(Instances instances)
This function takes instances, and returns an array of integers 0..(num_attributes-1) |
int[] |
getAttrIdxsWithoutLastClass(Instances instances)
It is often the case that last attribute of the data is the class. |
int[] |
getAttrIndxs()
Returns an array of attribute incece which will be used by the metric |
int |
getClassIndex(int classIndex)
Get the index of the attribute is the class attribute |
int |
getNumAttributes()
Get the number of attributes that the metric uses |
abstract boolean |
isDistanceBased()
The computation of a metric can be either based on distance, or on similarity |
static double |
length(Instance instance)
Get the norm-2 length of an instance assuming all attributes are numeric |
void |
normalizeInstance(Instance inst)
Normalizes the values of a normal Instance |
void |
setAttrIdxs(int[] attrIdxs)
Specifies a list of attributes which will be used by the metric |
void |
setAttrIdxs(int startIdx,
int endIdx)
Specifies an interval of attributes which will be used by the metric |
void |
setClassIndex(int classIndex)
Specify which attribute is the class attribute |
abstract double |
similarity(Instance instance1,
Instance instance2)
Returns a similarity estimate between two instances. |
abstract double |
similarityNonWeighted(Instance instance1,
Instance instance2)
Returns similarity value between two instances without using the weights. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int m_numAttributes
protected int[] m_attrIdxs
protected int m_classIndex
Constructor Detail |
public Metric()
Method Detail |
public abstract void buildMetric(int numAttributes) throws java.lang.Exception
numAttributes
- the number of attributes that the metric will work on
java.lang.Exception
- if the distance metric has not been
generated successfully.public abstract void buildMetric(int numAttributes, java.lang.String[] options) throws java.lang.Exception
numAttributes
- the number of attributes that the metric will work onoptions
- an array of options suitable for passing to setOptions.
May be null.
java.lang.Exception
- if the distance metric has not been
generated successfully.public abstract void buildMetric(Instances data) throws java.lang.Exception
data
- instances that the metric will be used on
java.lang.Exception
public void setAttrIdxs(int[] attrIdxs)
public int[] getAttrIndxs()
public void setAttrIdxs(int startIdx, int endIdx)
public abstract double distance(Instance instance1, Instance instance2) throws java.lang.Exception
instance1
- First instance.instance2
- Second instance.
java.lang.Exception
- if distance could not be estimated.public abstract double similarity(Instance instance1, Instance instance2) throws java.lang.Exception
instance1
- First instance.instance2
- Second instance.
java.lang.Exception
- if similarity could not be estimated.public abstract double similarityNonWeighted(Instance instance1, Instance instance2) throws java.lang.Exception
instance1
- First instance.instance2
- Second instance.
java.lang.Exception
- if similarity could not be estimated.public abstract double distanceNonWeighted(Instance instance1, Instance instance2) throws java.lang.Exception
instance1
- First instance.instance2
- Second instance.
java.lang.Exception
- if similarity could not be estimated.public int[] getAttrIdxsWithoutLastClass(Instances instances)
public int[] getAttrIdxs(Instances instances)
public void setClassIndex(int classIndex)
public int getClassIndex(int classIndex)
public int getNumAttributes()
public abstract boolean isDistanceBased()
public static double length(Instance instance)
public void normalizeInstance(Instance inst) throws java.lang.Exception
inst
- Instance to be normalized
java.lang.Exception
public static Metric forName(java.lang.String metricName, java.lang.String[] options) throws java.lang.Exception
metricName
- the fully qualified class name of the metricoptions
- an array of options suitable for passing to setOptions. May
be null.
java.lang.Exception
- if the metric name is invalid, or the options
supplied are not acceptable to the metricpublic java.lang.Object clone()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |