From 81fec577565ecf2fb25c41a539fd470cebd22692 Mon Sep 17 00:00:00 2001 From: Jeremy Vachier <89128100+jvachier@users.noreply.github.com> Date: Sat, 30 Nov 2024 13:18:59 +0100 Subject: [PATCH 1/5] addition of kmodes to requirements. --- kaggle_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/kaggle_requirements.txt b/kaggle_requirements.txt index 6400d8a1..f8e08395 100644 --- a/kaggle_requirements.txt +++ b/kaggle_requirements.txt @@ -69,6 +69,7 @@ keras<3.6 keras-cv keras-nlp keras-tuner +kmodes kornia langid leven From a6386487e16ef58db46c5e6edaef8b18e469ce2b Mon Sep 17 00:00:00 2001 From: Jeremy Vachier <89128100+jvachier@users.noreply.github.com> Date: Sat, 30 Nov 2024 13:27:56 +0100 Subject: [PATCH 2/5] Add unit test for kmodes. --- tests/test_kmodes.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/test_kmodes.py diff --git a/tests/test_kmodes.py b/tests/test_kmodes.py new file mode 100644 index 00000000..1131ffa4 --- /dev/null +++ b/tests/test_kmodes.py @@ -0,0 +1,21 @@ +import unittest + +import numpy as np +from kmodes.kmodes import KModes + + +class TestKmodes(unittest.TestCase): + def test_plot(self): + data = np.array( + [ + ["A", "B", "C"], + ["B", "C", "A"], + ["C", "A", "B"], + ["A", "C", "B"], + ["A", "A", "B"], + ] + ) + km = KModes(n_clusters=4, init="Huang", n_init=5, verbose=1) + clusters = km.fit_predict(data) + self.assertEqual(len(np.unique(clusters)), 4) + self.assertTrue() From f952fc0845ce262b53cb8058f8bb2a51646155e7 Mon Sep 17 00:00:00 2001 From: Jeremy Vachier <89128100+jvachier@users.noreply.github.com> Date: Sat, 30 Nov 2024 14:39:47 +0100 Subject: [PATCH 3/5] Updating test. --- tests/test_kmodes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_kmodes.py b/tests/test_kmodes.py index 1131ffa4..5264ca63 100644 --- a/tests/test_kmodes.py +++ b/tests/test_kmodes.py @@ -15,7 +15,7 @@ def test_plot(self): ["A", "A", "B"], ] ) - km = KModes(n_clusters=4, init="Huang", n_init=5, verbose=1) + km = KModes(n_clusters=4, init="Huang", n_init=5, verbose=0) clusters = km.fit_predict(data) self.assertEqual(len(np.unique(clusters)), 4) self.assertTrue() From d8a0b05d0f097270e2e7abe22c2e3c2f83045117 Mon Sep 17 00:00:00 2001 From: Jeremy Vachier <89128100+jvachier@users.noreply.github.com> Date: Sat, 30 Nov 2024 14:51:06 +0100 Subject: [PATCH 4/5] Update test. --- tests/test_kmodes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_kmodes.py b/tests/test_kmodes.py index 5264ca63..0f56c9fb 100644 --- a/tests/test_kmodes.py +++ b/tests/test_kmodes.py @@ -18,4 +18,3 @@ def test_plot(self): km = KModes(n_clusters=4, init="Huang", n_init=5, verbose=0) clusters = km.fit_predict(data) self.assertEqual(len(np.unique(clusters)), 4) - self.assertTrue() From ed9cbc9542c699e27d591e71542c25959bb7ef29 Mon Sep 17 00:00:00 2001 From: Jeremy Vachier Date: Sat, 30 Nov 2024 15:16:46 +0100 Subject: [PATCH 5/5] Updating test and email for CLA. --- tests/test_kmodes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_kmodes.py b/tests/test_kmodes.py index 0f56c9fb..056a7f71 100644 --- a/tests/test_kmodes.py +++ b/tests/test_kmodes.py @@ -15,6 +15,6 @@ def test_plot(self): ["A", "A", "B"], ] ) - km = KModes(n_clusters=4, init="Huang", n_init=5, verbose=0) + km = KModes(n_clusters=3, init="Huang", n_init=5, verbose=0) clusters = km.fit_predict(data) - self.assertEqual(len(np.unique(clusters)), 4) + self.assertEqual(len(np.unique(clusters)), 3)