Hierarchical Clustering algorithm derived from the R package ‘amap’ [Amap].
Hierarchical Cluster.
Initialize Hierarchical Cluster.
Parameters : |
|
---|
Example:
>>> import numpy as np
>>> import mlpy
>>> x = np.array([[ 1. , 1.5],
... [ 1.1, 1.8],
... [ 2. , 2.8],
... [ 3.2, 3.1],
... [ 3.4, 3.2]])
>>> hc = mlpy.HCluster()
>>> hc.compute(x)
>>> hc.ia
array([-4, -1, -3, 2])
>>> hc.ib
array([-5, -2, 1, 3])
>>> hc.heights
array([ 0.2236068 , 0.31622776, 1.4560219 , 2.94108844])
>>> hc.cut(0.5)
array([0, 0, 1, 2, 2])
Compute Hierarchical Cluster.
Parameters : |
|
---|---|
Returns : |
|
Element i of merge describes the merging of clusters at step i of the clustering. If an element j is negative, then observation -j was merged at this stage. If j is positive then the merge was with the cluster formed at the (earlier) stage j of the algorithm. Thus negative entries in merge indicate agglomerations of singletons, and positive entries indicate agglomerations of non-singletons.
Cuts the tree into several groups by specifying the cut height.
Parameters : |
|
---|---|
Returns : |
|
[Amap] | amap: Another Multidimensional Analysis Package, http://cran.r-project.org/web/packages/amap/index.html |
k-means algorithm.
Initialization.
Parameters : |
|
---|
Example:
>>> import numpy as np
>>> import mlpy
>>> x = np.array([[ 1. , 1.5],
... [ 1.1, 1.8],
... [ 2. , 2.8],
... [ 3.2, 3.1],
... [ 3.4, 3.2]])
>>> kmeans = mlpy.Kmeans(k=3, init="plus", seed=0)
>>> kmeans.compute(x)
array([1, 1, 2, 0, 0], dtype=int32)
>>> kmeans.means
array([[ 3.3 , 3.15],
[ 1.05, 1.65],
[ 2. , 2.8 ]])
>>> kmeans.steps
2
New in version 2.2.0.
Compute Kmeans.
Parameters : |
|
---|---|
Returns : |
|
Attributes : |
|
k-medoids algorithm.
Initialize Kmedoids.
Parameters : |
|
---|
Example:
>>> import numpy as np
>>> import mlpy
>>> x = np.array([[ 1. , 1.5],
... [ 1.1, 1.8],
... [ 2. , 2.8],
... [ 3.2, 3.1],
... [ 3.4, 3.2]])
>>> dtw = mlpy.Dtw(onlydist=True)
>>> km = mlpy.Kmedoids(k=3, dist=dtw)
>>> km.compute(x)
(array([4, 0, 2]), array([3, 1]), array([0, 1]), 0.072499999999999981)
Samples 4, 0, 2 are medoids and represent cluster 0, 1, 2 respectively.
- cluster 0: samples 4 (medoid) and 3
- cluster 1: samples 0 (medoid) and 1
- cluster 2: sample 2 (medoid)
New in version 2.0.8.
Compute Kmedoids.
Parameters : |
|
---|---|
Returns : |
|