DEAP / deap

Distributed Evolutionary Algorithms in Python
http://deap.readthedocs.org/
GNU Lesser General Public License v3.0
5.75k stars 1.12k forks source link

RuntimeWarning in TPOT unit tests with deap v1.2.2 #243

Open weixuanfu opened 6 years ago

weixuanfu commented 6 years ago

Thank you for the nice project!

In this ci test for TPOT with the latest deap (v1.2.2), there are a lot runtimewarning messages as below

/home/travis/miniconda/envs/testenv/lib/python3.6/site-packages/deap/creator.py:141: RuntimeWarning: A class named 'FitnessMulti' has already been created and it will be overwritten. Consider deleting previous creation of that class or rename it.
  RuntimeWarning)
/home/travis/miniconda/envs/testenv/lib/python3.6/site-packages/deap/creator.py:141: RuntimeWarning: A class named 'Individual' has already been created and it will be overwritten. Consider deleting previous creation of that class or rename it.
  RuntimeWarning)

It is weird that these warning messages only showed in python3.6 but not in python2.7 on both Windows and Linux. And these warning messages have not happened before with previous version of deap (e.g. 1.0.2). Any suggestions? Thanks.

weixuanfu commented 6 years ago

The codes below can reproduce the warning message:

from tpot import TPOTClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
import numpy as np

iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(iris.data.astype(np.float64),
    iris.target.astype(np.float64), train_size=0.75, test_size=0.25)

tpot1 = TPOTClassifier(generations=1, population_size=10, verbosity=2)
tpot1.fit(X_train, y_train)
# no warning message during 1st fit()
tpot2 = TPOTClassifier(generations=1, population_size=10, verbosity=2)
tpot2.fit(X_train, y_train)
# warning message shows up during 2nd fit()