Package moa.learners.featureanalysis
Class FeatureImportanceHoeffdingTree
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.classifiers.AbstractClassifier
-
- moa.learners.featureanalysis.FeatureImportanceHoeffdingTree
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,Classifier
,MultiClassClassifier
,AWTRenderable
,FeatureImportanceClassifier
,Learner<Example<Instance>>
,MOAObject
,OptionHandler
public class FeatureImportanceHoeffdingTree extends AbstractClassifier implements MultiClassClassifier, CapabilitiesHandler, FeatureImportanceClassifier
HoeffdingTree Feature Importance extends the traditional HoeffdingTree classifier to also yield feature importances.This class uses the HoeffdingTree structure to produce feature importances. This class does not interfere with the training algorithm of the underlying HoeffdingTree model. Any subclass of the HoeffdingTree class can be set as the treeLearnerOption.
See details in:
Heitor Murilo Gomes, Rodrigo Fernandes de Mello, Bernhard Pfahringer, Albert Bifet. Feature Scoring using Tree-Based Ensembles for Evolving Data Streams. IEEE International Conference on Big Data (pp. 761-769), 2019Parameters:
- -l : HoeffdingTree or subclass to train and to be analyzed.
- -s : The feature importance estimation metric: MDI (Mean Decrease in Impurity) and COVER.
- Version:
- $Revision: 1 $
- Author:
- Heitor Murilo Gomes (heitor dot gomes at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
FEATURE_IMPORTANCE_COVER
protected static int
FEATURE_IMPORTANCE_MDI
MultiChoiceOption
featureImportanceOption
protected double[]
featureImportances
protected int
featureImportancesInquiries
protected int
nodeCountAtLastFeatureImportanceInquiry
protected HoeffdingTree
treeLearner
ClassOption
treeLearnerOption
-
Fields inherited from class moa.classifiers.AbstractClassifier
classifierRandom, modelContext, randomSeed, randomSeedOption, trainingWeightSeenByModel
-
Fields inherited from class moa.options.AbstractOptionHandler
config
-
-
Constructor Summary
Constructors Constructor Description FeatureImportanceHoeffdingTree()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
calcNodeCover(HoeffdingTree.SplitNode splitNode)
double
calcNodeDecreaseImpurity(HoeffdingTree.SplitNode splitNode)
double[]
getFeatureImportances(boolean normalize)
Obtain the current importance for each feature.void
getModelDescription(StringBuilder out, int indent)
Returns a string representation of the model.protected Measurement[]
getModelMeasurementsImpl()
Gets the current measurements of this classifier.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods.int[]
getTopKFeatures(int k, boolean normalize)
The output is a double array where values indicates the original feature index and the order of the array its ranking.double[]
getVotesForInstance(Instance instance)
Predicts the class memberships for a given instance.boolean
isRandomizable()
Gets whether this learner needs a random seed.void
resetLearningImpl()
Resets this classifier.void
trainOnInstanceImpl(Instance instance)
Trains this classifier incrementally using the given instance.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods.-
Methods inherited from class moa.classifiers.AbstractClassifier
contextIsCompatible, copy, correctlyClassifies, defineImmutableCapabilities, getAttributeNameString, getAWTRenderer, getClassLabelString, getClassNameString, getDescription, getModel, getModelContext, getModelMeasurements, getNominalValueString, getPredictionForInstance, getPredictionForInstance, getPurposeString, getSubClassifiers, getSublearners, getVotesForInstance, modelAttIndexToInstanceAttIndex, modelAttIndexToInstanceAttIndex, prepareForUseImpl, resetLearning, setModelContext, setRandomSeed, trainingHasStarted, trainingWeightSeenByModel, trainOnInstance, trainOnInstance
-
Methods inherited from class moa.options.AbstractOptionHandler
getCLICreationString, getOptions, getPreparedClassOption, prepareClassOptions, prepareForUse, prepareForUse
-
Methods inherited from class moa.AbstractMOAObject
copy, measureByteSize, measureByteSize, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface moa.gui.AWTRenderable
getAWTRenderer
-
Methods inherited from interface moa.capabilities.CapabilitiesHandler
defineImmutableCapabilities, getCapabilities
-
Methods inherited from interface moa.classifiers.Classifier
copy, correctlyClassifies, getPredictionForInstance, getSubClassifiers, trainOnInstance
-
Methods inherited from interface moa.learners.Learner
getModel, getModelContext, getModelMeasurements, getPredictionForInstance, getSublearners, getVotesForInstance, resetLearning, setModelContext, setRandomSeed, trainingHasStarted, trainingWeightSeenByModel, trainOnInstance
-
Methods inherited from interface moa.MOAObject
getDescription, measureByteSize
-
Methods inherited from interface moa.options.OptionHandler
getCLICreationString, getOptions, getPurposeString, prepareForUse, prepareForUse
-
-
-
-
Field Detail
-
treeLearnerOption
public ClassOption treeLearnerOption
-
featureImportanceOption
public MultiChoiceOption featureImportanceOption
-
treeLearner
protected HoeffdingTree treeLearner
-
featureImportances
protected double[] featureImportances
-
nodeCountAtLastFeatureImportanceInquiry
protected int nodeCountAtLastFeatureImportanceInquiry
-
featureImportancesInquiries
protected int featureImportancesInquiries
-
FEATURE_IMPORTANCE_MDI
protected static final int FEATURE_IMPORTANCE_MDI
- See Also:
- Constant Field Values
-
FEATURE_IMPORTANCE_COVER
protected static final int FEATURE_IMPORTANCE_COVER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getFeatureImportances
public double[] getFeatureImportances(boolean normalize)
Description copied from interface:FeatureImportanceClassifier
Obtain the current importance for each feature.- Specified by:
getFeatureImportances
in interfaceFeatureImportanceClassifier
- Returns:
- array containing the importance/score estimated for each feature
-
getTopKFeatures
public int[] getTopKFeatures(int k, boolean normalize)
Description copied from interface:FeatureImportanceClassifier
The output is a double array where values indicates the original feature index and the order of the array its ranking. The size of this array is expected to be less than the complete set of features.- Specified by:
getTopKFeatures
in interfaceFeatureImportanceClassifier
- Returns:
- the k features with the highest scores.
-
calcNodeCover
public double calcNodeCover(HoeffdingTree.SplitNode splitNode)
-
calcNodeDecreaseImpurity
public double calcNodeDecreaseImpurity(HoeffdingTree.SplitNode splitNode)
-
getVotesForInstance
public double[] getVotesForInstance(Instance instance)
Description copied from interface:Classifier
Predicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero.- Specified by:
getVotesForInstance
in interfaceClassifier
- Specified by:
getVotesForInstance
in classAbstractClassifier
- Parameters:
instance
- the instance to be classified- Returns:
- an array containing the estimated membership probabilities of the test instance in each class
-
resetLearningImpl
public void resetLearningImpl()
Description copied from class:AbstractClassifier
Resets this classifier. It must be similar to starting a new classifier from scratch.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.- Specified by:
resetLearningImpl
in classAbstractClassifier
-
trainOnInstanceImpl
public void trainOnInstanceImpl(Instance instance)
Description copied from class:AbstractClassifier
Trains this classifier incrementally using the given instance.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.- Specified by:
trainOnInstanceImpl
in classAbstractClassifier
- Parameters:
instance
- the instance to be used for training
-
getModelMeasurementsImpl
protected Measurement[] getModelMeasurementsImpl()
Description copied from class:AbstractClassifier
Gets the current measurements of this classifier.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.- Specified by:
getModelMeasurementsImpl
in classAbstractClassifier
- Returns:
- an array of measurements to be used in evaluation tasks
-
getModelDescription
public void getModelDescription(StringBuilder out, int indent)
Description copied from class:AbstractClassifier
Returns a string representation of the model.- Specified by:
getModelDescription
in classAbstractClassifier
- Parameters:
out
- the stringbuilder to add the descriptionindent
- the number of characters to indent
-
isRandomizable
public boolean isRandomizable()
Description copied from interface:Learner
Gets whether this learner needs a random seed. Examples of methods that needs a random seed are bagging and boosting.- Specified by:
isRandomizable
in interfaceLearner<Example<Instance>>
- Returns:
- true if the learner needs a random seed.
-
-