Documentation
¶
Index ¶
- type OPTICS
- type OpticsAdapter
- func (o *OpticsAdapter) ExtractClustersWithThreshold(threshold float64) (*clustering.ClusterResult, error)
- func (o *OpticsAdapter) Fit(data clustering.Dataset) error
- func (o *OpticsAdapter) FitPredict(data clustering.Dataset) (*clustering.ClusterResult, error)
- func (o *OpticsAdapter) GetCoreDistances() []float64
- func (o *OpticsAdapter) GetOrdering() []int
- func (o *OpticsAdapter) GetParams() map[string]interface{}
- func (o *OpticsAdapter) GetReachabilityDistances() []float64
- func (o *OpticsAdapter) Predict(data clustering.Dataset) (*clustering.ClusterResult, error)
- func (o *OpticsAdapter) SetParams(params map[string]interface{}) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OPTICS ¶
type OPTICS struct { // MinPts is the minimum number of points required to form a cluster MinPts int // Epsilon is the maximum distance between two points to be considered neighbors Epsilon float64 // Ordering contains the processing order of the points Ordering []int // ReachDist contains the reachability distance for each point ReachDist []float64 // CoreDist contains the core distance for each point CoreDist []float64 }
Example ¶
// Simple dataset: two clusters data := [][]float64{ {0, 0}, {0, 1}, {1, 0}, {1, 1}, // cluster 1 {10, 10}, {10, 11}, {11, 10}, {11, 11}, // cluster 2 } minPts := 2 epsilon := 2.0 opt := New(minPts, epsilon) opt.Fit(data) fmt.Println("Ordering:", opt.Ordering) fmt.Println("Reachability distances:", opt.ReachDist) fmt.Println("Core distances:", opt.CoreDist)
Output: Ordering: [0 1 2 3 4 5 6 7] Reachability distances: [+Inf 1 1 1 +Inf 1 1 1] Core distances: [1 1 1 1 1 1 1 1]
type OpticsAdapter ¶
type OpticsAdapter struct { *OPTICS // contains filtered or unexported fields }
OpticsAdapter wraps the OPTICS algorithm to implement the clustering interfaces
func NewAdapter ¶
func NewAdapter(minPts int, epsilon float64) *OpticsAdapter
NewAdapter creates a new OPTICS adapter that implements the clustering interfaces
func (*OpticsAdapter) ExtractClustersWithThreshold ¶
func (o *OpticsAdapter) ExtractClustersWithThreshold(threshold float64) (*clustering.ClusterResult, error)
ExtractClustersWithThreshold allows extracting clusters with a custom threshold
func (*OpticsAdapter) Fit ¶
func (o *OpticsAdapter) Fit(data clustering.Dataset) error
Fit trains the clustering algorithm on the provided dataset
func (*OpticsAdapter) FitPredict ¶
func (o *OpticsAdapter) FitPredict(data clustering.Dataset) (*clustering.ClusterResult, error)
FitPredict is a convenience method that fits and predicts in one step
func (*OpticsAdapter) GetCoreDistances ¶
func (o *OpticsAdapter) GetCoreDistances() []float64
GetCoreDistances returns core distances (DensityBasedClusterer interface)
func (*OpticsAdapter) GetOrdering ¶
func (o *OpticsAdapter) GetOrdering() []int
GetOrdering returns the ordering of points (DensityBasedClusterer interface)
func (*OpticsAdapter) GetParams ¶
func (o *OpticsAdapter) GetParams() map[string]interface{}
GetParams returns the algorithm parameters
func (*OpticsAdapter) GetReachabilityDistances ¶
func (o *OpticsAdapter) GetReachabilityDistances() []float64
GetReachabilityDistances returns reachability distances (DensityBasedClusterer interface)
func (*OpticsAdapter) Predict ¶
func (o *OpticsAdapter) Predict(data clustering.Dataset) (*clustering.ClusterResult, error)
Predict returns cluster assignments for the provided data
func (*OpticsAdapter) SetParams ¶
func (o *OpticsAdapter) SetParams(params map[string]interface{}) error
SetParams sets the algorithm parameters