Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5308a2e

Browse files
committed
Spelling/typo/minor style tweaks.
1 parent 869046e commit 5308a2e

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

csp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def parse_neighbors(neighbors, vars=[]):
287287
dict[var] = []
288288
specs = [spec.split(':') for spec in neighbors.split(';')]
289289
for (A, Aneighbors) in specs:
290-
A = A.strip();
290+
A = A.strip()
291291
dict.setdefault(A, [])
292292
for B in Aneighbors.split():
293293
dict[A].append(B)

learning.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class DataSet:
1515
d.target The attribute that a learning algorithm will try to predict.
1616
By default the final attribute.
1717
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
1919
values for the corresponding attribute. If None, it
2020
is computed from the known examples by self.setproblem.
2121
If not None, an erroneous value raises ValueError.
@@ -42,7 +42,7 @@ def __init__(self, examples=None, attrs=None, target=-1, values=None,
4242
else:
4343
self.examples = examples
4444
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.
4646
if not attrs and self.examples:
4747
attrs = range(len(self.examples[0]))
4848
self.attrs = attrs
@@ -57,7 +57,7 @@ def setproblem(self, target, inputs=None, exclude=()):
5757
"""Set (or change) the target and/or inputs.
5858
This way, one DataSet can be used multiple ways. inputs, if specified,
5959
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.
6161
Also computes the list of possible values, if that wasn't done yet."""
6262
self.target = self.attrnum(target)
6363
exclude = map(self.attrnum, exclude)
@@ -156,7 +156,7 @@ def predict(self, example):
156156
class NaiveBayesLearner(Learner):
157157

158158
def train(self, dataset):
159-
"""Just count the target/attr/val occurences.
159+
"""Just count the target/attr/val occurrences.
160160
Count how many times each value of each attribute occurs.
161161
Store count in N[targetvalue][attr][val]. Let N[attr][None] be the
162162
sum over all vals."""
@@ -291,7 +291,7 @@ def decision_tree_learning(self, examples, attrs, default=None):
291291
return default
292292
elif self.all_same_class(examples):
293293
return examples[0][self.dataset.target]
294-
elif len(attrs) == 0:
294+
elif len(attrs) == 0:
295295
return self.majority_value(examples)
296296
else:
297297
best = self.choose_attribute(attrs, examples)
@@ -410,7 +410,7 @@ class EnsembleLearner(Learner):
410410
"""Given a list of learning algorithms, have them vote."""
411411

412412
def __init__(self, learners=[]):
413-
self.learners=learners
413+
self.learners = learners
414414

415415
def train(self, dataset):
416416
for learner in self.learners:
@@ -481,7 +481,7 @@ def score(learner, size):
481481
for size in sizes]
482482

483483
#______________________________________________________________________________
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.
485485

486486
orings = DataSet(name='orings', target='Distressed',
487487
attrnames="Rings Distressed Temp Pressure Flightnum")
@@ -502,8 +502,8 @@ def score(learner, size):
502502
def RestaurantDataSet(examples=None):
503503
"Build a DataSet of Restaurant waiting examples."
504504
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')
507507

508508
restaurant = RestaurantDataSet()
509509

@@ -563,7 +563,7 @@ def Xor(n):
563563
return Parity(2, n, name="xor")
564564

565565
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."
567567
examples = []
568568
for i in range(n):
569569
x, y = [random.uniform(0.0, 2.0) for i in '12']

logic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ def WalkSAT(clauses, p=0.5, max_flips=10000):
749749
if probability(p):
750750
sym = random.choice(prop_symbols(clause))
751751
else:
752-
## Flip the symbol in clause that miximizes number of sat. clauses
752+
## Flip the symbol in clause that maximizes number of sat. clauses
753753
raise NotImplementedError
754754
model[sym] = not model[sym]
755755

probability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __setitem__(self, values, p):
104104
if isinstance(values, dict):
105105
values = [values[var] for var in self.variables]
106106
self.prob[values] = p
107-
for var,val in zip(self.variables, values):
107+
for var, val in zip(self.variables, values):
108108
if val not in self.vals[var]:
109109
self.vals[var].append(val)
110110

text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ class PermutationDecoder:
320320
common one-letter words, etc.); etc.
321321
We could represent a search state as a permutation of the 26 letters,
322322
and alter the solution through hill climbing. With an initial guess
323-
based on unigram probabilities, this would probably fair well. However,
323+
based on unigram probabilities, this would probably fare well. However,
324324
I chose instead to have an incremental representation. A state is
325325
represented as a letter-to-letter map; for example {'z': 'e'} to
326326
represent that 'z' will be translated to 'e'

0 commit comments

Comments
 (0)