File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -267,8 +267,7 @@ def display(self, indent=0):
267
267
print 'RESULT = ' , subtree
268
268
269
269
def __repr__ (self ):
270
- return 'DecisionTree(%r, %r, %r)' % (
271
- self .attr , self .attrname , self .branches )
270
+ return '(%r %r)' % (self .attrname , self .branches )
272
271
273
272
Yes , No = True , False
274
273
@@ -526,6 +525,16 @@ def T(attrname, branches):
526
525
{'No' : 'Yes' , 'Yes' :
527
526
T ('Raining' , {'No' : 'No' , 'Yes' : 'Yes' })})})})})
528
527
528
+ __doc__ += """
529
+ [Fig. 18.6]
530
+ >>> restaurant_learner = DecisionTreeLearner()
531
+ >>> restaurant_learner.train(restaurant)
532
+ >>> restaurant_learner.dt
533
+ ('Patrons' {'None': 'No', 'Full': ('Hungry' {'Yes': ('Type' \
534
+ {'Burger': 'Yes', 'Thai': ('Fri/Sat' {'Yes': 'Yes', 'No': 'No'}), \
535
+ 'French': 'Yes', 'Italian': 'No'}), 'No': 'No'}), 'Some': 'Yes'})
536
+ """
537
+
529
538
def SyntheticRestaurant (n = 20 ):
530
539
"Generate a DataSet with n examples."
531
540
def gen ():
You can’t perform that action at this time.
0 commit comments