Package weka.attributeSelection
Class ReliefFAttributeEval
- java.lang.Object
-
- weka.attributeSelection.ASEvaluation
-
- weka.attributeSelection.ReliefFAttributeEval
-
- All Implemented Interfaces:
java.io.Serializable,AttributeEvaluator,CapabilitiesHandler,OptionHandler,RevisionHandler,TechnicalInformationHandler
public class ReliefFAttributeEval extends ASEvaluation implements AttributeEvaluator, OptionHandler, TechnicalInformationHandler
ReliefFAttributeEval :
Evaluates the worth of an attribute by repeatedly sampling an instance and considering the value of the given attribute for the nearest instance of the same and different class. Can operate on both discrete and continuous class data.
For more information see:
Kenji Kira, Larry A. Rendell: A Practical Approach to Feature Selection. In: Ninth International Workshop on Machine Learning, 249-256, 1992.
Igor Kononenko: Estimating Attributes: Analysis and Extensions of RELIEF. In: European Conference on Machine Learning, 171-182, 1994.
Marko Robnik-Sikonja, Igor Kononenko: An adaptation of Relief for attribute estimation in regression. In: Fourteenth International Conference on Machine Learning, 296-304, 1997. BibTeX:@inproceedings{Kira1992, author = {Kenji Kira and Larry A. Rendell}, booktitle = {Ninth International Workshop on Machine Learning}, editor = {Derek H. Sleeman and Peter Edwards}, pages = {249-256}, publisher = {Morgan Kaufmann}, title = {A Practical Approach to Feature Selection}, year = {1992} } @inproceedings{Kononenko1994, author = {Igor Kononenko}, booktitle = {European Conference on Machine Learning}, editor = {Francesco Bergadano and Luc De Raedt}, pages = {171-182}, publisher = {Springer}, title = {Estimating Attributes: Analysis and Extensions of RELIEF}, year = {1994} } @inproceedings{Robnik-Sikonja1997, author = {Marko Robnik-Sikonja and Igor Kononenko}, booktitle = {Fourteenth International Conference on Machine Learning}, editor = {Douglas H. Fisher}, pages = {296-304}, publisher = {Morgan Kaufmann}, title = {An adaptation of Relief for attribute estimation in regression}, year = {1997} }Valid options are:-M <num instances> Specify the number of instances to sample when estimating attributes. If not specified, then all instances will be used.
-D <seed> Seed for randomly sampling instances. (Default = 1)
-K <number of neighbours> Number of nearest neighbours (k) used to estimate attribute relevances (Default = 10).
-W Weight nearest neighbours by distance
-A <num> Specify sigma value (used in an exp function to control how quickly weights for more distant instances decrease. Use in conjunction with -W. Sensible value=1/5 to 1/10 of the number of nearest neighbours. (Default = 2)
- Version:
- $Revision: 11219 $
- Author:
- Mark Hall (mhall@cs.waikato.ac.nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ReliefFAttributeEval()Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildEvaluator(Instances data)Initializes a ReliefF attribute evaluator.doubleevaluateAttribute(int attribute)Evaluates an individual attribute using ReliefF's instance based approach.CapabilitiesgetCapabilities()Returns the capabilities of this evaluator.intgetNumNeighbours()Get the number of nearest neighboursjava.lang.String[]getOptions()Gets the current settings of ReliefFAttributeEval.java.lang.StringgetRevision()Returns the revision string.intgetSampleSize()Get the number of instances used for estimating attributesintgetSeed()Get the seed used for randomly sampling instances.intgetSigma()Get the value of sigma.TechnicalInformationgetTechnicalInformation()Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.booleangetWeightByDistance()Get whether nearest neighbours are being weighted by distancejava.lang.StringglobalInfo()Returns a string describing this attribute evaluatorjava.util.EnumerationlistOptions()Returns an enumeration describing the available options.static voidmain(java.lang.String[] args)Main method for testing this class.java.lang.StringnumNeighboursTipText()Returns the tip text for this propertyint[]postProcess(int[] attributeSet)Provides a chance for a attribute evaluator to do any special post processing of the selected attribute set.java.lang.StringsampleSizeTipText()Returns the tip text for this propertyjava.lang.StringseedTipText()Returns the tip text for this propertyvoidsetNumNeighbours(int n)Set the number of nearest neighboursvoidsetOptions(java.lang.String[] options)Parses a given list of options.voidsetSampleSize(int s)Set the number of instances to sample for attribute estimationvoidsetSeed(int s)Set the random number seed for randomly sampling instances.voidsetSigma(int s)Sets the sigma value.voidsetWeightByDistance(boolean b)Set the nearest neighbour weighting methodjava.lang.StringsigmaTipText()Returns the tip text for this propertyjava.lang.StringtoString()Return a description of the ReliefF attribute evaluator.java.lang.StringweightByDistanceTipText()Returns the tip text for this property-
Methods inherited from class weka.attributeSelection.ASEvaluation
clean, forName, makeCopies
-
-
-
-
Method Detail
-
globalInfo
public java.lang.String globalInfo()
Returns a string describing this attribute evaluator- Returns:
- a description of the evaluator suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
public TechnicalInformation getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.- Specified by:
getTechnicalInformationin interfaceTechnicalInformationHandler- Returns:
- the technical information about this class
-
listOptions
public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(java.lang.String[] options) throws java.lang.ExceptionParses a given list of options. Valid options are:-M <num instances> Specify the number of instances to sample when estimating attributes. If not specified, then all instances will be used.
-D <seed> Seed for randomly sampling instances. (Default = 1)
-K <number of neighbours> Number of nearest neighbours (k) used to estimate attribute relevances (Default = 10).
-W Weight nearest neighbours by distance
-A <num> Specify sigma value (used in an exp function to control how quickly weights for more distant instances decrease. Use in conjunction with -W. Sensible value=1/5 to 1/10 of the number of nearest neighbours. (Default = 2)
- Specified by:
setOptionsin interfaceOptionHandler- Parameters:
options- the list of options as an array of strings- Throws:
java.lang.Exception- if an option is not supported
-
sigmaTipText
public java.lang.String sigmaTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setSigma
public void setSigma(int s) throws java.lang.ExceptionSets the sigma value.- Parameters:
s- the value of sigma (> 0)- Throws:
java.lang.Exception- if s is not positive
-
getSigma
public int getSigma()
Get the value of sigma.- Returns:
- the sigma value.
-
numNeighboursTipText
public java.lang.String numNeighboursTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setNumNeighbours
public void setNumNeighbours(int n)
Set the number of nearest neighbours- Parameters:
n- the number of nearest neighbours.
-
getNumNeighbours
public int getNumNeighbours()
Get the number of nearest neighbours- Returns:
- the number of nearest neighbours
-
seedTipText
public java.lang.String seedTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setSeed
public void setSeed(int s)
Set the random number seed for randomly sampling instances.- Parameters:
s- the random number seed.
-
getSeed
public int getSeed()
Get the seed used for randomly sampling instances.- Returns:
- the random number seed.
-
sampleSizeTipText
public java.lang.String sampleSizeTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setSampleSize
public void setSampleSize(int s)
Set the number of instances to sample for attribute estimation- Parameters:
s- the number of instances to sample.
-
getSampleSize
public int getSampleSize()
Get the number of instances used for estimating attributes- Returns:
- the number of instances.
-
weightByDistanceTipText
public java.lang.String weightByDistanceTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setWeightByDistance
public void setWeightByDistance(boolean b)
Set the nearest neighbour weighting method- Parameters:
b- true nearest neighbours are to be weighted by distance.
-
getWeightByDistance
public boolean getWeightByDistance()
Get whether nearest neighbours are being weighted by distance- Returns:
- m_weightByDiffernce
-
getOptions
public java.lang.String[] getOptions()
Gets the current settings of ReliefFAttributeEval.- Specified by:
getOptionsin interfaceOptionHandler- Returns:
- an array of strings suitable for passing to setOptions()
-
toString
public java.lang.String toString()
Return a description of the ReliefF attribute evaluator.- Overrides:
toStringin classjava.lang.Object- Returns:
- a description of the evaluator as a String.
-
getCapabilities
public Capabilities getCapabilities()
Returns the capabilities of this evaluator.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Overrides:
getCapabilitiesin classASEvaluation- Returns:
- the capabilities of this evaluator
- See Also:
Capabilities
-
buildEvaluator
public void buildEvaluator(Instances data) throws java.lang.Exception
Initializes a ReliefF attribute evaluator.- Specified by:
buildEvaluatorin classASEvaluation- Parameters:
data- set of instances serving as training data- Throws:
java.lang.Exception- if the evaluator has not been generated successfully
-
evaluateAttribute
public double evaluateAttribute(int attribute) throws java.lang.ExceptionEvaluates an individual attribute using ReliefF's instance based approach. The actual work is done by buildEvaluator which evaluates all features.- Specified by:
evaluateAttributein interfaceAttributeEvaluator- Parameters:
attribute- the index of the attribute to be evaluated- Returns:
- the "merit" of the attribute
- Throws:
java.lang.Exception- if the attribute could not be evaluated
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classASEvaluation- Returns:
- the revision
-
postProcess
public int[] postProcess(int[] attributeSet)
Description copied from class:ASEvaluationProvides a chance for a attribute evaluator to do any special post processing of the selected attribute set.- Overrides:
postProcessin classASEvaluation- Parameters:
attributeSet- the set of attributes found by the search- Returns:
- a possibly ranked list of postprocessed attributes
-
main
public static void main(java.lang.String[] args)
Main method for testing this class.- Parameters:
args- the options
-
-