|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.DistributionClassifier
weka.classifiers.misc.PrototypeMetric
Prototype learner for purely real-valued instances that uses a general weka.core.metrics.Metric. Computes an average/mean/prototype vector for each class. New examples are classified based on computing distance from the instance feature vector to the closest prototype using this Metric. By defaults acts as Rocchio-style classifier that uses cosine similarity Assuming text data arff file is already TFIDF weighted. For example see: Joachims, Thorsten, A Probabilistic Analysis of the Rocchio Algorithm with TFIDF for Text Categorization. Proceedings of International Conference on Machine Learning (ICML), 1997.
Field Summary | |
protected Instances |
m_Instances
The instances used for training. |
protected Metric |
m_Metric
Metric to be used to compare intances to prototype instance |
protected Instance[] |
m_Prototypes
Prototype instance for each class |
Constructor Summary | |
PrototypeMetric()
|
Method Summary | |
void |
buildClassifier(Instances instances)
Generates the classifier. |
Instances[] |
classPartitionInstances(Instances instances)
Partition instances into a set for each class |
static java.lang.String |
concatStringArray(java.lang.String[] strings)
A little helper to create a single String from an array of Strings |
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance. |
Metric |
getMetric()
Get the distance metric |
java.lang.String[] |
getOptions()
Gets the current settings. |
java.lang.String |
globalInfo()
Returns a string describing this clusterer |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options.. |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
Instance |
meanInstance(Instances instances)
Compute a mean instance for all the instances in a set |
protected double[] |
meanVectorFull(Instances instances)
Compute mean vector for non-sparse instances using meanOrMode method on Instances |
protected double[] |
meanVectorSparse(Instances instances)
Efficiently compute a mean vector for a set of sparse instances |
void |
setMetric(Metric m)
Set the distance metric |
void |
setOptions(java.lang.String[] options)
Parses a given list of options. |
java.lang.String |
toString()
Returns a description of the classifier. |
Methods inherited from class weka.classifiers.DistributionClassifier |
calculateEntropy, calculateLabeledInstanceMargin, calculateMargin, classifyInstance |
Methods inherited from class weka.classifiers.Classifier |
forName, makeCopies |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Metric m_Metric
protected Instance[] m_Prototypes
protected Instances m_Instances
Constructor Detail |
public PrototypeMetric()
Method Detail |
public void setMetric(Metric m)
public Metric getMetric()
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
setOptions
in interface OptionHandler
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public java.lang.String globalInfo()
public void buildClassifier(Instances instances) throws java.lang.Exception
buildClassifier
in class Classifier
instances
- set of instances serving as training data
java.lang.Exception
- if the classifier has not been generated successfullypublic Instances[] classPartitionInstances(Instances instances)
public Instance meanInstance(Instances instances)
protected double[] meanVectorFull(Instances instances)
protected double[] meanVectorSparse(Instances instances)
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class DistributionClassifier
instance
- the instance to be classified
java.lang.Exception
- if distribution can't be computedpublic static java.lang.String concatStringArray(java.lang.String[] strings)
strings
- an array of stringspublic java.lang.String toString()
public static void main(java.lang.String[] argv)
argv
- the options
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |