How to use the pyclustering.utils.read_sample function in pyclustering

To help you get started, we’ve selected a few pyclustering examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github annoviko / pyclustering / pyclustering / container / examples / kdtree_examples.py View on Github external
def template_build_visualize(sample_path):
    print("KD Tree for sample: '" + sample_path + "'");
    sample = read_sample(sample_path);
    tree_instance = kdtree(sample);
    
    kdtree_text_visualizer(tree_instance).visualize(True);
github annoviko / pyclustering / pyclustering / cluster / examples / clarans_examples.py View on Github external
def template_clustering(number_clusters, path, iterations, maxneighbors):
    sample = read_sample(path);

    clarans_instance = clarans(sample, number_clusters, iterations, maxneighbors);
    (ticks, result) = timedcall(clarans_instance.process);

    print("Sample: ", path, "\t\tExecution time: ", ticks, "\n");

    clusters = clarans_instance.get_clusters();
    draw_clusters(sample, clusters);
github annoviko / pyclustering / pyclustering / cluster / examples / agglomerative_examples.py View on Github external
def template_clustering(number_clusters, path, links):
    sample = read_sample(path)
    
    clusters_centroid_link = None
    clusters_single_link = None
    clusters_complete_link = None
    clusters_average_link = None
    
    visualizer = cluster_visualizer(len(links), len(links));
    index_canvas = 0;
    
    if (type_link.CENTROID_LINK in links):
        agglomerative_centroid_link = agglomerative(sample, number_clusters, type_link.CENTROID_LINK, True);
        
        (ticks, result) = timedcall(agglomerative_centroid_link.process);
        clusters_centroid_link = agglomerative_centroid_link.get_clusters();
        
        visualizer.append_clusters(clusters_centroid_link, sample, index_canvas);
github annoviko / pyclustering / pyclustering / nnet / examples / cnn_examples.py View on Github external
def chaotic_clustering_triangulation_sample_simple_01():
    sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE1);
    template_dynamic_cnn(len(sample), 100, sample, 3, type_conn.TRIANGULATION_DELAUNAY);
github annoviko / pyclustering / pyclustering / cluster / examples / fcm_examples.py View on Github external
def cluster_iris():
    start_centers = kmeans_plusplus_initializer(read_sample(FAMOUS_SAMPLES.SAMPLE_IRIS), 4).initialize()
    template_clustering(start_centers, FAMOUS_SAMPLES.SAMPLE_IRIS)
github annoviko / pyclustering / pyclustering / nnet / examples / cnn_examples.py View on Github external
def chaotic_clustering_sample_simple_04():
    sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE4);
    template_dynamic_cnn(len(sample), 100, sample, 5, type_conn.ALL_TO_ALL);
github annoviko / pyclustering / pyclustering / nnet / examples / cnn_examples.py View on Github external
def chaotic_clustering_sample_simple_03():
    sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE3);
    template_dynamic_cnn(len(sample), 100, sample, 10, type_conn.ALL_TO_ALL);
github annoviko / pyclustering / pyclustering / cluster / examples / syncnet_examples.py View on Github external
def template_animated_clustering(file, radius, order, expected_cluster_amount, title_animation = None):
    sample = read_sample(file);
    expected_result_obtained = False;
     
    analyser = None;
     
    while (expected_result_obtained == False):
        network = syncnet(sample, radius, initial_phases = initial_type.RANDOM_GAUSSIAN, ccore = True);
     
        analyser = network.process(order, solve_type.FAST, True);
        clusters = analyser.allocate_clusters(0.1);
     
        if (len(clusters) == expected_cluster_amount):
            print("Expected result is obtained - start rendering...")
            expected_result_obtained = True;
             
            visualizer = cluster_visualizer();
            visualizer.append_clusters(clusters, sample);
github annoviko / pyclustering / pyclustering / cluster / examples / kmedoids_examples.py View on Github external
def template_clustering(start_medoids, path, tolerance=0.25, show=True):
    sample = read_sample(path)

    metric = distance_metric(type_metric.EUCLIDEAN_SQUARE, data=sample)
    kmedoids_instance = kmedoids(sample, start_medoids, tolerance, metric=metric)
    (ticks, result) = timedcall(kmedoids_instance.process)
    
    clusters = kmedoids_instance.get_clusters()
    medoids = kmedoids_instance.get_medoids()
    print("Sample: ", path, "\t\tExecution time: ", ticks, "\n")

    if show is True:
        visualizer = cluster_visualizer(1)
        visualizer.append_clusters(clusters, sample, 0)
        visualizer.append_cluster([sample[index] for index in start_medoids], marker='*', markersize=15)
        visualizer.append_cluster(medoids, data=sample, marker='*', markersize=15)
        visualizer.show()
github annoviko / pyclustering / pyclustering / cluster / examples / kmeans_examples.py View on Github external
def cluster_iris():
    start_centers = kmeans_plusplus_initializer(read_sample(FAMOUS_SAMPLES.SAMPLE_IRIS), 4).initialize()
    template_clustering(start_centers, FAMOUS_SAMPLES.SAMPLE_IRIS)