def centerFrames( self ): """ Get indices for frame nearest to each cluster center. @return: list of cluster center indecies @rtype: [int] """ return N0.argmax( self.memberships(), 1 )
def argmax( self, key ): """ @param key: item attribute @type key: any @return: index of item with highest item[key] value @rtype: int """ vLst = self.valuesOf( key ) return N0.argmax( vLst )
def argmax(self, infoKey): """ Get index of complex c with highest c.infos[infokey] value @param infoKey: key for info dict @type infoKey: str @return: index of complex c with highest c.infos[infokey] value @rtype: int """ vLst = self.valuesOf(infoKey) return N0.argmax(vLst)
def argmax( self, infoKey ): """ Get index of complex c with highest c.infos[infokey] value @param infoKey: key for info dict @type infoKey: str @return: index of complex c with highest c.infos[infokey] value @rtype: int """ vLst = self.valuesOf( infoKey ) return N0.argmax( vLst )
def memberFrames(self, threshold=0.): """ Get indices of all frames belonging to each cluster. Each frame is guaranteed to belong, at least, to the cluster for which it has its maximum membership. If threshold > 0, it can additionally pop up in other clusters. @param threshold: minimal cluster membership or 0 to consider only max membership (default: 0) @type threshold: float @return: n_cluster, lst of lst of int, frame indices @rtype: [[int]] """ ## best cluster for each frame msm = self.memberships() maxMemb = N0.argmax(msm, 0) r = [ N0.nonzero(N0.equal(maxMemb, i)) for i in range(0, self.n_clusters) ] r = [x.tolist() for x in r] ## same thing but now taking all above threshold ## -> same frame can end up in several clusters if threshold > 0.: r2 = [N0.nonzero(N0.greater(l, threshold)) for l in msm] ## add only additional frames for i in range(0, len(r)): try: frames = r[i].tolist() except: frames = r[i] r[i] = frames + [fr for fr in r2[i] if fr not in r[i]] ## sort frames within each cluster by their membership r = [self.membershipSort(r[i], i) for i in range(0, len(r))] return r
def memberFrames( self, threshold=0. ): """ Get indices of all frames belonging to each cluster. Each frame is guaranteed to belong, at least, to the cluster for which it has its maximum membership. If threshold > 0, it can additionally pop up in other clusters. @param threshold: minimal cluster membership or 0 to consider only max membership (default: 0) @type threshold: float @return: n_cluster, lst of lst of int, frame indices @rtype: [[int]] """ ## best cluster for each frame msm = self.memberships() maxMemb = N0.argmax( msm, 0 ) r = [N0.nonzero( N0.equal(maxMemb, i) ) for i in range(0, self.n_clusters)] r = [ x.tolist() for x in r ] ## same thing but now taking all above threshold ## -> same frame can end up in several clusters if threshold > 0.: r2 = [ N0.nonzero( N0.greater( l, threshold) ) for l in msm ] ## add only additional frames for i in range(0, len( r ) ): try: frames = r[i].tolist() except: frames = r[i] r[i] = frames + [ fr for fr in r2[i] if fr not in r[i] ] ## sort frames within each cluster by their membership r = [ self.membershipSort( r[i], i) for i in range(0, len(r) )] return r