コード例 #1
0
    def testBlobs(self):
        no_of_clusters = 4

        # Create the dataset
        X, y = make_blobs(n_samples=500,
                          centers=no_of_clusters,
                          n_features=2,
                          random_state=185)

        # Run the clustering algorithm but first run a sequential algorithm to obtain initial centroids
        clustered_data, centroids, total_clusters = BSAS.basic_sequential_scheme(
            X)
        X, centroids, centroids_history = kmeans_clustering.kmeans(
            X, no_of_clusters, centroids_initial=centroids)

        # Plotting
        plot_data(X, no_of_clusters, centroids, centroids_history)

        # Examine Cluster Validity with statistical tests
        initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(
            X, no_of_clusters, kmeans_clustering.kmeans)
        initial_indices, list_of_indices, result_list = external_criteria.external_validity(
            X, no_of_clusters, y, kmeans_clustering.kmeans)

        # Histogram of gammas from internal criteria
        hist_internal_criteria(initial_gamma, list_of_gammas, result)
        hist_external_criteria(initial_indices, list_of_indices, result_list)

        plt.show()
コード例 #2
0
    def testMoons(self):
        no_of_clusters = 2

        # Create the dataset
        X, y = make_moons(n_samples=300,
                          shuffle=True,
                          noise=0.1,
                          random_state=10)

        # Run the clustering algorithm
        X, centroids, centroids_history = kmeans_clustering.kmeans(
            X, no_of_clusters)

        # Plotting
        plot_data(X, no_of_clusters, centroids, centroids_history)

        # Examine Cluster Validity with statistical tests
        initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(
            X, no_of_clusters, kmeans_clustering.kmeans)
        initial_indices, list_of_indices, result_list = external_criteria.external_validity(
            X, no_of_clusters, y, kmeans_clustering.kmeans)

        # Histogram of gammas from internal and external criteria
        hist_internal_criteria(initial_gamma, list_of_gammas, result)
        hist_external_criteria(initial_indices, list_of_indices, result_list)

        plt.show()
コード例 #3
0
    def testMoons(self):
        # Create the dataset
        X, y = make_moons(n_samples=500,
                          shuffle=True,
                          noise=0.1,
                          random_state=121)

        # Run the clustering algorithm
        X, centroids, no_of_clusters = BSAS.basic_sequential_scheme(
            X, threshold=1)

        # Plotting
        plot_data(X, no_of_clusters, centroids)

        # Examine Cluster Validity with statistical tests
        initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(
            X, no_of_clusters, BSAS.basic_sequential_scheme)
        initial_indices, list_of_indices, result_list = external_criteria.external_validity(
            X, no_of_clusters, y, BSAS.basic_sequential_scheme)

        # Histogram of gammas from internal and external criteria
        hist_internal_criteria(initial_gamma, list_of_gammas, result)
        hist_external_criteria(initial_indices, list_of_indices, result_list)

        plt.show()
コード例 #4
0
    def testBlobs(self):
        no_of_clusters = 4

        # Create the dataset
        X, y = make_blobs(n_samples=500,
                          centers=no_of_clusters,
                          n_features=2,
                          random_state=352)

        # Run the clustering algorithm but first run a sequential algorithm to obtain initial centroids
        X_, no_of_clusters = DTA.minimum_spanning_tree_variation(X)

        # Plotting
        plot_data(X_, no_of_clusters)

        # Examine Cluster Validity with statistical tests
        initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(
            X_, no_of_clusters, DTA.minimum_spanning_tree_variation)
        initial_indices, list_of_indices, result_list = external_criteria.external_validity(
            X_, no_of_clusters, y, DTA.minimum_spanning_tree_variation)

        # Histogram of gammas from internal criteria
        hist_internal_criteria(initial_gamma, list_of_gammas, result)
        hist_external_criteria(initial_indices, list_of_indices, result_list)

        plt.show()
コード例 #5
0
    def testCircles(self):
        # Create the dataset
        X, y = make_circles(n_samples=500,
                            shuffle=True,
                            noise=0.07,
                            factor=0.27,
                            random_state=107)

        # Run the clustering algorithm
        X, no_of_clusters = DTA.minimum_spanning_tree_variation(X)

        # Plotting
        plot_data(X, no_of_clusters)

        # Examine Cluster Validity with statistical tests
        initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(
            X, no_of_clusters, DTA.minimum_spanning_tree_variation)
        initial_indices, list_of_indices, result_list = external_criteria.external_validity(
            X, no_of_clusters, y, DTA.minimum_spanning_tree_variation)

        # Histogram of gammas from internal and external criteria
        hist_internal_criteria(initial_gamma, list_of_gammas, result)
        hist_external_criteria(initial_indices, list_of_indices, result_list)

        plt.show()
コード例 #6
0
    def testMoons(self):
        # Create the dataset
        X, y = make_moons(n_samples=300,
                          shuffle=True,
                          noise=0.05,
                          random_state=10)

        # Run the clustering algorithm
        clusters_number_to_execute = 2
        X, centroids, ita, centroids_history, partition_matrix = fuzzy_clustering.fuzzy(
            X, no_of_clusters=clusters_number_to_execute)

        # Plotting
        plot_data(X, clusters_number_to_execute, centroids, centroids_history)

        # Examine Cluster Validity with statistical tests
        initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(
            X, clusters_number_to_execute, fuzzy_clustering.fuzzy)
        initial_indices, list_of_indices, result_list = external_criteria.external_validity(
            X, clusters_number_to_execute, y, fuzzy_clustering.fuzzy)

        # Histogram of gammas from internal and external criteria
        hist_internal_criteria(initial_gamma, list_of_gammas, result)
        hist_external_criteria(initial_indices, list_of_indices, result_list)

        plt.show()
コード例 #7
0
    def testBlobs(self):
        no_of_clusters = 4

        # Create the dataset
        X, y = make_blobs(n_samples=500,
                          centers=no_of_clusters,
                          n_features=2,
                          random_state=46)

        # Run the clustering algorithm
        clusters_number_to_execute = 4
        X, centroids, ita, centroids_history, partition_matrix = fuzzy_clustering.fuzzy(
            X, no_of_clusters=clusters_number_to_execute)

        # Plotting
        plot_data(X, clusters_number_to_execute, centroids, centroids_history)

        # Examine Cluster Validity with statistical tests
        initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(
            X, clusters_number_to_execute, fuzzy_clustering.fuzzy)
        initial_indices, list_of_indices, result_list = external_criteria.external_validity(
            X, clusters_number_to_execute, y, fuzzy_clustering.fuzzy)

        # Histogram of gammas from internal criteria
        hist_internal_criteria(initial_gamma, list_of_gammas, result)
        hist_external_criteria(initial_indices, list_of_indices, result_list)

        plt.show()
コード例 #8
0
    def testMoons(self):
        no_of_clusters = 2

        # Create the dataset
        X, y = make_moons(n_samples=300,
                          shuffle=True,
                          noise=0.1,
                          random_state=10)

        # Run the clustering algorithm
        X_, centroids, ita, centroids_history, partition_matrix = fuzzy_clustering.fuzzy(
            X, no_of_clusters)
        X, centroids, centroids_history, typicality_matrix = possibilistic_clustering.possibilistic(
            X, no_of_clusters, ita, centroids_initial=centroids)

        # Plotting
        plot_data(X, centroids, no_of_clusters, centroids_history)

        # Examine Cluster Validity with statistical tests
        initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(
            X, no_of_clusters, possibilistic_clustering.possibilistic)
        initial_indices, list_of_indices, result_list = external_criteria.external_validity(
            X, no_of_clusters, y, possibilistic_clustering.possibilistic)

        # Histogram of gammas from internal and external criteria
        hist_internal_criteria(initial_gamma, list_of_gammas, result)
        hist_external_criteria(initial_indices, list_of_indices, result_list)

        plt.show()
コード例 #9
0
    def testBlobs(self):
        no_of_clusters = 4

        # Create the dataset
        X, y = make_blobs(n_samples=500,
                          centers=no_of_clusters,
                          n_features=2,
                          random_state=124)

        # Run the clustering algorithm
        X, centroids, no_of_clusters = TTSS.two_threshold_sequential_scheme(
            X, threshold1=3.20, threshold2=3.55)

        # Plotting
        plot_data(X, no_of_clusters, centroids)

        # Examine Cluster Validity with statistical tests
        initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(
            X, no_of_clusters, TTSS.two_threshold_sequential_scheme)
        initial_indices, list_of_indices, result_list = external_criteria.external_validity(
            X, no_of_clusters, y, TTSS.two_threshold_sequential_scheme)

        # Histogram of gammas from internal criteria
        hist_internal_criteria(initial_gamma, list_of_gammas, result)
        hist_external_criteria(initial_indices, list_of_indices, result_list)

        plt.show()
コード例 #10
0
 def testMoons(self):
     # Create the dataset
     X, y = make_moons(n_samples=500, shuffle = True, noise = 0.07, random_state = 10)
     
     # Run the clustering algorithm
     X, no_of_clusters = MST.minimum_spanning_tree(X, k = 3, f = 2.7)
     
     # Plotting
     plot_data(X, no_of_clusters)
     
     # Examine Cluster Validity with statistical tests
     initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(X, no_of_clusters, MST.minimum_spanning_tree)
     initial_indices, list_of_indices, result_list = external_criteria.external_validity(X, no_of_clusters, y, MST.minimum_spanning_tree)
     
     # Histogram of gammas from internal and external criteria 
     hist_internal_criteria(initial_gamma, list_of_gammas, result)
     hist_external_criteria(initial_indices, list_of_indices, result_list)
     
     plt.show()
コード例 #11
0
 def testCircles(self):
     no_of_clusters = 2
     
     # Create the dataset
     X, y = make_circles(n_samples=300, shuffle = True, noise = 0.05, factor = 0.5, random_state = 10)
     
     # Run the clustering Algorithm
     X, centroids, no_of_clusters = TTSS.two_threshold_sequential_scheme(X)
     
     # Plotting
     plot_data(X, centroids, no_of_clusters)
     
     # Examine Cluster Validity with statistical tests
     initial_gamma, list_of_gammas, result = internal_criteria.internal_validity(X, no_of_clusters , TTSS.two_threshold_sequential_scheme)
     initial_indices, list_of_indices, result_list = external_criteria.external_validity(X, no_of_clusters, y, TTSS.two_threshold_sequential_scheme)
     
     # Histogram of gammas from internal and external criteria 
     hist_internal_criteria(initial_gamma, list_of_gammas, result)
     hist_external_criteria(initial_indices, list_of_indices, result_list)
     
     plt.show()