|
||||||||||
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.Prototype
Class for building and using a simple prototype classifier. 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. For real-valued attributes, standard vector mean and Euclidian distance are used. To handle nominal attributes, the distribution of values for each category are computed (as in naive Bayes) as part of the prototype. The distance along a nominal attribute from an instance with a value V for this attribute to the prototype for a given class is then: 1- P(V|class) In order to make each attribute contribute equally to the distance, values are normalized to [0,1] by setting NormalizeAttributes, which is set by default Predicted class probabilities to make a DistributionClassifier are assumed to be inversely proportional to the distances from the prototypes Borrows some structure from NaiveBayesSimple
Field Summary | |
protected double[][][] |
m_Counts
All the counts for nominal attributes. |
protected Instances |
m_Instances
The instances used for training. |
protected double[][] |
m_Means
The means for numeric attributes. |
protected boolean |
m_NormalizeAttributes
If set, Normalize all real attribute values between 0 and 1 so that each dimension contributes equally to distance |
protected double[] |
m_Ranges
The range (from min to max) taken on by each of the numeric attributes |
Constructor Summary | |
Prototype()
|
Method Summary | |
void |
buildClassifier(Instances instances)
Generates the classifier. |
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance. |
boolean |
getNormalizeAttributes()
|
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. |
java.lang.String |
normalizeAttributesTipText()
|
void |
setNormalizeAttributes(boolean v)
|
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 double[][][] m_Counts
protected double[][] m_Means
protected double[] m_Ranges
protected Instances m_Instances
protected boolean m_NormalizeAttributes
Constructor Detail |
public Prototype()
Method Detail |
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 void setNormalizeAttributes(boolean v)
public boolean getNormalizeAttributes()
public java.lang.String normalizeAttributesTipText()
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 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 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 |