コード例 #1
0
ファイル: clustering.py プロジェクト: rochoa85/treeCl
    def cluster_rotate(
        self,
        eigenvectors,
        max_groups,
        min_groups=2,
        tolerance=0.0025,
        ):

        groups = range(min_groups, max_groups + 1)
        vector_length = eigenvectors.shape[0]
        current_vector = eigenvectors[:, :groups[0]]
        n = max_groups - min_groups + 1

        quality_scores = [None] * n
        clusters = [None] * n
        rotated_vectors = [None] * n

        for g in range(n):
            if g > 0:
                current_vector = np.concatenate((rotated_vectors[g - 1],
                        eigenvectors[:, groups[g] - 1:groups[g]]), axis=1)

            (clusters[g], quality_scores[g], rotated_vectors[g]) = \
                evrot.main(current_vector)

        return (groups, clusters, quality_scores, rotated_vectors)
コード例 #2
0
ファイル: clustering.py プロジェクト: mgperry/treeCl
    def cluster_rotate(
        self,
        eigenvectors,
        max_groups,
        min_groups=2,
        tolerance=0.0025,
    ):

        groups = range(min_groups, max_groups + 1)
        vector_length = eigenvectors.shape[0]
        current_vector = eigenvectors[:, :groups[0]]
        n = max_groups - min_groups + 1

        quality_scores = [None] * n
        clusters = [None] * n
        rotated_vectors = [None] * n

        for g in range(n):
            if g > 0:
                current_vector = np.concatenate(
                    (rotated_vectors[g - 1],
                     eigenvectors[:, groups[g] - 1:groups[g]]),
                    axis=1)

            (clusters[g], quality_scores[g], rotated_vectors[g]) = \
                evrot.main(current_vector)

        # Find the highest index of quality scores where the
        # score is within 0.0025 of the maximum:
        # this is our chosen number of groups

        max_score = max(quality_scores)
        index = quality_scores.index(max_score)
        start = index + 1
        for (i, score) in enumerate(quality_scores[index + 1:], start=start):
            if abs(score - max_score) < tolerance:
                index = i

        return (groups[index], clusters[index], quality_scores,
                rotated_vectors[index])
コード例 #3
0
    def cluster_rotate(
        self,
        eigenvectors,
        max_groups,
        min_groups=2,
        ):

        groups = range(min_groups, max_groups + 1)
        vector_length = eigenvectors.shape[0]
        current_vector = eigenvectors[:, :groups[0]]
        n = max_groups - min_groups + 1

        quality_scores = [None] * n
        clusters = [None] * n
        rotated_vectors = [None] * n

        for g in range(n):
            if g > 0:
                current_vector = np.concatenate((rotated_vectors[g
                        - 1], eigenvectors[:, groups[g] - 1:
                        groups[g]]), axis=1)

            (clusters[g], quality_scores[g], rotated_vectors[g]) = \
                evrot.main(current_vector)

        # Find the highest index of quality scores where the
        # score is within 0.0025 of the maximum:
        # this is our chosen number of groups

        max_score = max(quality_scores)
        index = quality_scores.index(max_score)
        start = index + 1
        for (i, score) in enumerate(quality_scores[index + 1:],
                                    start=start):
            if abs(score - max_score) < 0.0025:
                index = i

        return (groups[index], clusters[index], quality_scores,
                rotated_vectors[index])