@@ -15,7 +15,7 @@ class DataSet:
15
15
d.target The attribute that a learning algorithm will try to predict.
16
16
By default the final attribute.
17
17
d.inputs The list of attrs without the target.
18
- d.values A list of lists, each sublist is the set of possible
18
+ d.values A list of lists: each sublist is the set of possible
19
19
values for the corresponding attribute. If None, it
20
20
is computed from the known examples by self.setproblem.
21
21
If not None, an erroneous value raises ValueError.
@@ -42,7 +42,7 @@ def __init__(self, examples=None, attrs=None, target=-1, values=None,
42
42
else :
43
43
self .examples = examples
44
44
map (self .check_example , self .examples )
45
- # Attrs are the indicies of examples, unless otherwise stated.
45
+ # Attrs are the indices of examples, unless otherwise stated.
46
46
if not attrs and self .examples :
47
47
attrs = range (len (self .examples [0 ]))
48
48
self .attrs = attrs
@@ -57,7 +57,7 @@ def setproblem(self, target, inputs=None, exclude=()):
57
57
"""Set (or change) the target and/or inputs.
58
58
This way, one DataSet can be used multiple ways. inputs, if specified,
59
59
is a list of attributes, or specify exclude as a list of attributes
60
- to not put use in inputs. Attributes can be -n .. n, or an attrname.
60
+ to not use in inputs. Attributes can be -n .. n, or an attrname.
61
61
Also computes the list of possible values, if that wasn't done yet."""
62
62
self .target = self .attrnum (target )
63
63
exclude = map (self .attrnum , exclude )
@@ -156,7 +156,7 @@ def predict(self, example):
156
156
class NaiveBayesLearner (Learner ):
157
157
158
158
def train (self , dataset ):
159
- """Just count the target/attr/val occurences .
159
+ """Just count the target/attr/val occurrences .
160
160
Count how many times each value of each attribute occurs.
161
161
Store count in N[targetvalue][attr][val]. Let N[attr][None] be the
162
162
sum over all vals."""
@@ -291,7 +291,7 @@ def decision_tree_learning(self, examples, attrs, default=None):
291
291
return default
292
292
elif self .all_same_class (examples ):
293
293
return examples [0 ][self .dataset .target ]
294
- elif len (attrs ) == 0 :
294
+ elif len (attrs ) == 0 :
295
295
return self .majority_value (examples )
296
296
else :
297
297
best = self .choose_attribute (attrs , examples )
@@ -410,7 +410,7 @@ class EnsembleLearner(Learner):
410
410
"""Given a list of learning algorithms, have them vote."""
411
411
412
412
def __init__ (self , learners = []):
413
- self .learners = learners
413
+ self .learners = learners
414
414
415
415
def train (self , dataset ):
416
416
for learner in self .learners :
@@ -481,7 +481,7 @@ def score(learner, size):
481
481
for size in sizes ]
482
482
483
483
#______________________________________________________________________________
484
- # The rest of this file gives Data sets for machine learning problems.
484
+ # The rest of this file gives datasets for machine learning problems.
485
485
486
486
orings = DataSet (name = 'orings' , target = 'Distressed' ,
487
487
attrnames = "Rings Distressed Temp Pressure Flightnum" )
@@ -502,8 +502,8 @@ def score(learner, size):
502
502
def RestaurantDataSet (examples = None ):
503
503
"Build a DataSet of Restaurant waiting examples."
504
504
return DataSet (name = 'restaurant' , target = 'Wait' , examples = examples ,
505
- attrnames = 'Alternate Bar Fri/Sat Hungry Patrons Price '
506
- + 'Raining Reservation Type WaitEstimate Wait' )
505
+ attrnames = 'Alternate Bar Fri/Sat Hungry Patrons Price '
506
+ + 'Raining Reservation Type WaitEstimate Wait' )
507
507
508
508
restaurant = RestaurantDataSet ()
509
509
@@ -563,7 +563,7 @@ def Xor(n):
563
563
return Parity (2 , n , name = "xor" )
564
564
565
565
def ContinuousXor (n ):
566
- "2 inputs are chosen uniformly form (0.0 .. 2.0]; output is xor of ints."
566
+ "2 inputs are chosen uniformly from (0.0 .. 2.0]; output is xor of ints."
567
567
examples = []
568
568
for i in range (n ):
569
569
x , y = [random .uniform (0.0 , 2.0 ) for i in '12' ]
0 commit comments