Skip to content

Commit

Permalink
Updated pathes to samples in the modules. Added several examples rela…
Browse files Browse the repository at this point in the history
…ted to SimpleSample4 SimpleSample5
  • Loading branch information
annoviko committed Mar 24, 2014
1 parent b6747ca commit 759dd57
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 141 deletions.
39 changes: 25 additions & 14 deletions cure/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from support import draw_clusters;
from support import timedcall;

from samples.definitions import SIMPLE_SAMPLES;
from samples.definitions import FCPS_SAMPLES;

from cure import cure;

def template_clustering(number_clusters, path, number_represent_points = 5, compression = 0.5, draw = True):
Expand All @@ -17,49 +20,55 @@ def template_clustering(number_clusters, path, number_represent_points = 5, comp


def cluster_sample1():
template_clustering(2, '../samples/SampleSimple1.txt');
template_clustering(2, SIMPLE_SAMPLES.SAMPLE_SIMPLE1);

def cluster_sample2():
template_clustering(3, '../samples/SampleSimple2.txt');
template_clustering(3, SIMPLE_SAMPLES.SAMPLE_SIMPLE2);

def cluster_sample3():
template_clustering(4, '../samples/SampleSimple3.txt');
template_clustering(4, SIMPLE_SAMPLES.SAMPLE_SIMPLE3);

def cluster_sample4():
template_clustering(5, SIMPLE_SAMPLES.SAMPLE_SIMPLE4);

def cluster_sample5():
template_clustering(4, SIMPLE_SAMPLES.SAMPLE_SIMPLE5);

def cluster_elongate():
template_clustering(2, '../samples/SampleElongate.txt');
template_clustering(2, SIMPLE_SAMPLES.SAMPLE_ELONGATE);

def cluster_lsun():
template_clustering(3, '../samples/SampleLsun.txt');
template_clustering(3, FCPS_SAMPLES.SAMPLE_LSUN);

def cluster_target():
template_clustering(6, '../samples/SampleTarget.txt', 10, 0.3);
template_clustering(6, FCPS_SAMPLES.SAMPLE_TARGET, 10, 0.3);

def cluster_two_diamonds():
template_clustering(2, '../samples/SampleTwoDiamonds.txt');
template_clustering(2, FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS);

def cluster_wing_nut():
template_clustering(2, '../samples/SampleWingNut.txt', 1, 1);
template_clustering(2, FCPS_SAMPLES.SAMPLE_WING_NUT, 1, 1);

def cluster_chainlink():
template_clustering(2, '../samples/SampleChainlink.txt');
template_clustering(2, FCPS_SAMPLES.SAMPLE_CHAINLINK);

def cluster_hepta():
template_clustering(7, '../samples/SampleHepta.txt');
template_clustering(7, FCPS_SAMPLES.SAMPLE_HEPTA);

def cluster_tetra():
template_clustering(4, '../samples/SampleTetra.txt');
template_clustering(4, FCPS_SAMPLES.SAMPLE_TETRA);

def cluster_engy_time():
template_clustering(2, '../samples/SampleEngyTime.txt', 50, 0.5);
template_clustering(2, FCPS_SAMPLES.SAMPLE_ENGY_TIME, 50, 0.5);

def cluster_golf_ball():
template_clustering(1, '../samples/SampleGolfBall.txt');
template_clustering(1, FCPS_SAMPLES.SAMPLE_GOLF_BALL);

def cluster_atom():
"Impossible to obtain parameters that satisfy us, it seems to me that compression = 0.2 is key parameter here, because results of clustering doesn't depend on number of represented points, except 0."
"Thus the best parameters is following: number of points for representation: [5, 400]; compression: [0.2, 0.204]"
"Results of clustering is not so dramatically, but clusters are not allocated properly"
template_clustering(2, '../samples/SampleAtom.txt', 20, 0.2);
template_clustering(2, FCPS_SAMPLES.SAMPLE_ATOM, 20, 0.2);

def find_best_atom():
for represent in range(5, 20, 100):
Expand All @@ -73,6 +82,8 @@ def find_best_atom():
cluster_sample1();
cluster_sample2();
cluster_sample3();
cluster_sample4();
cluster_sample5();
cluster_elongate();
cluster_lsun();
cluster_target();
Expand Down
2 changes: 1 addition & 1 deletion gcolor/syncgcolor/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def template_graph_coloring(positive_weight, negative_weight, filename, reductio


def one_circle1():
template_graph_coloring(0, -1, GRAPH_SIMPLE_SAMPLES.GRAPH_ONE_CIRCLE1, None, "Circle 1");
template_graph_coloring(1, -1, GRAPH_SIMPLE_SAMPLES.GRAPH_ONE_CIRCLE1, None, "Circle 1");


def one_circle2():
Expand Down
55 changes: 30 additions & 25 deletions hsyncnet/examples.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from nnet.sync import draw_dynamics;

from support import read_sample, draw_clusters;

from samples.definitions import SIMPLE_SAMPLES;
from samples.definitions import FCPS_SAMPLES;

from hsyncnet import hsyncnet;

def template_clustering(file, number_clusters, arg_collect_dynamic = True, show_network_structure = False, arg_order = 0.999, arg_eps = 0.1):
Expand All @@ -20,59 +24,60 @@ def template_clustering(file, number_clusters, arg_collect_dynamic = True, show_


def cluster_sample1():
template_clustering('../samples/SampleSimple1.txt', 2);
template_clustering(SIMPLE_SAMPLES.SAMPLE_SIMPLE1, 2);

def cluster_sample2():
template_clustering('../samples/SampleSimple2.txt', 3);
template_clustering(SIMPLE_SAMPLES.SAMPLE_SIMPLE2, 3);

def cluster_sample3():
template_clustering('../samples/SampleSimple3.txt', 4);
template_clustering(SIMPLE_SAMPLES.SAMPLE_SIMPLE3, 4);

def cluster_simple4():
template_clustering('../samples/SampleSimple4.txt', 5);
template_clustering(SIMPLE_SAMPLES.SAMPLE_SIMPLE4, 5);

def cluster_simple5():
template_clustering('../samples/SampleSimple5.txt', 4);
template_clustering(SIMPLE_SAMPLES.SAMPLE_SIMPLE5, 4);

def cluster_elongate():
template_clustering('../samples/SampleElongate.txt', 2, arg_collect_dynamic = False);
template_clustering(SIMPLE_SAMPLES.SAMPLE_ELONGATE, 2, arg_collect_dynamic = False);

def cluster_lsun():
"NOTE: Too slow"
template_clustering('../samples/SampleLsun.txt', 3, arg_collect_dynamic = False);
template_clustering(FCPS_SAMPLES.SAMPLE_LSUN, 3, arg_collect_dynamic = False);

def cluster_hepta():
template_clustering('../samples/SampleHepta.txt', 7, arg_collect_dynamic = False);
template_clustering(FCPS_SAMPLES.SAMPLE_HEPTA, 7, arg_collect_dynamic = False);

def cluster_tetra():
"NOTE: Too slow"
template_clustering('../samples/SampleTetra.txt', 4, arg_collect_dynamic = False);
template_clustering(FCPS_SAMPLES.SAMPLE_TETRA, 4, arg_collect_dynamic = False);

def cluster_target():
"NOTE: Too slow"
template_clustering('../samples/SampleTarget.txt', 6, arg_collect_dynamic = False);
template_clustering(FCPS_SAMPLES.SAMPLE_TARGET, 6, arg_collect_dynamic = False);

def cluster_chainlink():
"NOTE: Too slow"
template_clustering('../samples/SampleChainlink.txt', 2, arg_collect_dynamic = False);
template_clustering(FCPS_SAMPLES.SAMPLE_CHAINLINK, 2, arg_collect_dynamic = False);

def cluster_wing_nut():
"NOTE: Too slow"
template_clustering('../samples/SampleWingNut.txt', 2, arg_collect_dynamic = False);
template_clustering(FCPS_SAMPLES.SAMPLE_WING_NUT, 2, arg_collect_dynamic = False);

def cluster_two_diamonds():
"NOTE: Too slow"
template_clustering('../samples/SampleTwoDiamonds.txt', 2, arg_collect_dynamic = False);
template_clustering(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS, 2, arg_collect_dynamic = False);


# cluster_sample1();
# cluster_sample2();
# cluster_sample3();
# cluster_simple4();
# cluster_elongate();
# cluster_lsun();
# cluster_hepta();
# cluster_tetra();
# cluster_target();
# cluster_chainlink();
# cluster_wing_nut();
# cluster_two_diamonds();
cluster_sample1();
cluster_sample2();
cluster_sample3();
cluster_simple4();
cluster_elongate();
cluster_lsun();
cluster_hepta();
cluster_tetra();
cluster_target();
cluster_chainlink();
cluster_wing_nut();
cluster_two_diamonds();
24 changes: 14 additions & 10 deletions hsyncnet/tests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import unittest;

from nnet.sync import initial_type;

from support import read_sample;

from hsyncnet import hsyncnet;

from samples.definitions import SIMPLE_SAMPLES;

class Test(unittest.TestCase):
def templateClusteringResults(self, path, number_clusters, expected_length_clusters):
sample = read_sample(path);
Expand All @@ -23,24 +27,24 @@ def templateClusteringResults(self, path, number_clusters, expected_length_clust
assert sorted([len(cluster) for cluster in clusters]) == expected_length_clusters;

def testClusteringSampleSimple1(self):
self.templateClusteringResults("../samples/SampleSimple1.txt", 2, [5, 5]);
self.templateClusteringResults("../samples/SampleSimple1.txt", 1, [10]);
self.templateClusteringResults(SIMPLE_SAMPLES.SAMPLE_SIMPLE1, 2, [5, 5]);
self.templateClusteringResults(SIMPLE_SAMPLES.SAMPLE_SIMPLE1, 1, [10]);

def testClusteringSampleSimple2(self):
self.templateClusteringResults("../samples/SampleSimple2.txt", 3, [5, 8, 10]);
self.templateClusteringResults("../samples/SampleSimple2.txt", 1, [23]);
self.templateClusteringResults(SIMPLE_SAMPLES.SAMPLE_SIMPLE2, 3, [5, 8, 10]);
self.templateClusteringResults(SIMPLE_SAMPLES.SAMPLE_SIMPLE2, 1, [23]);

def testClusteringSampleSimple3(self):
self.templateClusteringResults("../samples/SampleSimple3.txt", 4, [10, 10, 10, 30]);
self.templateClusteringResults("../samples/SampleSimple3.txt", 1, [60]);
self.templateClusteringResults(SIMPLE_SAMPLES.SAMPLE_SIMPLE3, 4, [10, 10, 10, 30]);
self.templateClusteringResults(SIMPLE_SAMPLES.SAMPLE_SIMPLE3, 1, [60]);

def testClusteringSampleSimple4(self):
self.templateClusteringResults("../samples/SampleSimple4.txt", 5, [15, 15, 15, 15, 15]);
self.templateClusteringResults("../samples/SampleSimple4.txt", 1, [75]);
self.templateClusteringResults(SIMPLE_SAMPLES.SAMPLE_SIMPLE4, 5, [15, 15, 15, 15, 15]);
self.templateClusteringResults(SIMPLE_SAMPLES.SAMPLE_SIMPLE4, 1, [75]);

def testClusteringSampleSimple5(self):
self.templateClusteringResults("../samples/SampleSimple5.txt", 4, [15, 15, 15, 15]);
self.templateClusteringResults("../samples/SampleSimple5.txt", 1, [60]);
self.templateClusteringResults(SIMPLE_SAMPLES.SAMPLE_SIMPLE5, 4, [15, 15, 15, 15]);
self.templateClusteringResults(SIMPLE_SAMPLES.SAMPLE_SIMPLE5, 1, [60]);


if __name__ == "__main__":
Expand Down
10 changes: 10 additions & 0 deletions kmeans/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ def cluster_sample3():
start_centers = [[0.2, 0.1], [4.0, 1.0], [2.0, 2.0], [2.3, 3.9]];
template_clustering(start_centers, SIMPLE_SAMPLES.SAMPLE_SIMPLE3);

def cluster_sample4():
start_centers = [[1.5, 0.0], [1.5, 2.0], [1.5, 4.0], [1.5, 6.0], [1.5, 8.0]];
template_clustering(start_centers, SIMPLE_SAMPLES.SAMPLE_SIMPLE4);

def cluster_sample5():
start_centers = [[0.0, 1.0], [0.0, 0.0], [1.0, 1.0], [1.0, 0.0]];
template_clustering(start_centers, SIMPLE_SAMPLES.SAMPLE_SIMPLE5);

def cluster_elongate():
"Not so applicable for this sample"
start_centers = [[1.0, 4.5], [3.1, 2.7]];
Expand Down Expand Up @@ -68,6 +76,8 @@ def cluster_engy_time():
cluster_sample1();
cluster_sample2();
cluster_sample3();
cluster_sample4();
cluster_sample5();
cluster_elongate();
cluster_lsun();
cluster_target();
Expand Down
47 changes: 25 additions & 22 deletions nnet/som/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from nnet.som import type_conn;
from nnet.som import type_init;

from samples.definitions import SIMPLE_SAMPLES;
from samples.definitions import FCPS_SAMPLES;

from support import read_sample;

def template_self_organization(file, rows, cols, time, structure, init_type = type_init.uniform_grid):
Expand All @@ -11,62 +14,62 @@ def template_self_organization(file, rows, cols, time, structure, init_type = ty
network.show_network(False, dataset = False);

def som_sample1():
template_self_organization('../../samples/SampleSimple1.txt', 1, 2, 100, type_conn.grid_four);
template_self_organization(SIMPLE_SAMPLES.SAMPLE_SIMPLE1, 1, 2, 100, type_conn.grid_four);

def som_sample2():
template_self_organization('../../samples/SampleSimple2.txt', 1, 3, 100, type_conn.grid_four);
template_self_organization(SIMPLE_SAMPLES.SAMPLE_SIMPLE2, 1, 3, 100, type_conn.grid_four);

def som_sample3():
template_self_organization('../../samples/SampleSimple3.txt', 2, 2, 100, type_conn.grid_four);
template_self_organization(SIMPLE_SAMPLES.SAMPLE_SIMPLE3, 2, 2, 100, type_conn.grid_four);

def som_sample4():
template_self_organization('../../samples/SampleSimple4.txt', 1, 5, 100, type_conn.grid_four);
template_self_organization(SIMPLE_SAMPLES.SAMPLE_SIMPLE4, 1, 5, 100, type_conn.grid_four);

def som_sample5():
template_self_organization('../../samples/SampleSimple5.txt', 2, 2, 100, type_conn.grid_four);
template_self_organization(SIMPLE_SAMPLES.SAMPLE_SIMPLE5, 2, 2, 100, type_conn.grid_four);

def som_lsun():
template_self_organization('../../samples/SampleLsun.txt', 5, 5, 100, type_conn.grid_four);
template_self_organization(FCPS_SAMPLES.SAMPLE_LSUN, 5, 5, 100, type_conn.grid_four);

def som_target():
template_self_organization('../../samples/SampleTarget.txt', 5, 5, 100, type_conn.grid_four);
template_self_organization(FCPS_SAMPLES.SAMPLE_TARGET, 5, 5, 100, type_conn.grid_four);

def som_tetra():
template_self_organization('../../samples/SampleTetra.txt', 1, 4, 100, type_conn.grid_four);
template_self_organization(FCPS_SAMPLES.SAMPLE_TETRA, 1, 4, 100, type_conn.grid_four);

def som_two_diamonds():
template_self_organization('../../samples/SampleTwoDiamonds.txt', 5, 5, 100, type_conn.grid_four);
template_self_organization(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS, 5, 5, 100, type_conn.grid_four);

def som_elongate():
template_self_organization('../../samples/SampleElongate.txt', 5, 5, 100, type_conn.grid_four);
template_self_organization(SIMPLE_SAMPLES.SAMPLE_ELONGATE, 5, 5, 100, type_conn.grid_four);

def som_wing_nut():
template_self_organization('../../samples/SampleWingNut.txt', 5, 5, 100, type_conn.grid_four);
template_self_organization(FCPS_SAMPLES.SAMPLE_WING_NUT, 5, 5, 100, type_conn.grid_four);

def som_chainlink():
template_self_organization('../../samples/SampleChainlink.txt', 5, 5, 100, type_conn.grid_four);
template_self_organization(FCPS_SAMPLES.SAMPLE_CHAINLINK, 5, 5, 100, type_conn.grid_four);

def som_atom():
template_self_organization('../../samples/SampleAtom.txt', 5, 5, 100, type_conn.grid_four);
template_self_organization(FCPS_SAMPLES.SAMPLE_ATOM, 5, 5, 100, type_conn.grid_four);

def som_golf_ball():
template_self_organization('../../samples/SampleGolfBall.txt', 5, 5, 100, type_conn.grid_four);
template_self_organization(FCPS_SAMPLES.SAMPLE_GOLF_BALL, 5, 5, 100, type_conn.grid_four);

def som_hepta():
template_self_organization('../../samples/SampleHepta.txt', 1, 7, 100, type_conn.grid_four);
template_self_organization(FCPS_SAMPLES.SAMPLE_HEPTA, 1, 7, 100, type_conn.grid_four);

def som_engy_time():
template_self_organization('../../samples/SampleEngyTime.txt', 5, 5, 100, type_conn.grid_four);
template_self_organization(FCPS_SAMPLES.SAMPLE_ENGY_TIME, 5, 5, 100, type_conn.grid_four);

def som_target_diffence_intialization():
template_self_organization('../../samples/SampleTarget.txt', 9, 9, 150, type_conn.grid_four, type_init.random_centroid);
template_self_organization('../../samples/SampleTarget.txt', 9, 9, 150, type_conn.grid_four, type_init.random_surface);
template_self_organization('../../samples/SampleTarget.txt', 9, 9, 150, type_conn.grid_four, type_init.uniform_grid);
template_self_organization(FCPS_SAMPLES.SAMPLE_TARGET, 9, 9, 150, type_conn.grid_four, type_init.random_centroid);
template_self_organization(FCPS_SAMPLES.SAMPLE_TARGET, 9, 9, 150, type_conn.grid_four, type_init.random_surface);
template_self_organization(FCPS_SAMPLES.SAMPLE_TARGET, 9, 9, 150, type_conn.grid_four, type_init.uniform_grid);

def som_two_diamonds_diffence_intialization():
template_self_organization('../../samples/SampleTwoDiamonds.txt', 5, 5, 150, type_conn.grid_four, type_init.random_centroid);
template_self_organization('../../samples/SampleTwoDiamonds.txt', 5, 5, 150, type_conn.grid_four, type_init.random_surface);
template_self_organization('../../samples/SampleTwoDiamonds.txt', 5, 5, 150, type_conn.grid_four, type_init.uniform_grid);
template_self_organization(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS, 5, 5, 150, type_conn.grid_four, type_init.random_centroid);
template_self_organization(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS, 5, 5, 150, type_conn.grid_four, type_init.random_surface);
template_self_organization(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS, 5, 5, 150, type_conn.grid_four, type_init.uniform_grid);


som_sample1();
Expand Down

0 comments on commit 759dd57

Please sign in to comment.