weka.core.metrics
Class AttrEvalMetricLearner

java.lang.Object
  extended byweka.core.metrics.MetricLearner
      extended byweka.core.metrics.AttrEvalMetricLearner
All Implemented Interfaces:
OptionHandler, java.io.Serializable

public class AttrEvalMetricLearner
extends MetricLearner
implements java.io.Serializable, OptionHandler

AttrEvalMetricLearner - sets the weights of a metric using scores from an attribute evaluator

See Also:
Serialized Form

Field Summary
protected  ASEvaluation m_evaluator
          The attribute evaluator used
protected  LearnableMetric m_metric
          The metric that the classifier was used to learn, useful for external-calculation based metrics
 
Constructor Summary
AttrEvalMetricLearner()
          Create a new attribute evaluator metric learner
 
Method Summary
static java.lang.String concatStringArray(java.lang.String[] strings)
          A little helper to create a single String from an array of Strings
 double getDistance(Instance instance1, Instance instance2)
          Use the Classifier for an estimation of distance
 ASEvaluation getEvaluator()
          Get the evaluator
 java.lang.String[] getOptions()
          Gets the current settings of WeightedDotP.
 double getSimilarity(Instance instance1, Instance instance2)
          Use the Classifier for an estimation of similarity
protected static java.lang.String getTimestamp()
          Gets a string containing current date and time.
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
protected  double[] normalizeWeights(double[] weights)
          Normalize weights
 void setEvaluator(ASEvaluation evaluator)
          Set the evaluator
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 java.lang.String toString()
          Obtain a textual description of the metriclearner
 void trainMetric(LearnableMetric metric, Instances instances)
          Train a given met7ric 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, wait, wait, wait
 

Field Detail

m_metric

protected LearnableMetric m_metric
The metric that the classifier was used to learn, useful for external-calculation based metrics


m_evaluator

protected ASEvaluation m_evaluator
The attribute evaluator used

Constructor Detail

AttrEvalMetricLearner

public AttrEvalMetricLearner()
Create a new attribute evaluator metric learner

Method Detail

trainMetric

public void trainMetric(LearnableMetric metric,
                        Instances instances)
                 throws java.lang.Exception
Train a given met7ric using given training instances

Specified by:
trainMetric in class MetricLearner
Parameters:
metric - the metric to train
instances - data to train the metric on
Throws:
java.lang.Exception - if training has gone bad.

normalizeWeights

protected double[] normalizeWeights(double[] weights)
Normalize weights

Parameters:
weights - an unnormalized array of weights
Returns:
a normalized array of weights

getSimilarity

public double getSimilarity(Instance instance1,
                            Instance instance2)
                     throws java.lang.Exception
Use the Classifier for an estimation of similarity

Specified by:
getSimilarity in class MetricLearner
Parameters:
instance1 - first instance of a pair
instance2 - second instance of a pair
Throws:
java.lang.Exception

getDistance

public double getDistance(Instance instance1,
                          Instance instance2)
                   throws java.lang.Exception
Use the Classifier for an estimation of distance

Specified by:
getDistance in class MetricLearner
Parameters:
instance1 - first instance of a pair
instance2 - second instance of a pair
Throws:
java.lang.Exception

setEvaluator

public void setEvaluator(ASEvaluation evaluator)
                  throws java.lang.Exception
Set the evaluator

Throws:
java.lang.Exception

getEvaluator

public ASEvaluation getEvaluator()
Get the evaluator


getOptions

public java.lang.String[] getOptions()
Gets the current settings of WeightedDotP.

Specified by:
getOptions in interface OptionHandler
Returns:
an array of strings suitable for passing to setOptions()

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Parses a given list of options. Valid options are:

-B classifierstring

Specified by:
setOptions in interface OptionHandler
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

getTimestamp

protected static java.lang.String getTimestamp()
Gets a string containing current date and time.

Returns:
a string containing the date and time.

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.

Specified by:
listOptions in interface OptionHandler
Returns:
an enumeration of all the available options.

toString

public java.lang.String toString()
Obtain a textual description of the metriclearner

Returns:
a textual description of the metric learner

concatStringArray

public static java.lang.String concatStringArray(java.lang.String[] strings)
A little helper to create a single String from an array of Strings

Parameters:
strings - an array of strings