Skip to content

Commit 7ec1d88

Browse files
committed
Added the test for DecisionTreeLearner for the restaurant example given in the book
1 parent 57409bf commit 7ec1d88

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/test_learning.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from learning import (
44
parse_csv, weighted_mode, weighted_replicate,
55
rms_error, manhattan_distance, mean_boolean_error, mean_error,
6-
information_content
6+
information_content, DecisionTreeLearner, restaurant
77
)
88
from utils import rounder
99

@@ -55,5 +55,20 @@ def test_information_content():
5555
# Entropy of a biased coin with heads probability 0.99
5656
assert rounder(information_content([0.99,0.01])) == 0.0808
5757

58+
def test_DecisionTreeLearner():
59+
assert(DecisionTreeLearner(restaurant).display ==
60+
'''Test Patrons
61+
Patrons = Some ==> RESULT = Yes
62+
Patrons = None ==> RESULT = No
63+
Patrons = Full ==> Test Type
64+
Type = Thai ==> Test Fri/Sat
65+
Fri/Sat = No ==> RESULT = No
66+
Fri/Sat = Yes ==> RESULT = Yes
67+
Type = French ==> RESULT = No
68+
Type = Italian ==> RESULT = No
69+
Type = Burger ==> Test Hungry
70+
Hungry = No ==> RESULT = No
71+
Hungry = Yes ==> RESULT = Yes''')
72+
5873
if __name__ == '__main__':
5974
pytest.main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy