úÎ"ô |#      !"(c) 2015 Kai ZhangMITkai@kzhang.org experimentalportableNone  Different initialization methods%K-means++ algorithm, not implemented.oThe Forgy method randomly chooses k unique observations from the data set and uses these as the initial meansResults from running kmeansYA vector of integers (0 ~ k-1) indicating the cluster to which each point is allocated.A matrix of cluster centres.2Lloyd's algorithm, also known as K-means algorithm2Lloyd's algorithm, also known as K-means algorithm .Assign data to clusters based on KMeans result number of clusterseach row represents a pointinitial set of k centroidseach row represents a point#$   #$ None$O(1) Return the size of a dendrogram %&        %&None' nearest neighbor chain algorithm(^all update functions perform destructive updates, and hence should not be called by end userssingle linkage update formula)complete linkage update formula*average linkage update formula+weighted linkage update formula,ward linkage update formula -.'/distance matrixquery;this would be selected if it achieves the minimal distance()*+,'()*+, -.'/()*+,(c) 2015 Kai ZhangMITkai@kzhang.org experimentalportableNone3 *Different hierarchical clustering schemes.'O(n^3) Median linkage, not implemented.)O(n^3) Centroid linkage, not implemented.O(n^2) Ward's method.O(n^2) Weighted linkage.YO(n^2) Average linkage or UPGMA, $d(A,B) = frac{sum_{a in A}sum_{b in B}d(a,b)}{|A||B|}$.@O(n^2) Complete linkage, $d(A,B) = max_{a in A, b in B} d(a,b)$.>O(n^2) Single linkage, $d(A,B) = min_{a in A, b in B} d(a,b)$. Perform hierarchical clustering.!Cut a dendrogram at given height.1Return the elements of a dendrogram in pre-order. %2-dimensional drawing of a dendrogram"-compute euclidean distance between two points !"  !"   !" !"0      !"#$%&'()*+,-./0123clustering-0.1.2AI.Clustering.KMeans AI.Clustering.Hierarchical.TypesAI.Clustering.Hierarchical#AI.Clustering.Hierarchical.InternalInitializationKMeansPPForgyKMeans _clusters_centerskmeans kmeansWithdecode DistanceMat DendrogramBranchLeafSizeDistFnDistancesize!idxLinkageMedianCentroidWardWeightedAverageCompleteSinglehclustcutAtflattendrawDendrogram computeDists euclideanforgysample$fFunctorDendrogram$fBinaryDendrogramnnChainsinglecompleteaverageweightedward DistUpdateFn ActiveNodeSetnearestNeighbor