Closed davekirby closed 7 years ago
I just ran into this issue too.
Running the example on the README file just gives this error:
Running it in Python 3.5.1 on OSX in a Jupyter notebook.
Types [2, 2, 1] and maxint [24, 24, 0] detected
--- Evolve in 625 possible combinations ---
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-9446b1aeccef> in <module>()
28 generations_number=5,
29 n_jobs=4)
---> 30 cv.fit(X, y)
/usr/local/lib/python3.5/site-packages/evolutionary_search/__init__.py in fit(self, X, y)
286 self.best_params_ = None
287 for possible_params in self.possible_params:
--> 288 self._fit(X, y, possible_params)
289 if self.refit:
290 self.best_estimator_ = clone(self.estimator)
/usr/local/lib/python3.5/site-packages/evolutionary_search/__init__.py in _fit(self, X, y, parameter_dict)
346 pop, logbook = algorithms.eaSimple(pop, toolbox, cxpb=0.5, mutpb=0.2,
347 ngen=self.generations_number, stats=stats,
--> 348 halloffame=hof, verbose=self.verbose)
349
350 current_best_score_ = hof[0].fitness.values[0]
/usr/local/lib/python3.5/site-packages/deap/algorithms.py in eaSimple(population, toolbox, cxpb, mutpb, ngen, stats, halloffame, verbose)
145 # Evaluate the individuals with an invalid fitness
146 invalid_ind = [ind for ind in population if not ind.fitness.valid]
--> 147 fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
148 for ind, fit in zip(invalid_ind, fitnesses):
149 ind.fitness.values = fit
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/multiprocessing/pool.py in map(self, func, iterable, chunksize)
258 in a list that is returned.
259 '''
--> 260 return self._map_async(func, iterable, mapstar, chunksize).get()
261
262 def starmap(self, func, iterable, chunksize=None):
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/multiprocessing/pool.py in get(self, timeout)
606 return self._value
607 else:
--> 608 raise self._value
609
610 def _set(self, i, obj):
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/multiprocessing/pool.py in _handle_tasks(taskqueue, put, outqueue, pool, cache)
383 break
384 try:
--> 385 put(task)
386 except Exception as e:
387 job, ind = task[:2]
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/multiprocessing/connection.py in send(self, obj)
204 self._check_closed()
205 self._check_writable()
--> 206 self._send_bytes(ForkingPickler.dumps(obj))
207
208 def recv_bytes(self, maxlength=None):
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/multiprocessing/reduction.py in dumps(cls, obj, protocol)
48 def dumps(cls, obj, protocol=None):
49 buf = io.BytesIO()
---> 50 cls(buf, protocol).dump(obj)
51 return buf.getbuffer()
52
TypeError: can't pickle dict_items objects
Same problem here. Is there any solution?
I just fixed the compatibility with pyhthon3. Just do a pip install sklearn-deap --upgrade
There are two old-style print statements in
__init__.py
that break compatibility with Python 3.I added brackets to turn them into function calls and that seemed to fix it, but I have not done extensive testing to see if there are any other compatibility issues.