|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.rules.NNge
NNge classifier. Nearest neighbor like algorithm using non-nested generalized exemplars. For more information, see
Brent Martin, (1995) "Instance-Based learning : Nearest Neighbor With Generalization", Master Thesis, University of Waikato, Hamilton, New Zealand
Sylvain Roy (2002) "Nearest Neighbor With Generalization", Unpublished, University of Canterbury, Christchurch, New Zealand
Valid options are:
-I num
Set the number of folder to use in the computing of the mutual information
(default 5)
-G num
Set the number of attempts of generalisation
(default 5)
Nested Class Summary | |
private class |
NNge.Exemplar
Implements Exemplar as used by NNge : parallel axis hyperrectangle. |
Field Summary | |
private NNge.Exemplar |
m_Exemplars
The list of Exemplars |
private NNge.Exemplar[] |
m_ExemplarsByClass
The lists of Exemplars by class |
(package private) double[] |
m_MaxArray
The maximum values for numeric attributes. |
private double[] |
m_MI
|
private double[] |
m_MI_MaxArray
|
private double[] |
m_MI_MinArray
|
private int[][][] |
m_MI_NumAttrClassInter
MUTUAL INFORMATION'S DATAS |
private int[][][] |
m_MI_NumAttrClassValue
|
private int[][] |
m_MI_NumAttrInter
|
private int[][] |
m_MI_NumAttrValue
|
private int[] |
m_MI_NumClass
|
private int |
m_MI_NumInst
|
(package private) double[] |
m_MinArray
The minimum values for numeric attributes. |
private double[] |
m_MissingVector
Values to use for missing value |
private int |
m_NumAttemptsOfGene
The number of try for generalisation |
private int |
m_NumFoldersMI
The number of folder for the Mutual Information |
private Instances |
m_Train
An empty instances to keep the headers, the classIndex, etc... |
Fields inherited from class weka.classifiers.Classifier |
m_Debug |
Constructor Summary | |
NNge()
|
Method Summary | |
private void |
addExemplar(NNge.Exemplar ex)
Adds an Exemplar in NNge's lists Ensure that the exemplar is not already in a list : the links would be broken... |
private void |
adjust(Instance newInst,
NNge.Exemplar predictedExemplar)
Adjust the NNge. |
private double |
attrWeight(int index)
returns the weight of indexth attribute |
void |
buildClassifier(Instances data)
Generates a classifier. |
double |
classifyInstance(Instance instance)
Classifies a given instance. |
private boolean |
detectOverlapping(NNge.Exemplar ex)
Returns true if ex overlaps any of the Exemplars in NNge's lists |
private void |
generalise(Instance newInst)
Generalise an Exemplar (not necessarily predictedExemplar) to match instance. |
int |
getNumAttemptsOfGeneOption()
Gets the number of attempts for generalisation. |
int |
getNumFoldersMIOption()
Gets the number of folder for mutual information. |
java.lang.String[] |
getOptions()
Gets the current option settings for the OptionHandler. |
java.lang.String |
globalInfo()
Returns a string describing classifier |
private void |
initWeight(NNge.Exemplar ex)
Init the weight of ex Watch out ! |
java.util.Enumeration |
listOptions()
Returns an enumeration of all the available options.. |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
private NNge.Exemplar |
nearestExemplar(Instance inst)
Returns the nearest Exemplar |
private NNge.Exemplar |
nearestExemplar(Instance inst,
double c)
Returns the nearest Exemplar with class c |
private boolean |
notEqualFeatures(Instance inst1,
Instance inst2)
Returns true if the instance don't have the same feature values |
java.lang.String |
numAttemptsOfGeneOptionTipText()
Returns the tip text for this property |
java.lang.String |
numFoldersMIOptionTipText()
Returns the tip text for this property |
private void |
prune(NNge.Exemplar predictedExemplar,
Instance newInst)
Prunes an Exemplar that matches an Instance |
private void |
removeExemplar(NNge.Exemplar ex)
Removes an Exemplar from NNge's lists Ensure that the Exemplar is actually in NNge's lists. |
void |
setNumAttemptsOfGeneOption(int newIntParameter)
Sets the number of attempts for generalisation. |
void |
setNumFoldersMIOption(int newIntParameter)
Sets the number of folder for mutual information. |
void |
setOptions(java.lang.String[] options)
Sets the OptionHandler's options using the given list. |
java.lang.String |
toString()
Returns a description of this classifier. |
private void |
update(Instance instance)
Performs the update of the classifier |
void |
updateClassifier(Instance instance)
Updates the classifier using the given instance. |
private void |
updateMI(Instance inst)
Updates the data for computing the mutual information MUST be called AFTER adding inst in m_Train |
private void |
updateMinMax(Instance instance)
Updates the minimum, maximum, sum, sumSquare values for all the attributes |
Methods inherited from class weka.classifiers.Classifier |
debugTipText, distributionForInstance, forName, getDebug, makeCopies, setDebug |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private Instances m_Train
private NNge.Exemplar m_Exemplars
private NNge.Exemplar[] m_ExemplarsByClass
double[] m_MinArray
double[] m_MaxArray
private int m_NumAttemptsOfGene
private int m_NumFoldersMI
private double[] m_MissingVector
private int[][][] m_MI_NumAttrClassInter
private int[][] m_MI_NumAttrInter
private double[] m_MI_MaxArray
private double[] m_MI_MinArray
private int[][][] m_MI_NumAttrClassValue
private int[][] m_MI_NumAttrValue
private int[] m_MI_NumClass
private int m_MI_NumInst
private double[] m_MI
Constructor Detail |
public NNge()
Method Detail |
public java.lang.String globalInfo()
public void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier
in class Classifier
data
- set of instances serving as training data
java.lang.Exception
- if the classifier has not been
generated successfullypublic double classifyInstance(Instance instance) throws java.lang.Exception
classifyInstance
in class Classifier
instance
- the instance to be classified
java.lang.Exception
- if instance could not be classified
successfullypublic void updateClassifier(Instance instance) throws java.lang.Exception
updateClassifier
in interface UpdateableClassifier
instance
- the instance to include
java.lang.Exception
- if instance could not be incorporated
successfullyprivate void update(Instance instance) throws java.lang.Exception
instance
- the new instance
java.lang.Exception
- if the update failsprivate NNge.Exemplar nearestExemplar(Instance inst)
inst
- an Instance
private NNge.Exemplar nearestExemplar(Instance inst, double c)
inst
- an Instancec
- the class of the Exemplar to return
private void generalise(Instance newInst) throws java.lang.Exception
newInst
- the new instance
java.lang.Exception
- in case of inconsitent situationprivate void adjust(Instance newInst, NNge.Exemplar predictedExemplar) throws java.lang.Exception
newInst
- the instance to classifypredictedExemplar
- the Exemplar that matches newInst
java.lang.Exception
- in case of inconsistent situationprivate void prune(NNge.Exemplar predictedExemplar, Instance newInst) throws java.lang.Exception
predictedExemplar
- an ExemplarnewInst
- an Instance matched by predictedExemplar
java.lang.Exception
- in case of inconsistent situation. (shouldn't happen.)private boolean notEqualFeatures(Instance inst1, Instance inst2)
inst1
- an instanceinst2
- an instance
private boolean detectOverlapping(NNge.Exemplar ex)
ex
- an Exemplars
private void updateMinMax(Instance instance)
instance
- the new instanceprivate void updateMI(Instance inst) throws java.lang.Exception
java.lang.Exception
- is thrown if an inconsistent situation is metprivate void initWeight(NNge.Exemplar ex)
ex
- the Exemplar to initialiseprivate void addExemplar(NNge.Exemplar ex)
ex
- a new Exemplar to addprivate void removeExemplar(NNge.Exemplar ex)
ex
- a new Exemplar to addprivate double attrWeight(int index)
index
- attribute's index
public java.lang.String toString()
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Classifier
public void setOptions(java.lang.String[] options) throws java.lang.Exception
setOptions
in interface OptionHandler
setOptions
in class Classifier
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
getOptions
in class Classifier
public java.lang.String numAttemptsOfGeneOptionTipText()
public int getNumAttemptsOfGeneOption()
public void setNumAttemptsOfGeneOption(int newIntParameter)
newIntParameter
- the new value.public java.lang.String numFoldersMIOptionTipText()
public int getNumFoldersMIOption()
public void setNumFoldersMIOption(int newIntParameter)
newIntParameter
- the new value.public static void main(java.lang.String[] argv)
argv
- should contain command line arguments for evaluation
(see Evaluation).
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |