Package moa.classifiers.meta
Class SelfOptimisingKNearestLeaves
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.classifiers.AbstractClassifier
-
- moa.classifiers.meta.SelfOptimisingKNearestLeaves
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,Classifier
,Regressor
,AWTRenderable
,Learner<Example<Instance>>
,MOAObject
,OptionHandler
public class SelfOptimisingKNearestLeaves extends AbstractClassifier implements Regressor
Implementation of Self-Optimising K Nearest Leaves.See details in:
Yibin Sun, Bernhard Pfahringer, Heitor Murilo Gomes, Albert Bifet. SOKNL: a novel way of integrating K nearest neighbours with adaptive random forest regression for data streams. In European Conference on Machine Learning and Principle and Practice of Knowledge Discovery in Databases (ECML-PKDD), 2022. https://doi.org/10.1007/s10618-022-00858-9- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
SelfOptimisingKNearestLeaves.SelfOptimisingKNearestLeavesBaseLearner
-
Field Summary
Fields Modifier and Type Field Description FlagOption
disableBackgroundLearnerOption
FlagOption
disableDriftDetectionOption
ClassOption
driftDetectionMethodOption
protected SelfOptimisingKNearestLeaves.SelfOptimisingKNearestLeavesBaseLearner[]
ensemble
IntOption
ensembleSizeOption
protected BasicRegressionPerformanceEvaluator
evaluator
protected static int
FEATURES_M
protected static int
FEATURES_PERCENT
protected static int
FEATURES_SQRT
protected static int
FEATURES_SQRT_INV
protected long
instancesSeen
IntOption
kOption
FloatOption
lambdaOption
MultiChoiceOption
mFeaturesModeOption
IntOption
mFeaturesPerTreeSizeOption
protected double[]
previousPrediction
IntOption
randomSeedOption
protected BasicRegressionPerformanceEvaluator[]
selfOptimisingEvaluators
FlagOption
selfOptimisingOption
protected int
subspaceSize
ClassOption
treeLearnerOption
ClassOption
warningDetectionMethodOption
-
Fields inherited from class moa.classifiers.AbstractClassifier
classifierRandom, modelContext, randomSeed, trainingWeightSeenByModel
-
Fields inherited from class moa.options.AbstractOptionHandler
config
-
-
Constructor Summary
Constructors Constructor Description SelfOptimisingKNearestLeaves()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.Prediction
getPredictionForInstance(Instance inst)
Gets the reference to the header of the data stream.String
getPurposeString()
Dictionary with option texts and objectsdouble[]
getVotesForInstance(Instance instance)
Predicts the class memberships for a given instance.protected void
initEnsemble(Instance 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, 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.capabilities.CapabilitiesHandler
getCapabilities
-
Methods inherited from interface moa.MOAObject
measureByteSize
-
Methods inherited from interface moa.options.OptionHandler
getCLICreationString, getOptions, prepareForUse, prepareForUse
-
-
-
-
Field Detail
-
treeLearnerOption
public ClassOption treeLearnerOption
-
ensembleSizeOption
public IntOption ensembleSizeOption
-
selfOptimisingOption
public FlagOption selfOptimisingOption
-
kOption
public IntOption kOption
-
randomSeedOption
public IntOption randomSeedOption
-
mFeaturesModeOption
public MultiChoiceOption mFeaturesModeOption
-
mFeaturesPerTreeSizeOption
public IntOption mFeaturesPerTreeSizeOption
-
lambdaOption
public FloatOption lambdaOption
-
driftDetectionMethodOption
public ClassOption driftDetectionMethodOption
-
warningDetectionMethodOption
public ClassOption warningDetectionMethodOption
-
disableDriftDetectionOption
public FlagOption disableDriftDetectionOption
-
disableBackgroundLearnerOption
public FlagOption disableBackgroundLearnerOption
-
FEATURES_M
protected static final int FEATURES_M
- See Also:
- Constant Field Values
-
FEATURES_SQRT
protected static final int FEATURES_SQRT
- See Also:
- Constant Field Values
-
FEATURES_SQRT_INV
protected static final int FEATURES_SQRT_INV
- See Also:
- Constant Field Values
-
FEATURES_PERCENT
protected static final int FEATURES_PERCENT
- See Also:
- Constant Field Values
-
ensemble
protected SelfOptimisingKNearestLeaves.SelfOptimisingKNearestLeavesBaseLearner[] ensemble
-
instancesSeen
protected long instancesSeen
-
subspaceSize
protected int subspaceSize
-
evaluator
protected BasicRegressionPerformanceEvaluator evaluator
-
selfOptimisingEvaluators
protected BasicRegressionPerformanceEvaluator[] selfOptimisingEvaluators
-
previousPrediction
protected double[] previousPrediction
-
-
Method Detail
-
getPurposeString
public String getPurposeString()
Description copied from class:AbstractOptionHandler
Dictionary with option texts and objects- Specified by:
getPurposeString
in interfaceOptionHandler
- Overrides:
getPurposeString
in classAbstractClassifier
- Returns:
- the string with the purpose of this object
-
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
-
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
-
initEnsemble
protected void initEnsemble(Instance instance)
-
getPredictionForInstance
public Prediction getPredictionForInstance(Instance inst)
Description copied from interface:Classifier
Gets the reference to the header of the data stream. The header of the data stream is extended from WEKAInstances
. This header is needed to know the number of classes and attributes- Specified by:
getPredictionForInstance
in interfaceClassifier
- Overrides:
getPredictionForInstance
in classAbstractClassifier
- Returns:
- the reference to the data stream header
-
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.
-
-