cluster

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KMeansOption

type KMeansOption func(*MiniBatchKMeans)

KMeansOption is a configuration option for MiniBatchKMeans

func WithKMeansBatchSize

func WithKMeansBatchSize(batchSize int) KMeansOption

WithKMeansBatchSize sets the mini-batch size

func WithKMeansInit

func WithKMeansInit(init string) KMeansOption

WithKMeansInit sets the initialization method

func WithKMeansMaxIter

func WithKMeansMaxIter(maxIter int) KMeansOption

WithKMeansMaxIter sets the maximum number of iterations

func WithKMeansNClusters

func WithKMeansNClusters(n int) KMeansOption

WithKMeansNClusters sets the number of clusters

func WithKMeansRandomState

func WithKMeansRandomState(seed int64) KMeansOption

WithKMeansRandomState sets the random seed

func WithKMeansTol

func WithKMeansTol(tol float64) KMeansOption

WithKMeansTol sets the tolerance for convergence

type MiniBatchKMeans

type MiniBatchKMeans struct {
	// contains filtered or unexported fields
}

MiniBatchKMeans implements mini-batch K-means clustering Compatible with scikit-learn's MiniBatchKMeans

func NewMiniBatchKMeans

func NewMiniBatchKMeans(options ...KMeansOption) *MiniBatchKMeans

NewMiniBatchKMeans creates a new MiniBatchKMeans instance

func (*MiniBatchKMeans) ClusterCenters

func (kmeans *MiniBatchKMeans) ClusterCenters() [][]float64

ClusterCenters returns the learned cluster centers

func (*MiniBatchKMeans) Fit

func (kmeans *MiniBatchKMeans) Fit(X, y mat.Matrix) error

Fit trains the model using batch learning

func (*MiniBatchKMeans) FitPredict

func (kmeans *MiniBatchKMeans) FitPredict(X, y mat.Matrix) (mat.Matrix, error)

FitPredict performs training and prediction simultaneously

func (*MiniBatchKMeans) FitStream

func (kmeans *MiniBatchKMeans) FitStream(ctx context.Context, dataChan <-chan *model.Batch) error

FitStream trains the model from data stream

func (*MiniBatchKMeans) Inertia

func (kmeans *MiniBatchKMeans) Inertia() float64

Inertia returns inertia (within-cluster sum of squared errors)

func (*MiniBatchKMeans) IsWarmStart

func (kmeans *MiniBatchKMeans) IsWarmStart() bool

IsWarmStart returns whether warm start is enabled (always false)

func (*MiniBatchKMeans) Labels

func (kmeans *MiniBatchKMeans) Labels() []int

Labels returns cluster labels for training data

func (*MiniBatchKMeans) NIterations

func (kmeans *MiniBatchKMeans) NIterations() int

NIterations returns the number of training iterations performed

func (*MiniBatchKMeans) PartialFit

func (kmeans *MiniBatchKMeans) PartialFit(X, y mat.Matrix, classes []int) error

PartialFit trains the model incrementally with mini-batches

func (*MiniBatchKMeans) Predict

func (kmeans *MiniBatchKMeans) Predict(X mat.Matrix) (mat.Matrix, error)

Predict performs cluster prediction on input data

func (*MiniBatchKMeans) PredictStream

func (kmeans *MiniBatchKMeans) PredictStream(ctx context.Context, inputChan <-chan mat.Matrix) <-chan mat.Matrix

PredictStream performs real-time prediction on input stream

func (*MiniBatchKMeans) SetWarmStart

func (kmeans *MiniBatchKMeans) SetWarmStart(warmStart bool)

SetWarmStart sets warm start enable/disable (does nothing)

func (*MiniBatchKMeans) Transform

func (kmeans *MiniBatchKMeans) Transform(X mat.Matrix) (mat.Matrix, error)

Transform converts data to distances to cluster centers

Jump to

Keyboard shortcuts

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