seg1d.algorithm.cluster

seg1d.algorithm.cluster(segGroups, segAdder=0.5, nClust=2)[source]

Clustering

Clusters segments based on correlation values

Parameters:
segGroupsn x 3 array

[ [ start index, end index, correlation ] ]

segAdderfloat, optional

0.0 to 1.0 or None If not None, the value that is added to the cluster groups to force a correlation cluster of the highest values

Returns:
n x 3 array

[start segment, end segment, correlation score of segment]

Other Parameters:
 
nClustint, optional

number of clusters to group data in (Default 2)

If nClust=0, returns segGroups

Warns:
Segment Adder value was included in final cluster.

This may mean cluster is poorly defined or Adder is too high. It is removed before being returned. However, it may be a sign of poor clustering settings as the intention of the segment adder is to force clustering of highly similar segments by creating a lower group (therefore, it should not be in the high cluster group).

See also

uniques
(input for this function)

Examples

>>> import numpy as np
>>> import seg1d.algorithm as alg
>>> x = [[7, 17, 0.90], [20, 40, 0.88], [40, 65, 0.8], [50, 65, 0.70]]
>>> alg.cluster(x)
[[7, 17, 0.9], [20, 40, 0.88], [40, 65, 0.8], [50, 65, 0.7]]
>>> alg.cluster(x,segAdder=None)
[[7, 17, 0.9], [20, 40, 0.88], [40, 65, 0.8]]
>>> alg.cluster(x,segAdder=0.85)
[[7, 17, 0.9], [20, 40, 0.88], [40, 65, 0.8]]

Note: This should raise the following warning:

UserWarning: Segment Adder value was included in final cluster.
This may mean cluster is poorly defined or Adder is too high.
>>> alg.cluster(x,nClust=3)
[[7, 17, 0.9], [20, 40, 0.88], [40, 65, 0.8]]
>>> alg.cluster(x,segAdder=None,nClust=3)
[[7, 17, 0.9], [20, 40, 0.88]]