Skip to content

Commit

Permalink
#479: Added additional unit-tests for CURE algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
annoviko committed Jan 15, 2019
1 parent a8c5388 commit 78c8c03
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 15 deletions.
26 changes: 25 additions & 1 deletion ccore/tst/utest-cure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ TEST(utest_cure, allocation_sample_simple_01_one_representative) {
}


TEST(utest_cure, allocation_sample_simple_01_no_compression) {
const std::vector<size_t> expected_clusters_length = { 5, 5 };
template_length_process_data(simple_sample_factory::create_sample(SAMPLE_SIMPLE::SAMPLE_SIMPLE_01), 2, 5, 0.0, expected_clusters_length);
}


TEST(utest_cure, allocation_sample_one_allocation_simple_01) {
const std::vector<size_t> expected_clusters_length = { 10 };
template_length_process_data(simple_sample_factory::create_sample(SAMPLE_SIMPLE::SAMPLE_SIMPLE_01), 1, 5, 0.5, expected_clusters_length);
Expand All @@ -91,6 +97,12 @@ TEST(utest_cure, allocation_sample_simple_02_one_representative) {
}


TEST(utest_cure, allocation_sample_simple_02_no_compression) {
const std::vector<size_t> expected_clusters_length = { 10, 5, 8 };
template_length_process_data(simple_sample_factory::create_sample(SAMPLE_SIMPLE::SAMPLE_SIMPLE_02), 3, 5, 0.0, expected_clusters_length);
}


TEST(utest_cure, allocation_sample_one_allocation_simple_02) {
const std::vector<size_t> expected_clusters_length = { 23 };
template_length_process_data(simple_sample_factory::create_sample(SAMPLE_SIMPLE::SAMPLE_SIMPLE_02), 1, 5, 0.5, expected_clusters_length);
Expand Down Expand Up @@ -181,6 +193,12 @@ TEST(utest_cure, allocation_hepta) {
}


TEST(utest_cure, allocation_hepta_max_compression) {
const std::vector<size_t> expected_clusters_length = { 30, 30, 30, 30, 30, 30, 32 };
template_length_process_data(fcps_sample_factory::create_sample(FCPS_SAMPLE::HEPTA), 7, 5, 1.0, expected_clusters_length);
}


TEST(utest_cure, allocation_hepta_one_representative) {
const std::vector<size_t> expected_clusters_length = { 30, 30, 30, 30, 30, 30, 32 };
template_length_process_data(fcps_sample_factory::create_sample(FCPS_SAMPLE::HEPTA), 7, 1, 0.3, expected_clusters_length);
Expand Down Expand Up @@ -214,4 +232,10 @@ TEST(utest_cure, allocation_two_diamonds) {
TEST(utest_cure, allocation_wing_nut) {
const std::vector<size_t> expected_clusters_length = { 508, 508 };
template_length_process_data(fcps_sample_factory::create_sample(FCPS_SAMPLE::WING_NUT), 2, 4, 0.3, expected_clusters_length);
}
}


TEST(utest_cure, allocation_chainlink) {
const std::vector<size_t> expected_clusters_length = { 500, 500 };
template_length_process_data(fcps_sample_factory::create_sample(FCPS_SAMPLE::CHAINLINK), 2, 10, 0.3, expected_clusters_length);
}
2 changes: 1 addition & 1 deletion pyclustering/cluster/cure.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class cure:
# create instance of cure algorithm for cluster analysis
# request for allocation of two clusters.
cure_instance = cure(sample, 2, 5, 0.5, True);
cure_instance = cure(sample, 2, 5, 0.5);
# run cluster analysis
cure_instance.process();
Expand Down
26 changes: 13 additions & 13 deletions pyclustering/cluster/examples/cure_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from pyclustering.cluster.cure import cure


def template_clustering(number_clusters, path, number_represent_points=5, compression=0.5, draw=True, ccore_flag=False):
def template_clustering(number_clusters, path, number_represent_points=5, compression=0.5, draw=True, ccore_flag=True):
sample = read_sample(path)

cure_instance = cure(sample, number_clusters, number_represent_points, compression, ccore_flag)
Expand Down Expand Up @@ -125,18 +125,18 @@ def experiment_execution_time(draw, ccore):
template_clustering(2, FCPS_SAMPLES.SAMPLE_ATOM, 20, 0.2)


cluster_sample1()
cluster_sample2()
cluster_sample3()
cluster_sample4()
cluster_sample5()
cluster_sample6()
cluster_elongate()
cluster_lsun()
cluster_target()
cluster_two_diamonds()
cluster_wing_nut(True)
cluster_wing_nut(False)
# cluster_sample1()
# cluster_sample2()
# cluster_sample3()
# cluster_sample4()
# cluster_sample5()
# cluster_sample6()
# cluster_elongate()
# cluster_lsun()
# cluster_target()
# cluster_two_diamonds()
# cluster_wing_nut(True)
# cluster_wing_nut(False)
cluster_chainlink()
cluster_hepta()
cluster_tetra()
Expand Down
9 changes: 9 additions & 0 deletions pyclustering/cluster/tests/unit/ut_cure.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,27 @@ class CureUnitTest(unittest.TestCase):
def testClusterAllocationSampleSimple1(self):
CureTestTemplates.template_cluster_allocation(SIMPLE_SAMPLES.SAMPLE_SIMPLE1, [5, 5], 2)

def testClusterAllocationSampleSimple1OneRepresentor(self):
CureTestTemplates.template_cluster_allocation(SIMPLE_SAMPLES.SAMPLE_SIMPLE1, [5, 5], 2, 1, 0.5)

def testClusterAllocationSampleSimple1NumPy(self):
CureTestTemplates.template_cluster_allocation(SIMPLE_SAMPLES.SAMPLE_SIMPLE1, [5, 5], 2, numpy_usage=True)

def testClusterAllocationSampleSimple2(self):
CureTestTemplates.template_cluster_allocation(SIMPLE_SAMPLES.SAMPLE_SIMPLE2, [10, 5, 8], 3)

def testClusterAllocationSampleSimple2NoCompression(self):
CureTestTemplates.template_cluster_allocation(SIMPLE_SAMPLES.SAMPLE_SIMPLE2, [10, 5, 8], 3, 5, 0.0)

def testClusterAllocationSampleSimple2NumPy(self):
CureTestTemplates.template_cluster_allocation(SIMPLE_SAMPLES.SAMPLE_SIMPLE2, [10, 5, 8], 3, numpy_usage=True)

def testClusterAllocationSampleSimple3(self):
CureTestTemplates.template_cluster_allocation(SIMPLE_SAMPLES.SAMPLE_SIMPLE3, [10, 10, 10, 30], 4)

def testClusterAllocationSampleSimple3OneRepresentor(self):
CureTestTemplates.template_cluster_allocation(SIMPLE_SAMPLES.SAMPLE_SIMPLE3, [10, 10, 10, 30], 4, 1, 0.5)

def testClusterAllocationSampleSimple3NumPy(self):
CureTestTemplates.template_cluster_allocation(SIMPLE_SAMPLES.SAMPLE_SIMPLE3, [10, 10, 10, 30], 4, numpy_usage=True)

Expand Down

0 comments on commit 78c8c03

Please sign in to comment.