Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-arenas committed Nov 17, 2021
1 parent b5ba016 commit d39d3c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 0 additions & 2 deletions sklearn_genetic/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,6 @@ def eaMuPlusLambda(
halloffame.update(population)

record = stats.compile(population) if stats is not None else {}
print("INSTANCE")
print(isinstance(record["fitness"], np.ndarray))
if isinstance(record["fitness"], np.ndarray):
record = {key: value[0] for key, value in record.items()}

Expand Down
10 changes: 5 additions & 5 deletions sklearn_genetic/genetic_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from sklearn.utils.validation import check_is_fitted
from sklearn.metrics import check_scoring
from sklearn.exceptions import NotFittedError
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection._search import BaseSearchCV
from sklearn.model_selection._split import check_cv

Expand Down Expand Up @@ -980,11 +979,12 @@ def evaluate(self, individual):
The second one is the number of features selected
"""
current_generation_params = {"features": individual}

local_estimator = clone(self.estimator)

bool_individual = np.array(individual, dtype=bool)

current_generation_params = {"features": bool_individual}

local_estimator = clone(self.estimator)
n_selected_features = np.sum(individual)

# Compute the cv-metrics using only the selected features
Expand Down Expand Up @@ -1070,7 +1070,7 @@ def fit(self, X, y, callbacks=None):
# Update the _n_iterations value as the algorithm could stop earlier due a callback
self._n_iterations = n_gen

self.best_features_ = self._hof[0]
self.best_features_ = np.array(self._hof[0], dtype=bool)

self.cv_results_ = create_feature_selection_cv_results_(
logbook=self.logbook,
Expand Down

0 comments on commit d39d3c0

Please sign in to comment.