From efe419eb968d7f25e487f1d22078ef36f2f042e5 Mon Sep 17 00:00:00 2001 From: Guilherme Aldeia Date: Tue, 15 Aug 2023 14:41:59 -0400 Subject: [PATCH] Fixed incorrect variable being used in mutation --- src/brush/deap_api/nsga2.py | 5 +++-- src/brush/estimator.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/brush/deap_api/nsga2.py b/src/brush/deap_api/nsga2.py index a1a8c8b2..b569ad47 100644 --- a/src/brush/deap_api/nsga2.py +++ b/src/brush/deap_api/nsga2.py @@ -68,11 +68,12 @@ def calculate_statistics(ind): offspring = [] for ind1, ind2 in zip(parents[::2], parents[1::2]): + off1, off2 = None, None if rnd_flt() < CXPB: off1, off2 = toolbox.mate(ind1, ind2) else: - off1 = toolbox.mutate(off1) - off2 = toolbox.mutate(off2) + off1 = toolbox.mutate(ind1) + off2 = toolbox.mutate(ind2) # avoid inserting empty solutions if off1 is not None: offspring.extend([off1]) diff --git a/src/brush/estimator.py b/src/brush/estimator.py index ab988bbe..2039577d 100644 --- a/src/brush/estimator.py +++ b/src/brush/estimator.py @@ -189,7 +189,7 @@ def fit(self, X, y): """ _brush.set_params(self.get_params()) - if self.random_state != None: + if self.random_state is not None: _brush.set_random_state(self.random_state) self.data_ = self._make_data(X,y, validation_size=self.validation_size)