Class KmeansSamplingFactory<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>>
- java.lang.Object
-
- ai.libs.jaicore.ml.core.filter.sampling.inmemory.factories.ASampleAlgorithmFactory<D,KmeansSampling<I,D>>
-
- ai.libs.jaicore.ml.core.filter.sampling.inmemory.factories.KmeansSamplingFactory<I,D>
-
- All Implemented Interfaces:
IRerunnableSamplingAlgorithmFactory<D,KmeansSampling<I,D>>,ISamplingAlgorithmFactory<D,KmeansSampling<I,D>>,org.api4.java.common.reconstruction.IReconstructible
public class KmeansSamplingFactory<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 ASampleAlgorithmFactory<D,KmeansSampling<I,D>> implements IRerunnableSamplingAlgorithmFactory<D,KmeansSampling<I,D>>
-
-
Constructor Summary
Constructors Constructor Description KmeansSamplingFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KmeansSampling<I,D>getAlgorithm(int sampleSize, D inputDataset, java.util.Random random)After the necessary config is done, this method returns a fully configured instance of a sampling algorithm.voidsetClusterSeed(long clusterSeed)Set the seed the clustering will use for initialization.voidsetDistanceMeassure(org.apache.commons.math3.ml.distance.DistanceMeasure distanceMeassure)Set the distance measure for the clustering.voidsetK(int k)Set how many clusters shall be created.voidsetMaxIterations(int maxIterations)voidsetPreviousRun(KmeansSampling<I,D> previousRun)Set the previous run of the sampling algorithm, if one occurred, can be set here to get data from it.-
Methods inherited from class ai.libs.jaicore.ml.core.filter.sampling.inmemory.factories.ASampleAlgorithmFactory
addInstruction, create, getAlgorithm, getConstructionInstruction, getConstructionPlan, getRandom, getSampleSize, getSeed, setRandom, setSampleSize, setSeed
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ai.libs.jaicore.ml.core.filter.sampling.inmemory.factories.interfaces.ISamplingAlgorithmFactory
getAlgorithm
-
-
-
-
Method Detail
-
setPreviousRun
public void setPreviousRun(KmeansSampling<I,D> previousRun)
Description copied from interface:IRerunnableSamplingAlgorithmFactorySet the previous run of the sampling algorithm, if one occurred, can be set here to get data from it.- Specified by:
setPreviousRunin interfaceIRerunnableSamplingAlgorithmFactory<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>>- Parameters:
previousRun- Algorithm object of the previous of the sampling algorithm.
-
setK
public void setK(int k)
Set how many clusters shall be created. Default is the sample size;- Parameters:
k- Parameter k of k-means.
-
setClusterSeed
public void setClusterSeed(long clusterSeed)
Set the seed the clustering will use for initialization. Default is without a fix seed and the system time instead.- Parameters:
clusterSeed-
-
setDistanceMeassure
public void setDistanceMeassure(org.apache.commons.math3.ml.distance.DistanceMeasure distanceMeassure)
Set the distance measure for the clustering. Default is the Manhattan distance.- Parameters:
distanceMeassure-
-
setMaxIterations
public void setMaxIterations(int maxIterations)
-
getAlgorithm
public KmeansSampling<I,D> getAlgorithm(int sampleSize, D inputDataset, java.util.Random random)
Description copied from interface:ISamplingAlgorithmFactoryAfter the necessary config is done, this method returns a fully configured instance of a sampling algorithm.- Specified by:
getAlgorithmin interfaceISamplingAlgorithmFactory<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>>- Parameters:
sampleSize- Desired size of the sample that will be created.inputDataset- Dataset where the sample will be drawn from.random- Random object to make samples reproducible.- Returns:
- Configured sampling algorithm object.
-
-