Class KmeansSampling<I extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance & org.apache.commons.math3.ml.clustering.Clusterable,​D extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<I>>

  • All Implemented Interfaces:
    java.lang.Iterable<org.api4.java.algorithm.events.IAlgorithmEvent>, java.util.concurrent.Callable<D>, java.util.Iterator<org.api4.java.algorithm.events.IAlgorithmEvent>, org.api4.java.ai.ml.core.filter.unsupervised.sampling.ISamplingAlgorithm<D>, org.api4.java.algorithm.IAlgorithm<D,​D>, org.api4.java.common.control.ICancelable, org.api4.java.common.control.ILoggingCustomizable, org.api4.java.common.event.IEventEmitter<java.lang.Object>, org.api4.java.common.event.IRelaxedEventEmitter

    public class KmeansSampling<I extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance & org.apache.commons.math3.ml.clustering.Clusterable,​D extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<I>>
    extends ClusterSampling<I,​D>
    Implementation of a sampling method using kmeans-clustering. This algorithm produces clusters of the given points and checks weather all points in a cluster have the same target Attribute. If yes only the point nearest to the center is added, otherwise the whole cluster is added to the sample.

    Caution: This does ignore the given sample size!

    • Constructor Summary

      Constructors 
      Constructor Description
      KmeansSampling​(int maxIterations, long seed, int k, org.apache.commons.math3.ml.distance.DistanceMeasure dist, D input)
      Implementation of a sampling method using kmeans-clustering.
      KmeansSampling​(int maxIterations, long seed, org.apache.commons.math3.ml.distance.DistanceMeasure dist, D input)
      Implementation of a sampling method using kmeans-clustering.
      KmeansSampling​(long seed, int k, int maxIterations, D input)
      Implementation of a sampling method using kmeans-clustering.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.api4.java.algorithm.events.IAlgorithmEvent nextWithException()  
      • Methods inherited from class ai.libs.jaicore.basic.algorithm.AAlgorithm

        activate, announceTimeoutDetected, avoidReinterruptionOnShutdownOnCurrentThread, cancel, checkAndConductTermination, checkTermination, computeTimeoutAware, getActivationTime, getConfig, getDeadline, getId, getInput, getListeners, getNumCPUs, getRemainingTimeToDeadline, getState, getTimeout, getTimeoutPrecautionOffset, hasNext, hasThreadBeenInterruptedDuringShutdown, interruptThreadAsPartOfShutdown, isCanceled, isShutdownInitialized, isStopCriterionSatisfied, isTimeoutDefined, isTimeouted, iterator, next, post, registerActiveThread, registerListener, resolveShutdownInterruptOnCurrentThread, setConfig, setDeadline, setMaxNumThreads, setNumCPUs, setState, setTimeout, setTimeout, setTimeoutPrecautionOffset, shutdown, terminate, unregisterActiveThread, unregisterThreadAndShutdown
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.api4.java.algorithm.IAlgorithm

        getConfig, getId, getInput, getNumCPUs, getTimeout, registerListener, setMaxNumThreads, setNumCPUs, setTimeout, setTimeout
      • Methods inherited from interface org.api4.java.common.control.ICancelable

        cancel
      • Methods inherited from interface java.lang.Iterable

        forEach, iterator, spliterator
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, hasNext, next, remove
    • Constructor Detail

      • KmeansSampling

        public KmeansSampling​(long seed,
                              int k,
                              int maxIterations,
                              D input)
        Implementation of a sampling method using kmeans-clustering.
        Parameters:
        seed - RAndom Seed
        k - number of clusters
      • KmeansSampling

        public KmeansSampling​(int maxIterations,
                              long seed,
                              org.apache.commons.math3.ml.distance.DistanceMeasure dist,
                              D input)
        Implementation of a sampling method using kmeans-clustering. The sample size will be used as the number of clusters.
        Parameters:
        seed - Random Seed
        dist - DistanceMeasure to be used
      • KmeansSampling

        public KmeansSampling​(int maxIterations,
                              long seed,
                              int k,
                              org.apache.commons.math3.ml.distance.DistanceMeasure dist,
                              D input)
        Implementation of a sampling method using kmeans-clustering.
        Parameters:
        seed - Random Seed
        k - number of clusters
        dist - DistanceMeasure to be used
    • Method Detail

      • nextWithException

        public org.api4.java.algorithm.events.IAlgorithmEvent nextWithException()
                                                                         throws org.api4.java.algorithm.exceptions.AlgorithmException,
                                                                                java.lang.InterruptedException,
                                                                                org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException,
                                                                                org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException
        Throws:
        org.api4.java.algorithm.exceptions.AlgorithmException
        java.lang.InterruptedException
        org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
        org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException