From e7fd79f1af4bf66a50fdb76d93b4c7b502139185 Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Sun, 18 Feb 2018 15:05:02 +0530 Subject: [PATCH 1/2] Added tests for information_content Added some tests for information_content function from learning.py --- tests/test_learning.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_learning.py b/tests/test_learning.py index 8a21d6462..b47892618 100644 --- a/tests/test_learning.py +++ b/tests/test_learning.py @@ -165,6 +165,13 @@ def test_decision_tree_learner(): assert dTL([7.5, 4, 6, 2]) == "virginica" +def test_information_content(): + assert information_content([]) == 0 + assert information_content([4]) == 0 + assert information_content([5, 4, 0, 2, 5, 0]) == 1.9237949406953985 + assert information_content([1.5, 2.5]) == 0.9544340029249649 + + def test_random_forest(): iris = DataSet(name="iris") rF = RandomForest(iris) From 22bb0e875f68b1fdd331cf264540bda3c274d1b9 Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Sun, 18 Feb 2018 20:13:16 +0530 Subject: [PATCH 2/2] Added test for information_content --- tests/test_learning.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_learning.py b/tests/test_learning.py index b47892618..932070820 100644 --- a/tests/test_learning.py +++ b/tests/test_learning.py @@ -168,8 +168,10 @@ def test_decision_tree_learner(): def test_information_content(): assert information_content([]) == 0 assert information_content([4]) == 0 - assert information_content([5, 4, 0, 2, 5, 0]) == 1.9237949406953985 - assert information_content([1.5, 2.5]) == 0.9544340029249649 + assert information_content([5, 4, 0, 2, 5, 0]) > 1.9 + assert information_content([5, 4, 0, 2, 5, 0]) < 2 + assert information_content([1.5, 2.5]) > 0.9 + assert information_content([1.5, 2.5]) < 1.0 def test_random_forest():