Documentation
¶
Index ¶
- Variables
- func AvgFunc(aix, bix []int, ntot int, maxd float64, dmat tensor.Tensor) float64
- func Call(funcName string, aix, bix []int, ntot int, maxd float64, dmat tensor.Tensor) float64
- func ContrastFunc(aix, bix []int, ntot int, maxd float64, dmat tensor.Tensor) float64
- func MaxFunc(aix, bix []int, ntot int, maxd float64, dmat tensor.Tensor) float64
- func MinFunc(aix, bix []int, ntot int, maxd float64, dmat tensor.Tensor) float64
- func Plot(pt *table.Table, root *Node, dmat, labels tensor.Tensor)
- type MetricFunc
- type Metrics
- func (i Metrics) Desc() string
- func (i Metrics) Int64() int64
- func (i Metrics) MarshalText() ([]byte, error)
- func (i *Metrics) SetInt64(in int64)
- func (i *Metrics) SetString(s string) error
- func (i Metrics) String() string
- func (i *Metrics) UnmarshalText(text []byte) error
- func (i Metrics) Values() []enums.Enum
- type Node
Constants ¶
This section is empty.
Variables ¶
var Funcs map[string]MetricFunc
Funcs is a registry of clustering metric functions, initialized with the standard options.
Functions ¶
func AvgFunc ¶
AvgFunc is the average-distance or average-linkage weighting function for comparing two clusters a and b, given by their list of indexes. ntot is total number of nodes, and dmat is the square similarity matrix [ntot x ntot].
func ContrastFunc ¶
ContrastFunc computes maxd + (average within distance - average between distance) for two clusters a and b, given by their list of indexes. avg between is average distance between all items in a & b versus all outside that. ntot is total number of nodes, and dmat is the square similarity matrix [ntot x ntot]. maxd is the maximum distance and is needed to ensure distances are positive.
func MaxFunc ¶
MaxFunc is the maximum-distance or complete-linkage weighting function for comparing two clusters a and b, given by their list of indexes. ntot is total number of nodes, and dmat is the square similarity matrix [ntot x ntot].
func MinFunc ¶
MinFunc is the minimum-distance or single-linkage weighting function for comparing two clusters a and b, given by their list of indexes. ntot is total number of nodes, and dmat is the square similarity matrix [ntot x ntot].
Types ¶
type MetricFunc ¶
MetricFunc is a clustering distance metric function that evaluates aggregate distance between nodes, given the indexes of leaves in a and b clusters which are indexs into an ntot x ntot distance matrix dmat. maxd is the maximum distance value in the dmat, which is needed by the ContrastDist function and perhaps others.
type Metrics ¶
type Metrics int32 //enums:enum
Metrics are standard clustering distance metric functions, specifying how a node computes its distance based on its leaves.
const ( // Min is the minimum-distance or single-linkage weighting function. Min Metrics = iota // Max is the maximum-distance or complete-linkage weighting function. Max // Avg is the average-distance or average-linkage weighting function. Avg // Contrast computes maxd + (average within distance - average between distance). Contrast )
const MetricsN Metrics = 4
MetricsN is the highest valid value for type Metrics, plus one.
func MetricsValues ¶
func MetricsValues() []Metrics
MetricsValues returns all possible values for the type Metrics.
func (Metrics) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Metrics) SetString ¶
SetString sets the Metrics value from its string representation, and returns an error if the string is invalid.
func (*Metrics) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Node ¶
type Node struct { // index into original distance matrix; only valid for for terminal leaves. Index int // Distance value for this node, i.e., how far apart were all the kids from // each other when this node was created. is 0 for leaf nodes Dist float64 // ParDist is total aggregate distance from parents; The X axis offset at which our cluster starts. ParDist float64 // Y is y-axis value for this node; if a parent, it is the average of its kids Y's, // otherwise it counts down. Y float64 // Kids are child nodes under this one. Kids []*Node }
Node is one node in the cluster
func Cluster ¶
Cluster implements agglomerative clustering, based on a distance matrix dmat, e.g., as computed by metric.Matrix method, using a metric that increases in value with greater dissimilarity. labels provides an optional String tensor list of labels for the elements of the distance matrix. This calls InitAllLeaves to initialize the root node with all of the leaves, and then Glom to do the iterative agglomerative clustering process. If you want to start with pre-defined initial clusters, then call Glom with a root node so-initialized.
func Glom ¶
Glom does the iterative agglomerative clustering, based on a raw similarity matrix as given, using a root node that has already been initialized with the starting clusters, which is all of the leaves by default, but could be anything if you want to start with predefined clusters.
func InitAllLeaves ¶
InitAllLeaves returns a standard root node initialized with all of the leaves.
func (*Node) Plot ¶
Plot sets the rows of given data table to trace out lines with labels that will render this node in a cluster plot when plotted with a standard plotting package. The lines double-back on themselves to form a continuous line to be plotted.
func (*Node) SetParDist ¶
SetParDist sets the parent distance for the nodes in preparation for plotting.