Denclue<T>

Models & Types · AiDotNet.Clustering.Density

DENCLUE (DENsity-based CLUstEring) implementation.

Inheritance: ClusteringBase<T> → Denclue<T>

Implements: IGeneratedParameterRegistrar<T>

For Beginners

DENCLUE is like finding mountain peaks.

The density function creates a “landscape”:

  • High-density areas are “mountains”
  • Low-density areas are “valleys”

Each point “climbs uphill” to find its nearest peak. Points reaching the same peak belong to the same cluster.

Advantages over DBSCAN:

  • Can find clusters of varying densities
  • Produces cluster centers (attractors)
  • Handles noise naturally

Best for: Smooth, well-defined clusters where density varies.

How It Works

DENCLUE uses kernel density estimation to model the overall point density, then clusters points based on the local maxima (attractors) of the density function. Points are assigned to the attractor they converge to via gradient ascent (hill climbing).

Algorithm:

  1. For each point, perform hill climbing on the density function
  2. Points converging to the same attractor form a cluster
  3. Merge attractors that are very close together
  4. Mark points with low-density attractors as noise

Example

using AiDotNet;
using AiDotNet.Data.Loaders;
using AiDotNet.Clustering.Density;
using AiDotNet.Tensors.LinearAlgebra;

var data = new Matrix<double>(6, 2);
double[][] rows = { new[] { 1.0, 1.0 }, new[] { 1.2, 0.9 }, new[] { 1.1, 1.1 },
                    new[] { 8.0, 8.0 }, new[] { 8.2, 7.9 }, new[] { 7.9, 8.1 } };
for (int i = 0; i < 6; i++) { data[i, 0] = rows[i][0]; data[i, 1] = rows[i][1]; }

var result = await new AiModelBuilder<double, Matrix<double>, Vector<double>>()
    .ConfigureModel(new Denclue<double>())
    .ConfigureDataLoader(DataLoaders.FromMatrix(data))
    .BuildAsync();

var labels = result.Predict(data);
Console.WriteLine($"Denclue: clustered {labels.Length} points.");

Constructors

Constructor Summary
Denclue(DenclueOptions<T> options) Initializes a new DENCLUE instance.

Properties

Property Summary
T[] AttractorDensities { get; } Gets the density values at each attractor.
T[][] Attractors { get; } Gets the density attractors (cluster centers).

Methods

Method Summary
IFullModel<T, Matrix<T>, Vector<T>> WithParameters(Vector<T> parameters)
ModelOptions GetOptions()
T GetDensity(Vector<T> point) Gets the density estimate at a given point.
Vector<T> FitPredict(Matrix<T> x)
Vector<T> Predict(Matrix<T> x)
void Train(Matrix<T> x, Vector<T> y)