cluster

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 11 Imported by: 0

README

Clustering Package

WIP

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Covariance

func Covariance(data [][]float64, rowvar bool) ([][]float64, error)

*

  • Covariance()
  • Helper function utilized for PCA
  • Returns covariance matrix of data
  • Rowvar utilized if variable data is arranged by row

func Eigen

func Eigen(data [][]float64) ([]float64, [][]float64, error)

*

  • Eigen()
  • Return the eigenvalues and eigenvectors of a real symmetric matrix

func Euclidean

func Euclidean(point []float64, data [][]float64) []float64

*

  • Euclidean()
  • Grabs all the euclidean distances between a point and set of points

func Float64TwoDimenToDense

func Float64TwoDimenToDense(data [][]float64) *mat.Dense

*

  • Float64TwoDimenToDense()
  • Helper function utilized for PCA
  • Return mat.Dense instance of 2D float64 slice

func Float64TwoDimenToSymDense

func Float64TwoDimenToSymDense(data [][]float64) *mat.SymDense

*

  • Float64TwoDimenToDense()
  • Helper function utilized for PCA
  • Return mat.SymDense instance of 2D float64 slice

func PCA

func PCA(data [][]float64, n int) ([][]float64, error)

*

  • PCA()
  • Performs principal component analysis on given data
  • Reduces dimensionality to n components
  • Assumes data is organized via column

func ScatterPlot2DimenData

func ScatterPlot2DimenData(data [][]float64, label []string, params []string) error

*

  • ScatterPlot2DimenData()
  • Creates a scatterplot with provided data, labels, and plot parameters
  • Params consist of output directory, title, and x/y labels

func Spectral

func Spectral(data [][]float64, radius float64) ([]string, error)

*

  • Spectral()
  • Performs spectral clustering on data and returns the label for each data point
  • Clusters data into 2 partitions
  • Radius value determines connectivity

Types

type KMeans

type KMeans struct {
	CENTROIDS    [][]float64
	CLUSTERS     int
	MAX_EPISODES int
}

*

  • KMeans struct
  • Stores centroids and number of clusters in model

func InitKMeans

func InitKMeans(n, max_eps int) *KMeans

*

  • InitKMeans()
  • Initializes KMeans model with n clusters and max_eps iterations

func (*KMeans) Evaluate

func (model *KMeans) Evaluate(data [][]float64) ([][]float64, []string, error)

*

  • Evaluate()
  • Evaluates data with trained model to perform cluster analysis
  • Returns analysis with labels for plotting
  • Throws error if model not trained

func (*KMeans) Train

func (model *KMeans) Train(data [][]float64) error

*

  • Train()
  • Generates KMeans model with training data using KMeans++ algorithm
  • Throws error if data dimensions are empty/not consistent or fail in centroid calculations

Jump to

Keyboard shortcuts

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