clustering

package
v0.0.0-...-16e292c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CentroidBasedClusterer

type CentroidBasedClusterer interface {
	Clusterer

	// GetCentroids returns the cluster centroids
	GetCentroids() []Point

	// GetInertia returns the within-cluster sum of squares
	GetInertia() float64
}

CentroidBasedClusterer extends Clusterer for centroid-based algorithms

type Cluster

type Cluster struct {
	Points   []int // Indices of points in the cluster
	Centroid Point // Centroid of the cluster (if applicable)
	Label    int   // Cluster label/ID
}

Cluster represents a cluster of points with their indices

type ClusterResult

type ClusterResult struct {
	Clusters []Cluster
	Labels   []int                  // Label for each point (-1 for noise)
	Metadata map[string]interface{} // Algorithm-specific metadata
}

ClusterResult contains the results of a clustering algorithm

type Clusterer

type Clusterer interface {
	// Fit trains the clustering algorithm on the provided dataset
	Fit(data Dataset) error

	// Predict returns cluster assignments for the provided data
	Predict(data Dataset) (*ClusterResult, error)

	// FitPredict is a convenience method that fits and predicts in one step
	FitPredict(data Dataset) (*ClusterResult, error)

	// GetParams returns the algorithm parameters
	GetParams() map[string]interface{}

	// SetParams sets the algorithm parameters
	SetParams(params map[string]interface{}) error
}

Clusterer is the interface that wraps the basic clustering methods

type ClusteringMetrics

type ClusteringMetrics struct {
	SilhouetteScore  float64
	DaviesBouldin    float64
	CalinskiHarabasz float64
}

ClusteringMetrics provides common evaluation metrics

func EvaluateCluster

func EvaluateCluster(data Dataset, result *ClusterResult) (*ClusteringMetrics, error)

EvaluateCluster calculates clustering quality metrics

type Dataset

type Dataset []Point

Dataset represents a collection of points

type DensityBasedClusterer

type DensityBasedClusterer interface {
	Clusterer

	// GetOrdering returns the ordering of points (for algorithms like OPTICS)
	GetOrdering() []int

	// GetReachabilityDistances returns reachability distances (for OPTICS)
	GetReachabilityDistances() []float64

	// GetCoreDistances returns core distances (for OPTICS)
	GetCoreDistances() []float64
}

DensityBasedClusterer extends Clusterer for density-based algorithms

type Point

type Point []float64

Point represents a data point in n-dimensional space

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL