Package org.tribuo.clustering.hdbscan
Class HdbscanTrainer
java.lang.Object
org.tribuo.clustering.hdbscan.HdbscanTrainer
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable
,com.oracle.labs.mlrg.olcut.provenance.Provenancable<TrainerProvenance>
,Trainer<ClusterID>
An HDBSCAN* trainer which generates a hierarchical, density-based clustering representation
of the supplied data.
The cluster assignments and outlier scores can be retrieved from the model after training. Outliers or noise points are assigned the label 0.
For the HDBSCAN* algorithm see:
R.J.G.B. Campello, D. Moulavi, A. Zimek and J. Sander "Hierarchical Density Estimates for Data Clustering, Visualization, and Outlier Detection", ACM Trans. on Knowledge Discovery from Data, Vol 10, 1 (July 2015), 1-51. HDBSCAN*
For this specific implementation and prediction technique, see:
G. Stewart, M. Al-Khassaweneh. "An Implementation of the HDBSCAN* Clustering Algorithm", Applied Sciences. 2022; 12(5):2405. Manuscript
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A cluster exemplar, with attributes for the point's label, outlier score and its features.static enum
Deprecated. -
Field Summary
Fields inherited from interface org.tribuo.Trainer
DEFAULT_SEED, INCREMENT_INVOCATION_COUNT
-
Constructor Summary
ConstructorDescriptionHdbscanTrainer
(int minClusterSize) Constructs an HDBSCAN* trainer with only the minClusterSize parameter.HdbscanTrainer
(int minClusterSize, int k, NeighboursQueryFactory neighboursQueryFactory) Constructs an HDBSCAN* trainer using the supplied parameters.HdbscanTrainer
(int minClusterSize, HdbscanTrainer.Distance distanceType, int k, int numThreads) Deprecated.This Constructor is deprecated in version 4.3.HdbscanTrainer
(int minClusterSize, Distance dist, int k, int numThreads, NeighboursQueryFactoryType nqFactoryType) Constructs an HDBSCAN* trainer using the supplied parameters. -
Method Summary
Modifier and TypeMethodDescriptionint
The number of times this trainer instance has had it's train method invoked.void
Used by the OLCUT configuration system, and should not be called by external code.void
setInvocationCount
(int newInvocationCount) Set the internal state of the trainer to the provided number of invocations of the train method.toString()
Trains a predictive model using the examples in the given data set.train
(Dataset<ClusterID> examples, Map<String, com.oracle.labs.mlrg.olcut.provenance.Provenance> runProvenance) Trains a predictive model using the examples in the given data set.
-
Constructor Details
-
HdbscanTrainer
public HdbscanTrainer(int minClusterSize) Constructs an HDBSCAN* trainer with only the minClusterSize parameter.- Parameters:
minClusterSize
- The minimum number of points required to form a cluster.dist
defaults toDistanceType.L2
,k
defaults tominClusterSize
,numThreads
defaults to 1 andneighboursQueryFactory
defaults toNeighboursBruteForceFactory
.
-
HdbscanTrainer
@Deprecated public HdbscanTrainer(int minClusterSize, HdbscanTrainer.Distance distanceType, int k, int numThreads) Deprecated.This Constructor is deprecated in version 4.3.Constructs an HDBSCAN* trainer using the supplied parameters.neighboursQueryFactory
defaults toNeighboursBruteForceFactory
.- Parameters:
minClusterSize
- The minimum number of points required to form a cluster.distanceType
- The distance function.k
- The number of nearest-neighbors to use in the initial density approximation.numThreads
- The number of threads.
-
HdbscanTrainer
public HdbscanTrainer(int minClusterSize, Distance dist, int k, int numThreads, NeighboursQueryFactoryType nqFactoryType) Constructs an HDBSCAN* trainer using the supplied parameters.- Parameters:
minClusterSize
- The minimum number of points required to form a cluster.dist
- The distance function.k
- The number of nearest-neighbors to use in the initial density approximation.numThreads
- The number of threads.nqFactoryType
- The nearest neighbour query implementation factory to use.
-
HdbscanTrainer
Constructs an HDBSCAN* trainer using the supplied parameters.- Parameters:
minClusterSize
- The minimum number of points required to form a cluster.k
- The number of nearest-neighbors to use in the initial density approximation.neighboursQueryFactory
- The nearest neighbour query implementation factory to use.
-
-
Method Details
-
postConfig
public void postConfig()Used by the OLCUT configuration system, and should not be called by external code.- Specified by:
postConfig
in interfacecom.oracle.labs.mlrg.olcut.config.Configurable
-
train
public HdbscanModel train(Dataset<ClusterID> examples, Map<String, com.oracle.labs.mlrg.olcut.provenance.Provenance> runProvenance) Description copied from interface:Trainer
Trains a predictive model using the examples in the given data set. -
train
Description copied from interface:Trainer
Trains a predictive model using the examples in the given data set. -
getInvocationCount
public int getInvocationCount()Description copied from interface:Trainer
The number of times this trainer instance has had it's train method invoked.This is used to determine how many times the trainer's RNG has been accessed to ensure replicability in the random number stream.
- Specified by:
getInvocationCount
in interfaceTrainer<ClusterID>
- Returns:
- The number of train invocations.
-
setInvocationCount
public void setInvocationCount(int newInvocationCount) Description copied from interface:Trainer
Set the internal state of the trainer to the provided number of invocations of the train method.This is used when reproducing a Tribuo-trained model by setting the state of the RNG to what it was at when Tribuo trained the original model by simulating invocations of the train method. This method should ALWAYS be overridden, and the default method is purely for compatibility.
In a future major release this default implementation will be removed.
- Specified by:
setInvocationCount
in interfaceTrainer<ClusterID>
- Parameters:
newInvocationCount
- the number of invocations of the train method to simulate
-
toString
-
getProvenance
- Specified by:
getProvenance
in interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<TrainerProvenance>
-
DistanceType