From cf093b64bce85f6eb623e3d4e7feff8b71e695bc Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:09:14 +0300 Subject: [PATCH 01/36] Update test_denmune.py --- src/tests/test_denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index afd6d36..4133fee 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -34,7 +34,7 @@ def test_DenMune_results(): @pytest.mark.parametrize("show_plots", [True, False]) @pytest.mark.parametrize("show_noise", [True, False]) @pytest.mark.parametrize("show_analyzer", [True, False]) -@pytest.mark.parametrize("prop_step", [0, 600]) +@pytest.mark.parametrize("prop_step", [0, 0]) # all possible combinations will be tested over all parameters. Actually, 257 tests will be covered def test_parameters(train_data, train_truth, test_data, test_truth, validate, show_plots, show_noise, show_analyzer, prop_step): From 7d45ee104e884c6a497ea8b59b28c23c20a1775c Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:19:04 +0300 Subject: [PATCH 02/36] Update test_denmune.py --- src/tests/test_denmune.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index 4133fee..fcb94a3 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -26,10 +26,10 @@ def test_DenMune_results(): assert (np.mean(dm.labels_pred == y_cc) > 0.90) or (1 - np.mean(dm.labels_pred == y_cc) > 0.90) -@pytest.mark.parametrize("train_data", [None, X_cc[:800] ]) -@pytest.mark.parametrize("train_truth", [None, y_cc[:800] ]) -@pytest.mark.parametrize("test_data", [None, X_cc[800:] ]) -@pytest.mark.parametrize("test_truth", [None, y_cc[800:] ]) +@pytest.mark.parametrize("train_data", [X_cc[:800], X_cc[:800] ]) +@pytest.mark.parametrize("train_truth", [y_cc[:800], y_cc[:800] ]) +@pytest.mark.parametrize("test_data", [X_cc[800:], X_cc[800:] ]) +@pytest.mark.parametrize("test_truth", [y_cc[800:], y_cc[800:] ]) @pytest.mark.parametrize("validate", [True, False]) @pytest.mark.parametrize("show_plots", [True, False]) @pytest.mark.parametrize("show_noise", [True, False]) From 8b9fe9166b6ac6bb5ea1b45dab40bec27dd2aed2 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:35:05 +0300 Subject: [PATCH 03/36] Update test_denmune.py --- src/tests/test_denmune.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index fcb94a3..18a85f7 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -16,6 +16,17 @@ cluster_std=0.5, ) +data_file = 'https://raw.githubusercontent.com/egy1st/datasets/dd90854f92cb5ef73b4146606c1c158c32e69b94/denmune/shapes/aggr_rand.csv' +data = pd.read_csv(data_file, sep=',', header=None) +labels = data.iloc[:, -1] +data = data.drop(data.columns[-1], axis=1) +train_data = data [:555] +test_data = data [555:] +train_labels = labels [:555] +test_labels = labels [555:] + + + knn = 10 def test_DenMune_results(): @@ -23,18 +34,18 @@ def test_DenMune_results(): labels, validity = dm.fit_predict(show_analyzer=False) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.90 - assert (np.mean(dm.labels_pred == y_cc) > 0.90) or (1 - np.mean(dm.labels_pred == y_cc) > 0.90) + assert (np.mean(dm.labels_pred == y_cc) > 0.80) or (1 - np.mean(dm.labels_pred == y_cc) > 0.80) -@pytest.mark.parametrize("train_data", [X_cc[:800], X_cc[:800] ]) -@pytest.mark.parametrize("train_truth", [y_cc[:800], y_cc[:800] ]) -@pytest.mark.parametrize("test_data", [X_cc[800:], X_cc[800:] ]) -@pytest.mark.parametrize("test_truth", [y_cc[800:], y_cc[800:] ]) +@pytest.mark.parametrize("train_data", [None, train_data ]) +@pytest.mark.parametrize("train_truth", [None, train_labels ]) +@pytest.mark.parametrize("test_data", [None, test_data ]) +@pytest.mark.parametrize("test_truth", [None, test_labels ]) @pytest.mark.parametrize("validate", [True, False]) @pytest.mark.parametrize("show_plots", [True, False]) @pytest.mark.parametrize("show_noise", [True, False]) @pytest.mark.parametrize("show_analyzer", [True, False]) -@pytest.mark.parametrize("prop_step", [0, 0]) +@pytest.mark.parametrize("prop_step", [0, 500]) # all possible combinations will be tested over all parameters. Actually, 257 tests will be covered def test_parameters(train_data, train_truth, test_data, test_truth, validate, show_plots, show_noise, show_analyzer, prop_step): From 97993e07c3f688dbd9cc3358b4c54d3c3162c8c6 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:37:52 +0300 Subject: [PATCH 04/36] Update test_denmune.py --- src/tests/test_denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index 18a85f7..8f56a8e 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -45,7 +45,7 @@ def test_DenMune_results(): @pytest.mark.parametrize("show_plots", [True, False]) @pytest.mark.parametrize("show_noise", [True, False]) @pytest.mark.parametrize("show_analyzer", [True, False]) -@pytest.mark.parametrize("prop_step", [0, 500]) +@pytest.mark.parametrize("prop_step", [0, 0]) # all possible combinations will be tested over all parameters. Actually, 257 tests will be covered def test_parameters(train_data, train_truth, test_data, test_truth, validate, show_plots, show_noise, show_analyzer, prop_step): From 383af55d2eb4bc9345906f1625b57fe4babb6422 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:42:32 +0300 Subject: [PATCH 05/36] Update test_denmune.py --- src/tests/test_denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index 8f56a8e..e5b3299 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -53,7 +53,7 @@ def test_parameters(train_data, train_truth, test_data, test_truth, validate, sh if not (train_data is not None and train_truth is None and test_truth is not None): if not (train_data is not None and test_data is not None and train_truth is None): if not (train_data is not None and train_truth is not None and test_truth is not None and test_data is None): - dm = DenMune(train_data=train_data, train_truth=train_truth, test_data=test_data, test_truth=test_truth, k_nearest=10,prop_step=prop_step) + dm = DenMune(train_data=train_data, train_truth=train_truth, test_data=test_data, test_truth=test_truth, k_nearest=10,prop_step=prop_step,rgn_tsne=True) labels, validity = dm.fit_predict(validate=validate, show_plots=show_plots, show_noise=show_noise, show_analyzer=show_analyzer) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.70 From 83c1a8daf8f84b7641ae0b451c2f48b996b713c7 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:46:02 +0300 Subject: [PATCH 06/36] Update test_denmune.py --- src/tests/test_denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index e5b3299..2b88a60 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -30,7 +30,7 @@ knn = 10 def test_DenMune_results(): - dm = DenMune(train_data=X_cc, train_truth=y_cc, k_nearest=knn) + dm = DenMune(train_data=X_cc, train_truth=y_cc, k_nearest=knn, rgn_tsne=True) labels, validity = dm.fit_predict(show_analyzer=False) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.90 From 87a179634445aafabfe2ec387a98e50c81463fd2 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:49:06 +0300 Subject: [PATCH 07/36] Update test_denmune.py --- src/tests/test_denmune.py | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index 2b88a60..575f63d 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -30,7 +30,7 @@ knn = 10 def test_DenMune_results(): - dm = DenMune(train_data=X_cc, train_truth=y_cc, k_nearest=knn, rgn_tsne=True) + dm = DenMune(train_data=X_cc, train_truth=y_cc, k_nearest=knn) labels, validity = dm.fit_predict(show_analyzer=False) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.90 @@ -53,7 +53,7 @@ def test_parameters(train_data, train_truth, test_data, test_truth, validate, sh if not (train_data is not None and train_truth is None and test_truth is not None): if not (train_data is not None and test_data is not None and train_truth is None): if not (train_data is not None and train_truth is not None and test_truth is not None and test_data is None): - dm = DenMune(train_data=train_data, train_truth=train_truth, test_data=test_data, test_truth=test_truth, k_nearest=10,prop_step=prop_step,rgn_tsne=True) + dm = DenMune(train_data=train_data, train_truth=train_truth, test_data=test_data, test_truth=test_truth, k_nearest=10,prop_step=prop_step) labels, validity = dm.fit_predict(validate=validate, show_plots=show_plots, show_noise=show_noise, show_analyzer=show_analyzer) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.70 @@ -106,29 +106,3 @@ def test_dataframe(): assert ( np.mean(dm.labels_pred == labels) > 0.97 or (1 - np.mean( dm.labels_pred == labels) > 0.97) ) -def test_exceptions(): - - with pytest.raises(Exception) as execinfo: - dm = DenMune(train_data=None, k_nearest=10) - #labels, validity = dm.fit_predict() - #raise Exception('train data is None') - - with pytest.raises(Exception) as execinfo: - dm = DenMune(train_data=train_data, test_truth=test_labels, k_nearest=10) - #labels, validity = dm.fit_predict() - #raise Exception('train_data is not None and train_truth is None and test_truth is not None') - - with pytest.raises(Exception) as execinfo: - dm = DenMune(train_data=train_data, test_data=test_data, k_nearest=10) - #labels, validity = dm.fit_predict() - #raise Exception('train_data is not None and test_data is not None and train_truth is None') - - with pytest.raises(Exception) as execinfo: - dm = DenMune(train_data=train_data, train_truth=train_labels, test_truth=test_labels, test_data=None, k_nearest=10) - #labels, validity = dm.fit_predict() - #raise Exception('train_data is not None and train_truth is not None and test_truth is not None and test_data is None') - with pytest.raises(Exception) as execinfo: - - dm = DenMune(train_data=train_data, train_truth=train_labels) # default value for k_nearest is 0 which is invalid - #labels, validity = dm.fit_predict() - #raise Exception('k-nearest neighbor should be at least 1') From 445ef15a617a670e6dd4d3f17e22b3df52a568f0 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:51:18 +0300 Subject: [PATCH 08/36] Update test_denmune.py --- src/tests/test_denmune.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index 575f63d..2e90203 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -98,11 +98,3 @@ def test_knn(): train_labels = labels [:555] test_labels = labels [555:] -# check if data will be treated correctly when comes as dataframe -def test_dataframe(): - knn = 11 # k-nearest neighbor, the only parameter required by the algorithm - dm = DenMune(train_data=train_data, train_truth=train_labels, test_data=test_data, test_truth=test_labels, k_nearest=knn, rgn_tsne=True) - labels, validity = dm.fit_predict(validate=True, show_noise=True, show_analyzer=True) - assert ( np.mean(dm.labels_pred == labels) > 0.97 or (1 - np.mean( dm.labels_pred == labels) > 0.97) ) - - From e0902a0b3a7a44b63e2bb11d1c61e05031dc8e76 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:52:56 +0300 Subject: [PATCH 09/36] Update test_denmune.py --- src/tests/test_denmune.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index 2e90203..faec86d 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -82,19 +82,3 @@ def test_t_SNE(rgn_tsne, file_2d): labels, validity = dm.fit_predict(show_analyzer=False, show_plots=False) assert (dm.data.shape[1] == 2) # this means it was reduced properly to 2-d using t-SNE -def test_knn(): - for k in range (5, 55, 5): - dm = DenMune(train_data=X_iris, train_truth=y_iris, k_nearest=k, rgn_tsne=False) - labels, validity = dm.fit_predict(show_analyzer=False, show_plots=False) - #assert (k == 50) # this means we tested the algorithm works fine with several knn inputs - - -data_file = 'https://raw.githubusercontent.com/egy1st/datasets/dd90854f92cb5ef73b4146606c1c158c32e69b94/denmune/shapes/aggr_rand.csv' -data = pd.read_csv(data_file, sep=',', header=None) -labels = data.iloc[:, -1] -data = data.drop(data.columns[-1], axis=1) -train_data = data [:555] -test_data = data [555:] -train_labels = labels [:555] -test_labels = labels [555:] - From 04bdd25f1dfe078d3dbbaffbfbde186706bf3bca Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:54:52 +0300 Subject: [PATCH 10/36] Update test_denmune.py --- src/tests/test_denmune.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index faec86d..fada3d2 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -77,8 +77,4 @@ def test_DenMune_propagation(): @pytest.mark.parametrize("rgn_tsne", [True, False]) -def test_t_SNE(rgn_tsne, file_2d): - dm = DenMune(train_data=X_iris, train_truth=y_iris, k_nearest=knn, rgn_tsne=rgn_tsne, file_2d=file_2d) - labels, validity = dm.fit_predict(show_analyzer=False, show_plots=False) - assert (dm.data.shape[1] == 2) # this means it was reduced properly to 2-d using t-SNE From 3aaaff11a711541a3268cd43d0ac18c96ca82d73 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:56:10 +0300 Subject: [PATCH 11/36] Update test_denmune.py --- src/tests/test_denmune.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index fada3d2..7a54c79 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -68,13 +68,3 @@ def test_DenMune_propagation(): # if snapshot iteration = 1000, this means we could propagate to the end properly assert (snapshot == 1000) -# we are going to do some tests using iris data -X_iris = load_iris()["data"] -y_iris = load_iris()["target"] - -# we test t_SNE reduction by applying it on Iris dataset which has 4 dimentions. -@pytest.mark.parametrize("file_2d", [None, 'iris_2d.csv']) -@pytest.mark.parametrize("rgn_tsne", [True, False]) - - - From 6f2c8ca740ac3ab836eafa08e53963a6b68daa8f Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 02:57:40 +0300 Subject: [PATCH 12/36] Update test_denmune.py --- src/tests/test_denmune.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index 7a54c79..8826d95 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -58,13 +58,3 @@ def test_parameters(train_data, train_truth, test_data, test_truth, validate, sh # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.70 assert ( np.mean(dm.labels_pred == y_cc) > 0.70 or (1 - np.mean( dm.labels_pred == y_cc) > 0.70) ) - - -def test_DenMune_propagation(): - snapshots = chain([0], range(2,5), range(5,50,5), range(50, 100, 10), range(100,500,50), range(500,1100, 100)) - for snapshot in snapshots: - dm = DenMune(train_data=X_cc, k_nearest=knn, prop_step=snapshot) - labels, validity = dm.fit_predict(show_analyzer=False, show_plots=False) - # if snapshot iteration = 1000, this means we could propagate to the end properly - assert (snapshot == 1000) - From 3780c46879be4895d3097cfa92e63a8ab04a299d Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 03:02:00 +0300 Subject: [PATCH 13/36] Update test_denmune.py --- src/tests/test_denmune.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index 8826d95..cdb7ebf 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -37,24 +37,3 @@ def test_DenMune_results(): assert (np.mean(dm.labels_pred == y_cc) > 0.80) or (1 - np.mean(dm.labels_pred == y_cc) > 0.80) -@pytest.mark.parametrize("train_data", [None, train_data ]) -@pytest.mark.parametrize("train_truth", [None, train_labels ]) -@pytest.mark.parametrize("test_data", [None, test_data ]) -@pytest.mark.parametrize("test_truth", [None, test_labels ]) -@pytest.mark.parametrize("validate", [True, False]) -@pytest.mark.parametrize("show_plots", [True, False]) -@pytest.mark.parametrize("show_noise", [True, False]) -@pytest.mark.parametrize("show_analyzer", [True, False]) -@pytest.mark.parametrize("prop_step", [0, 0]) - -# all possible combinations will be tested over all parameters. Actually, 257 tests will be covered -def test_parameters(train_data, train_truth, test_data, test_truth, validate, show_plots, show_noise, show_analyzer, prop_step): - if not (train_data is None): - if not (train_data is not None and train_truth is None and test_truth is not None): - if not (train_data is not None and test_data is not None and train_truth is None): - if not (train_data is not None and train_truth is not None and test_truth is not None and test_data is None): - dm = DenMune(train_data=train_data, train_truth=train_truth, test_data=test_data, test_truth=test_truth, k_nearest=10,prop_step=prop_step) - labels, validity = dm.fit_predict(validate=validate, show_plots=show_plots, show_noise=show_noise, show_analyzer=show_analyzer) - # This test use data that are not perfectly separable so the - # accuracy is not 1. Accuracy around 0.70 - assert ( np.mean(dm.labels_pred == y_cc) > 0.70 or (1 - np.mean( dm.labels_pred == y_cc) > 0.70) ) From ab7ec37bf7941653b40f488cccf1b21c0d064b0c Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 03:05:16 +0300 Subject: [PATCH 14/36] Update test_denmune.py --- src/tests/test_denmune.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index cdb7ebf..d774a94 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -16,16 +16,6 @@ cluster_std=0.5, ) -data_file = 'https://raw.githubusercontent.com/egy1st/datasets/dd90854f92cb5ef73b4146606c1c158c32e69b94/denmune/shapes/aggr_rand.csv' -data = pd.read_csv(data_file, sep=',', header=None) -labels = data.iloc[:, -1] -data = data.drop(data.columns[-1], axis=1) -train_data = data [:555] -test_data = data [555:] -train_labels = labels [:555] -test_labels = labels [555:] - - knn = 10 @@ -34,6 +24,6 @@ def test_DenMune_results(): labels, validity = dm.fit_predict(show_analyzer=False) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.90 - assert (np.mean(dm.labels_pred == y_cc) > 0.80) or (1 - np.mean(dm.labels_pred == y_cc) > 0.80) + assert (np.mean(dm.labels_pred == y_cc) > 0.50) or (1 - np.mean(dm.labels_pred == y_cc) > 0.50) From c0c49904fbac38139da01fe754210e5f15a80237 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 03:28:59 +0300 Subject: [PATCH 15/36] Update test_denmune.py --- src/tests/test_denmune.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index d774a94..3c7e2d1 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -18,12 +18,3 @@ knn = 10 - -def test_DenMune_results(): - dm = DenMune(train_data=X_cc, train_truth=y_cc, k_nearest=knn) - labels, validity = dm.fit_predict(show_analyzer=False) - # This test use data that are not perfectly separable so the - # accuracy is not 1. Accuracy around 0.90 - assert (np.mean(dm.labels_pred == y_cc) > 0.50) or (1 - np.mean(dm.labels_pred == y_cc) > 0.50) - - From d2eb6d39f69d49fd2818eeecad32cebb549c2a9e Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 03:35:54 +0300 Subject: [PATCH 16/36] Update test_denmune.py --- src/tests/test_denmune.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index 3c7e2d1..a0ea819 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -18,3 +18,10 @@ knn = 10 + +def test_DenMune_results(): + dm = DenMune(train_data=X_cc, train_truth=y_cc, k_nearest=knn) + labels, validity = dm.fit_predict(show_analyzer=False) + # This test use data that are not perfectly separable so the + # accuracy is not 1. Accuracy around 0.90 + assert (np.mean(dm.labels_pred == y_cc) > 0.80) or (1 - np.mean(dm.labels_pred == y_cc) > 0.80) From 460a488453cfdbbee700d60861fc13dd4640a4e2 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 03:39:41 +0300 Subject: [PATCH 17/36] Update test_denmune.py --- src/tests/test_denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index a0ea819..3185bd4 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -24,4 +24,4 @@ def test_DenMune_results(): labels, validity = dm.fit_predict(show_analyzer=False) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.90 - assert (np.mean(dm.labels_pred == y_cc) > 0.80) or (1 - np.mean(dm.labels_pred == y_cc) > 0.80) + assert (np.mean(dm.labels_pred == y_cc) < 0.80) or (1 - np.mean(dm.labels_pred == y_cc) < 0.80) From 955cb2fed7aa1b06c73e8a3427ebbd3646adfc4d Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 03:46:54 +0300 Subject: [PATCH 18/36] Updated config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e43ad0b..8b787cd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,7 +24,7 @@ jobs: # The executor is the environment in which the steps below will be executed - below will use a python 3.8 container # Change the version below to your required version of python docker: - - image: cimg/python:3.10 + - image: cimg/python:3.10.12 # Checkout the code as the first step. This is a dedicated CircleCI step. From 79cc8de14483e5d2f626b440a0e2c5875183c88f Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 03:48:30 +0300 Subject: [PATCH 19/36] Updated config.yml --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8b787cd..f43bc0c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ orbs: # See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/python codecov: codecov/codecov@3.0.0 slack: circleci/slack@4.4.4 - python: circleci/python@1.2 + python: circleci/python@3.10 # Define a job to be invoked later in a workflow. @@ -24,7 +24,7 @@ jobs: # The executor is the environment in which the steps below will be executed - below will use a python 3.8 container # Change the version below to your required version of python docker: - - image: cimg/python:3.10.12 + - image: cimg/python:3.10 # Checkout the code as the first step. This is a dedicated CircleCI step. @@ -66,7 +66,7 @@ jobs: # Invoke jobs via workflows # See: https://circleci.com/docs/2.0/configuration-reference/#workflows workflows: - Python-3.8: # This is the name of the workflow, feel free to change it to better match your workflow. + Python-3.10: # This is the name of the workflow, feel free to change it to better match your workflow. # Inside the workflow, you define the jobs you want to run. jobs: - build-and-test: From 68e0b3fb661af8907350348dbf398e3f7e286b4c Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 03:49:51 +0300 Subject: [PATCH 20/36] Updated config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f43bc0c..38e27f1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ orbs: # See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/python codecov: codecov/codecov@3.0.0 slack: circleci/slack@4.4.4 - python: circleci/python@3.10 + python: circleci/python@1.2 # Define a job to be invoked later in a workflow. From 282330e8ea8a879bb1c94e2be2e7b6c42fd42622 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 03:51:10 +0300 Subject: [PATCH 21/36] Updated config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 38e27f1..08c1cd7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ orbs: # See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/python codecov: codecov/codecov@3.0.0 slack: circleci/slack@4.4.4 - python: circleci/python@1.2 + python: circleci/python@2.1.1 # Define a job to be invoked later in a workflow. From e65080069ecbe06ccd221a0f02d8316b286d4653 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:04:40 +0300 Subject: [PATCH 22/36] Update denmune.py --- src/denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/denmune.py b/src/denmune.py index 7fc86d1..4eed7b7 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -125,7 +125,7 @@ def __init__( if isinstance(train_data, pd.DataFrame): train_data = train_data.to_numpy() train_data = train_data.copy(order='C') - elif type(train_data == np.ndarray and not train_data.data.c_contiguous): + elif type(train_data == np.ndarray) and (not train_data.data.c_contiguous): train_data = train_data.copy(order='C') if train_truth is not None: From 7fc6365e1d6de7e34c5321c79600da0956c56538 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:06:22 +0300 Subject: [PATCH 23/36] Update denmune.py --- src/denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/denmune.py b/src/denmune.py index 4eed7b7..fe411a2 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -125,7 +125,7 @@ def __init__( if isinstance(train_data, pd.DataFrame): train_data = train_data.to_numpy() train_data = train_data.copy(order='C') - elif type(train_data == np.ndarray) and (not train_data.data.c_contiguous): + elif type(train_data == np.ndarray): train_data = train_data.copy(order='C') if train_truth is not None: From 0b0560cbd638e6393af52ee688e31ff07c05891c Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:09:55 +0300 Subject: [PATCH 24/36] Update denmune.py --- src/denmune.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/denmune.py b/src/denmune.py index fe411a2..84c64f2 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -125,7 +125,8 @@ def __init__( if isinstance(train_data, pd.DataFrame): train_data = train_data.to_numpy() train_data = train_data.copy(order='C') - elif type(train_data == np.ndarray): + else: + print(type(train_data) train_data = train_data.copy(order='C') if train_truth is not None: From 6d6f9f914cdef7b085aa47e71372a26a6f8b1139 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:11:39 +0300 Subject: [PATCH 25/36] Update denmune.py --- src/denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/denmune.py b/src/denmune.py index 84c64f2..c54b2b8 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -126,7 +126,7 @@ def __init__( train_data = train_data.to_numpy() train_data = train_data.copy(order='C') else: - print(type(train_data) + print(type(train_data)) train_data = train_data.copy(order='C') if train_truth is not None: From 0b0b4f2ca6e084c2ca7d1dd2fbd6abdb27d8e720 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:14:29 +0300 Subject: [PATCH 26/36] Update denmune.py --- src/denmune.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/denmune.py b/src/denmune.py index c54b2b8..7383195 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -127,6 +127,7 @@ def __init__( train_data = train_data.copy(order='C') else: print(type(train_data)) + print(train_data) train_data = train_data.copy(order='C') if train_truth is not None: From 02a04b44d4a6e633033a78f6e461e1ec1bdb93a4 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:20:03 +0300 Subject: [PATCH 27/36] Update denmune.py --- src/denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/denmune.py b/src/denmune.py index 7383195..ed83080 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -134,7 +134,7 @@ def __init__( if isinstance(train_truth, pd.Series): train_truth = train_truth.to_numpy() train_truth = train_truth.copy(order='C') - elif type(train_truth == np.ndarray and not train_truth.data.c_contiguous): + else: #type(train_truth == np.ndarray and not train_truth.data.c_contiguous): train_truth = train_truth.copy(order='C') if test_data is not None: From 5965e8c241f370b3070c6aabf7a710c5c3b4061e Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:22:38 +0300 Subject: [PATCH 28/36] Update denmune.py --- src/denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/denmune.py b/src/denmune.py index ed83080..8377bb7 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -125,7 +125,7 @@ def __init__( if isinstance(train_data, pd.DataFrame): train_data = train_data.to_numpy() train_data = train_data.copy(order='C') - else: + elif type(train_data == np.ndarray) and (not train_data.data.c_contiguous) print(type(train_data)) print(train_data) train_data = train_data.copy(order='C') From d5a7c355ead6e222baa9d411be745044ad71f2a0 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:24:27 +0300 Subject: [PATCH 29/36] Update denmune.py --- src/denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/denmune.py b/src/denmune.py index 8377bb7..c6a9166 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -125,7 +125,7 @@ def __init__( if isinstance(train_data, pd.DataFrame): train_data = train_data.to_numpy() train_data = train_data.copy(order='C') - elif type(train_data == np.ndarray) and (not train_data.data.c_contiguous) + elif type(train_data == np.ndarray) and (not train_data.data.c_contiguous): print(type(train_data)) print(train_data) train_data = train_data.copy(order='C') From 8582213fe7d2805c9c30671bd68651e04146064c Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:26:32 +0300 Subject: [PATCH 30/36] Update denmune.py --- src/denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/denmune.py b/src/denmune.py index c6a9166..c1aee3b 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -125,7 +125,7 @@ def __init__( if isinstance(train_data, pd.DataFrame): train_data = train_data.to_numpy() train_data = train_data.copy(order='C') - elif type(train_data == np.ndarray) and (not train_data.data.c_contiguous): + elif type(train_data == np.ndarray): # and (not train_data.data.c_contiguous) print(type(train_data)) print(train_data) train_data = train_data.copy(order='C') From fdab09f8d7aafb6b12cace3f91d9a2a5cdac524e Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:30:47 +0300 Subject: [PATCH 31/36] Update denmune.py --- src/denmune.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/denmune.py b/src/denmune.py index c1aee3b..27b3a29 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -125,31 +125,32 @@ def __init__( if isinstance(train_data, pd.DataFrame): train_data = train_data.to_numpy() train_data = train_data.copy(order='C') - elif type(train_data == np.ndarray): # and (not train_data.data.c_contiguous) - print(type(train_data)) - print(train_data) + # elif type(train_data == np.ndarray) and (not train_data.data.c_contiguous): + else: train_data = train_data.copy(order='C') if train_truth is not None: if isinstance(train_truth, pd.Series): train_truth = train_truth.to_numpy() train_truth = train_truth.copy(order='C') - else: #type(train_truth == np.ndarray and not train_truth.data.c_contiguous): + # elif type(train_truth == np.ndarray) and (not train_truth.data.c_contiguous): + else: train_truth = train_truth.copy(order='C') if test_data is not None: if isinstance(test_data, pd.DataFrame): test_data = test_data.to_numpy() test_data = test_data.copy(order='C') - elif type(test_data == np.ndarray and not test_data.data.c_contiguous): - print ('I am in two') + # elif type(test_data == np.ndarray) and (not test_data.data.c_contiguous): + else: test_data = test_data.copy(order='C') if test_truth is not None: if isinstance(test_truth, pd.Series): test_truth = test_truth.to_numpy() test_truth = test_truth.copy(order='C') - elif type(test_truth == np.ndarray and not test_truth.data.c_contiguous): + # elif type(test_truth == np.ndarray) and (not test_truth.data.c_contiguous): + else: test_truth = test_truth.copy(order='C') self.train_sz = len(train_data) From c7d024003e82014fd93c98039e573e50857b51fe Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:34:07 +0300 Subject: [PATCH 32/36] Update test_denmune.py --- src/tests/test_denmune.py | 100 +++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index 3185bd4..dc09541 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -16,7 +16,6 @@ cluster_std=0.5, ) - knn = 10 def test_DenMune_results(): @@ -24,4 +23,101 @@ def test_DenMune_results(): labels, validity = dm.fit_predict(show_analyzer=False) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.90 - assert (np.mean(dm.labels_pred == y_cc) < 0.80) or (1 - np.mean(dm.labels_pred == y_cc) < 0.80) + assert (np.mean(dm.labels_pred == y_cc) > 0.80) or (1 - np.mean(dm.labels_pred == y_cc) > 0.80) + + +@pytest.mark.parametrize("train_data", [None, X_cc[:800] ]) +@pytest.mark.parametrize("train_truth", [None, y_cc[:800] ]) +@pytest.mark.parametrize("test_data", [None, X_cc[800:] ]) +@pytest.mark.parametrize("test_truth", [None, y_cc[800:] ]) +@pytest.mark.parametrize("validate", [True, False]) +@pytest.mark.parametrize("show_plots", [True, False]) +@pytest.mark.parametrize("show_noise", [True, False]) +@pytest.mark.parametrize("show_analyzer", [True, False]) +@pytest.mark.parametrize("prop_step", [0, 0]) + +# all possible combinations will be tested over all parameters. Actually, 257 tests will be covered +def test_parameters(train_data, train_truth, test_data, test_truth, validate, show_plots, show_noise, show_analyzer, prop_step): + if not (train_data is None): + if not (train_data is not None and train_truth is None and test_truth is not None): + if not (train_data is not None and test_data is not None and train_truth is None): + if not (train_data is not None and train_truth is not None and test_truth is not None and test_data is None): + dm = DenMune(train_data=train_data, train_truth=train_truth, test_data=test_data, test_truth=test_truth, k_nearest=10,prop_step=prop_step) + labels, validity = dm.fit_predict(validate=validate, show_plots=show_plots, show_noise=show_noise, show_analyzer=show_analyzer) + # This test use data that are not perfectly separable so the + # accuracy is not 1. Accuracy around 0.70 + assert ( np.mean(dm.labels_pred == y_cc) > 0.70 or (1 - np.mean( dm.labels_pred == y_cc) > 0.70) ) + + +def test_DenMune_propagation(): + snapshots = chain([0], range(2,5), range(5,50,5), range(50, 100, 10), range(100,500,50), range(500,1100, 100)) + for snapshot in snapshots: + dm = DenMune(train_data=X_cc, k_nearest=knn, prop_step=snapshot) + labels, validity = dm.fit_predict(show_analyzer=False, show_plots=False) + # if snapshot iteration = 1000, this means we could propagate to the end properly + assert (snapshot == 1000) + +# we are going to do some tests using iris data +X_iris = load_iris()["data"] +y_iris = load_iris()["target"] + +# we test t_SNE reduction by applying it on Iris dataset which has 4 dimentions. +@pytest.mark.parametrize("file_2d", [None, 'iris_2d.csv']) +@pytest.mark.parametrize("rgn_tsne", [True, False]) + + +def test_t_SNE(rgn_tsne, file_2d): + dm = DenMune(train_data=X_iris, train_truth=y_iris, k_nearest=knn, rgn_tsne=rgn_tsne, file_2d=file_2d) + labels, validity = dm.fit_predict(show_analyzer=False, show_plots=False) + assert (dm.data.shape[1] == 2) # this means it was reduced properly to 2-d using t-SNE + +def test_knn(): + for k in range (5, 55, 5): + dm = DenMune(train_data=X_iris, train_truth=y_iris, k_nearest=k, rgn_tsne=False) + labels, validity = dm.fit_predict(show_analyzer=False, show_plots=False) + #assert (k == 50) # this means we tested the algorithm works fine with several knn inputs + + +data_file = 'https://raw.githubusercontent.com/egy1st/datasets/dd90854f92cb5ef73b4146606c1c158c32e69b94/denmune/shapes/aggr_rand.csv' +data = pd.read_csv(data_file, sep=',', header=None) +labels = data.iloc[:, -1] +data = data.drop(data.columns[-1], axis=1) +train_data = data [:555] +test_data = data [555:] +train_labels = labels [:555] +test_labels = labels [555:] + +# check if data will be treated correctly when comes as dataframe +def test_dataframe(): + knn = 11 # k-nearest neighbor, the only parameter required by the algorithm + dm = DenMune(train_data=train_data, train_truth=train_labels, test_data=test_data, test_truth=test_labels, k_nearest=knn, rgn_tsne=True) + labels, validity = dm.fit_predict(validate=True, show_noise=True, show_analyzer=True) + assert ( np.mean(dm.labels_pred == labels) > 0.97 or (1 - np.mean( dm.labels_pred == labels) > 0.97) ) + + +def test_exceptions(): + + with pytest.raises(Exception) as execinfo: + dm = DenMune(train_data=None, k_nearest=10) + #labels, validity = dm.fit_predict() + #raise Exception('train data is None') + + with pytest.raises(Exception) as execinfo: + dm = DenMune(train_data=train_data, test_truth=test_labels, k_nearest=10) + #labels, validity = dm.fit_predict() + #raise Exception('train_data is not None and train_truth is None and test_truth is not None') + + with pytest.raises(Exception) as execinfo: + dm = DenMune(train_data=train_data, test_data=test_data, k_nearest=10) + #labels, validity = dm.fit_predict() + #raise Exception('train_data is not None and test_data is not None and train_truth is None') + + with pytest.raises(Exception) as execinfo: + dm = DenMune(train_data=train_data, train_truth=train_labels, test_truth=test_labels, test_data=None, k_nearest=10) + #labels, validity = dm.fit_predict() + #raise Exception('train_data is not None and train_truth is not None and test_truth is not None and test_data is None') + with pytest.raises(Exception) as execinfo: + + dm = DenMune(train_data=train_data, train_truth=train_labels) # default value for k_nearest is 0 which is invalid + #labels, validity = dm.fit_predict() + #raise Exception('k-nearest neighbor should be at least 1') From 191a72b20cfd62ff96d2764bbb6902d4e6cff84c Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 04:36:43 +0300 Subject: [PATCH 33/36] Update test_denmune.py --- src/tests/test_denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index dc09541..d806e04 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -34,7 +34,7 @@ def test_DenMune_results(): @pytest.mark.parametrize("show_plots", [True, False]) @pytest.mark.parametrize("show_noise", [True, False]) @pytest.mark.parametrize("show_analyzer", [True, False]) -@pytest.mark.parametrize("prop_step", [0, 0]) +@pytest.mark.parametrize("prop_step", [0, 600]) # all possible combinations will be tested over all parameters. Actually, 257 tests will be covered def test_parameters(train_data, train_truth, test_data, test_truth, validate, show_plots, show_noise, show_analyzer, prop_step): From 3603f1f9989646dc01705a9cb4ce5f6d2d6dfea0 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 05:02:03 +0300 Subject: [PATCH 34/36] Update test_denmune.py --- src/tests/test_denmune.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index d806e04..afd6d36 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -23,12 +23,12 @@ def test_DenMune_results(): labels, validity = dm.fit_predict(show_analyzer=False) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.90 - assert (np.mean(dm.labels_pred == y_cc) > 0.80) or (1 - np.mean(dm.labels_pred == y_cc) > 0.80) + assert (np.mean(dm.labels_pred == y_cc) > 0.90) or (1 - np.mean(dm.labels_pred == y_cc) > 0.90) @pytest.mark.parametrize("train_data", [None, X_cc[:800] ]) @pytest.mark.parametrize("train_truth", [None, y_cc[:800] ]) -@pytest.mark.parametrize("test_data", [None, X_cc[800:] ]) +@pytest.mark.parametrize("test_data", [None, X_cc[800:] ]) @pytest.mark.parametrize("test_truth", [None, y_cc[800:] ]) @pytest.mark.parametrize("validate", [True, False]) @pytest.mark.parametrize("show_plots", [True, False]) From 37923a2ef3d1fd66137ef731117700922e2385ab Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 05:07:53 +0300 Subject: [PATCH 35/36] Update test_denmune.py --- src/tests/test_denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index afd6d36..ec5524d 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -46,7 +46,7 @@ def test_parameters(train_data, train_truth, test_data, test_truth, validate, sh labels, validity = dm.fit_predict(validate=validate, show_plots=show_plots, show_noise=show_noise, show_analyzer=show_analyzer) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.70 - assert ( np.mean(dm.labels_pred == y_cc) > 0.70 or (1 - np.mean( dm.labels_pred == y_cc) > 0.70) ) + assert ( np.mean(labels == y_cc) > 0.70 or (1 - np.mean( labels == y_cc) > 0.70) ) def test_DenMune_propagation(): From 318561cb5918072b52c1ba7a0c47c2836b9f884b Mon Sep 17 00:00:00 2001 From: Mohammad Ali Abbas Date: Sun, 9 Jul 2023 05:12:14 +0300 Subject: [PATCH 36/36] Update test_denmune.py --- src/tests/test_denmune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index ec5524d..c975ceb 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -118,6 +118,6 @@ def test_exceptions(): #raise Exception('train_data is not None and train_truth is not None and test_truth is not None and test_data is None') with pytest.raises(Exception) as execinfo: - dm = DenMune(train_data=train_data, train_truth=train_labels) # default value for k_nearest is 0 which is invalid + dm = DenMune(train_data=train_data, train_truth=train_labels, k_nearest=0) # default value for k_nearest is 1 which is valid #labels, validity = dm.fit_predict() #raise Exception('k-nearest neighbor should be at least 1')