Skip to content

Commit

Permalink
Merge pull request DEAP#413 from loganthomas/doc_updates
Browse files Browse the repository at this point in the history
Doc updates and Docstring typo fixes
  • Loading branch information
fmder authored Oct 2, 2019
2 parents 191dbb7 + 9f55f30 commit c7d45dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions deap/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def varAnd(population, toolbox, cxpb, mutpb):
mutated version in :math:`P_\mathrm{o}`. The resulting :math:`P_\mathrm{o}`
is returned.
This variation is named *And* beceause of its propention to apply both
This variation is named *And* because of its propensity to apply both
crossover and mutation on the individuals. Note that both operators are
not applied systematicaly, the resulting individuals can be generated from
not applied systematically, the resulting individuals can be generated from
crossover only, mutation only, crossover and mutation, and reproduction
according to the given probabilities. Both probabilities should be in
:math:`[0, 1]`.
Expand Down Expand Up @@ -105,7 +105,7 @@ def eaSimple(population, toolbox, cxpb, mutpb, ngen, stats=None,
The algorithm takes in a population and evolves it in place using the
:meth:`varAnd` method. It returns the optimized population and a
:class:`~deap.tools.Logbook` with the statistics of the evolution. The
logbook will contain the generation number, the number of evalutions for
logbook will contain the generation number, the number of evaluations for
each generation and the statistics if a :class:`~deap.tools.Statistics` is
given as argument. The *cxpb* and *mutpb* arguments are passed to the
:func:`varAnd` function. The pseudocode goes as follow ::
Expand Down Expand Up @@ -217,7 +217,7 @@ def varOr(population, toolbox, lambda_, cxpb, mutpb):
selected at random from :math:`P_\mathrm{p}`, cloned and appended to
:math:`P_\mathrm{o}`.
This variation is named *Or* beceause an offspring will never result from
This variation is named *Or* because an offspring will never result from
both operations crossover and mutation. The sum of both probabilities
shall be in :math:`[0, 1]`, the reproduction probability is
1 - *cxpb* - *mutpb*.
Expand Down Expand Up @@ -269,7 +269,7 @@ def eaMuPlusLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen,
The algorithm takes in a population and evolves it in place using the
:func:`varOr` function. It returns the optimized population and a
:class:`~deap.tools.Logbook` with the statistics of the evolution. The
logbook will contain the generation number, the number of evalutions for
logbook will contain the generation number, the number of evaluations for
each generation and the statistics if a :class:`~deap.tools.Statistics` is
given as argument. The *cxpb* and *mutpb* arguments are passed to the
:func:`varOr` function. The pseudocode goes as follow ::
Expand Down Expand Up @@ -361,7 +361,7 @@ def eaMuCommaLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen,
The algorithm takes in a population and evolves it in place using the
:func:`varOr` function. It returns the optimized population and a
:class:`~deap.tools.Logbook` with the statistics of the evolution. The
logbook will contain the generation number, the number of evalutions for
logbook will contain the generation number, the number of evaluations for
each generation and the statistics if a :class:`~deap.tools.Statistics` is
given as argument. The *cxpb* and *mutpb* arguments are passed to the
:func:`varOr` function. The pseudocode goes as follow ::
Expand Down Expand Up @@ -458,7 +458,7 @@ def eaGenerateUpdate(toolbox, ngen, halloffame=None, stats=None,
function and updates the generation method with the :func:`toolbox.update`
function. It returns the optimized population and a
:class:`~deap.tools.Logbook` with the statistics of the evolution. The
logbook will contain the generation number, the number of evalutions for
logbook will contain the generation number, the number of evaluations for
each generation and the statistics if a :class:`~deap.tools.Statistics` is
given as argument. The pseudocode goes as follow ::
Expand Down
18 changes: 9 additions & 9 deletions deap/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def compileADF(expr, psets):
# GP Program generation functions #
######################################
def genFull(pset, min_, max_, type_=None):
"""Generate an expression where each leaf has a the same depth
"""Generate an expression where each leaf has the same depth
between *min* and *max*.
:param pset: Primitive set from which primitives are selected.
Expand Down Expand Up @@ -549,7 +549,7 @@ def genGrow(pset, min_, max_, type_=None):

def condition(height, depth):
"""Expression generation stops when the depth is equal to height
or when it is randomly determined that a a node should be a terminal.
or when it is randomly determined that a node should be a terminal.
"""
return depth == height or \
(depth >= min_ and random.random() < pset.terminalRatio)
Expand Down Expand Up @@ -599,7 +599,7 @@ def generate(pset, min_, max_, condition, type_=None):
:obj:`None` (default) the type of :pset: (pset.ret)
is assumed.
:returns: A grown tree with leaves at possibly different depths
dependending on the condition function.
depending on the condition function.
"""
if type_ is None:
type_ = pset.ret
Expand Down Expand Up @@ -638,8 +638,8 @@ def generate(pset, min_, max_, condition, type_=None):
######################################

def cxOnePoint(ind1, ind2):
"""Randomly select in each individual and exchange each subtree with the
point as root between each individual.
"""Randomly select crossover point in each individual and exchange each
subtree with the point as root between each individual.
:param ind1: First tree participating in the crossover.
:param ind2: Second tree participating in the crossover.
Expand Down Expand Up @@ -683,7 +683,7 @@ def cxOnePointLeafBiased(ind1, ind2, termpb):
:param ind1: First typed tree participating in the crossover.
:param ind2: Second typed tree participating in the crossover.
:param termpb: The probability of chosing a terminal node (leaf).
:param termpb: The probability of choosing a terminal node (leaf).
:returns: A tuple of two typed trees.
When the nodes are strongly typed, the operator makes sure the
Expand All @@ -699,7 +699,7 @@ def cxOnePointLeafBiased(ind1, ind2, termpb):
# No crossover on single node tree
return ind1, ind2

# Determine wether we keep terminals or primitives for each individual
# Determine whether to keep terminals or primitives for each individual
terminal_op = partial(eq, 0)
primitive_op = partial(lt, 0)
arity_op1 = terminal_op if random.random() < termpb else primitive_op
Expand Down Expand Up @@ -847,7 +847,7 @@ def mutInsert(individual, pset):


def mutShrink(individual):
"""This operator shrinks the *individual* by chosing randomly a branch and
"""This operator shrinks the *individual* by choosing randomly a branch and
replacing it with one of the branch's arguments (also randomly chosen).
:param individual: The tree to be shrinked.
Expand Down Expand Up @@ -888,7 +888,7 @@ def staticLimit(key, max_value):
mutation operators. When an invalid (over the limit) child is generated,
it is simply replaced by one of its parents, randomly selected.
This operator can be used to avoid memory errors occuring when the tree
This operator can be used to avoid memory errors occurring when the tree
gets higher than 90 levels (as Python puts a limit on the call stack
depth), because it can ensure that no tree higher than this limit will ever
be accepted in the population, except if it was generated at initialization
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/gp_symbreg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ regression methods may not work. It is conceptually a simple problem, and
therefore makes a good introductory example for the GP framework in DEAP.

All symbolic regression problems use an arbitrary data distribution, and try
to fit the most accurately the data with a symbolic formula. Usually, a
to fit the data with the most accurate symbolic formula available. Usually,
measures like the RMSE (Root Mean Square Error) or MSE (Mean Squared Error) are used to measure an
individual's fitness.

Expand Down

0 comments on commit c7d45dd

Please sign in to comment.