Class SAMkNN

  • All Implemented Interfaces:
    Configurable, Serializable, CapabilitiesHandler, Classifier, MultiClassClassifier, AWTRenderable, Learner<Example<Instance>>, MOAObject, OptionHandler

    public class SAMkNN
    extends AbstractClassifier
    implements MultiClassClassifier, CapabilitiesHandler
    Self Adjusting Memory (SAM) coupled with the k Nearest Neighbor classifier (kNN) .

    Valid options are:

    -k number of neighbours
    -w max instances
    -m minimum number of instances in the STM
    -p LTM size relative to max instances
    -r Recalculation of the STM error

    Author:
    Viktor Losing (vlosing@techfak.uni-bielefeld.de) Paper: "KNN Classifier with Self Adjusting Memory for Heterogeneous Concept Drift" Viktor Losing, Barbara Hammer and Heiko Wersing http://ieeexplore.ieee.org/document/7837853 PDF can be found at https://pub.uni-bielefeld.de/download/2907622/2907623 BibTex: "@INPROCEEDINGS{7837853, author={V. Losing and B. Hammer and H. Wersing}, booktitle={2016 IEEE 16th International Conference on Data Mining (ICDM)}, title={KNN Classifier with Self Adjusting Memory for Heterogeneous Concept Drift}, year={2016}, pages={291-300}, keywords={data mining;optimisation;pattern classification;Big Data;Internet of Things;KNN classifier;SAM-kNN robustness;data mining;k nearest neighbor algorithm;metaparameter optimization;nonstationary data streams;performance evaluation;self adjusting memory model;Adaptation models;Benchmark testing;Biological system modeling;Data mining;Heuristic algorithms;Prediction algorithms;Predictive models;Data streams;concept drift;data mining;kNN}, doi={10.1109/ICDM.2016.0040}, month={Dec} }"
    See Also:
    Serialized Form
    • Field Detail

      • minSTMSizeOption

        public IntOption minSTMSizeOption
      • relativeLTMSizeOption

        public FloatOption relativeLTMSizeOption
      • recalculateSTMErrorOption

        public FlagOption recalculateSTMErrorOption
    • Constructor Detail

      • SAMkNN

        public SAMkNN()
    • Method Detail

      • init

        protected void init()
      • setModelContext

        public void setModelContext​(InstancesHeader context)
        Description copied from interface: Learner
        Sets the reference to the header of the data stream. The header of the data stream is extended from WEKA Instances. This header is needed to know the number of classes and attributes
        Specified by:
        setModelContext in interface Learner<Example<Instance>>
        Overrides:
        setModelContext in class AbstractClassifier
        Parameters:
        context - the reference to the data stream header
      • 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 class AbstractClassifier
      • trainOnInstanceImpl

        public void trainOnInstanceImpl​(Instance inst)
        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 class AbstractClassifier
        Parameters:
        inst - the instance to be used for training
      • getVotesForInstance

        public double[] getVotesForInstance​(Instance inst)
        Predicts the label of a given sample by using the STM, LTM and the CM.
        Specified by:
        getVotesForInstance in interface Classifier
        Specified by:
        getVotesForInstance in class AbstractClassifier
        Parameters:
        inst - the instance to be classified
        Returns:
        an array containing the estimated membership probabilities of the test instance in each class
      • 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 class AbstractClassifier
        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 class AbstractClassifier
        Parameters:
        out - the stringbuilder to add the description
        indent - 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 interface Learner<Example<Instance>>
        Returns:
        true if the learner needs a random seed.