Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: The gp.generate function tried to add a primitive of type '<type 'object'>', but there is none available. #141

Closed
pierluigi-failla opened this issue May 10, 2016 · 18 comments
Labels

Comments

@pierluigi-failla
Copy link

pierluigi-failla commented May 10, 2016

Trying to run the tutorial IRIS.ipynb I got an IndexError

Context of the issue

I tried to run the notebook, running the 4th cell I got the error.

Process to reproduce the issue

Open IRIS.ipynb in Jupyter and run all

Expected result

The same output as in the Tutorial folder.

Current result

IndexError: The gp.generate function tried to add a primitive of type '<type 'object'>', but there is none available.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-5-bd6041f6f821> in <module>()
      1 tpot = TPOT(generations=2)
----> 2 tpot.fit(X_train, y_train)
      3 print(tpot.score(X_test, y_test))

/xxx/python2.7/site-packages/tpot/tpot.pyc in fit(self, features, classes)
    229             self._toolbox.register('evaluate', self._evaluate_individual, training_testing_data=training_testing_data)
    230 
--> 231             pop = self._toolbox.population(n=self.population_size)
    232 
    233             def pareto_eq(ind1, ind2):

/xxx/python2.7/site-packages/deap/tools/init.pyc in initRepeat(container, func, n)
     21     See the :ref:`list-of-floats` and :ref:`population` tutorials for more examples.
     22     """
---> 23     return container(func() for _ in xrange(n))
     24 
     25 def initIterate(container, generator):

/xxx/python2.7/site-packages/deap/tools/init.pyc in <genexpr>((_,))
     21     See the :ref:`list-of-floats` and :ref:`population` tutorials for more examples.
     22     """
---> 23     return container(func() for _ in xrange(n))
     24 
     25 def initIterate(container, generator):

/xxx/python2.7/site-packages/deap/tools/init.pyc in initIterate(container, generator)
     47     more examples.
     48     """
---> 49     return container(generator())
     50 
     51 def initCycle(container, seq_func, n=1):

/xxx/python2.7/site-packages/deap/gp.pyc in genHalfAndHalf(pset, min_, max_, type_)
    536     """
    537     method = random.choice((genGrow, genFull))
--> 538     return method(pset, min_, max_, type_)
    539 
    540 def genRamped(pset, min_, max_, type_=__type__):

/xxx/python2.7/site-packages/deap/gp.pyc in genGrow(pset, min_, max_, type_)
    521         return depth == height or \
    522                (depth >= min_ and random.random() < pset.terminalRatio)
--> 523     return generate(pset, min_, max_, condition, type_)
    524 
    525 def genHalfAndHalf(pset, min_, max_, type_=__type__):

/xxx/python2.7/site-packages/deap/gp.pyc in generate(pset, min_, max_, condition, type_)
    581         else:
    582             try:
--> 583                 prim = random.choice(pset.primitives[type_])
    584             except IndexError:
    585                 _, _, traceback = sys.exc_info()

/xxx/python2.7/random.pyc in choice(self, seq)
    273     def choice(self, seq):
    274         """Choose a random element from a non-empty sequence."""
--> 275         return seq[int(self.random() * len(seq))]  # raises IndexError if seq is empty
    276 
    277     def shuffle(self, x, random=None):

IndexError: The gp.generate function tried to add a primitive of type '<type 'object'>', but there is none available.```
@rhiever
Copy link
Contributor

rhiever commented May 12, 2016

I can't reproduce this error in Python 2.7 nor Python 3.5 with the TPOT v0.3.0. What version are you running? Are you running it on top of an up-to-date Anaconda install?

@pierluigi-failla
Copy link
Author

No I'm not running in Anconda, here is my setting:

  • deap==1.0.1
  • numpy==1.8.1
  • scikit-learn==0.17.1
  • scipy==0.14.0
  • TPOT==0.3.0
  • xgboost==0.4a30

and Python 2.7.11. Do I miss something?

@rhiever
Copy link
Contributor

rhiever commented May 13, 2016

Here are the package versions that we're running for Python 2:

Python 2.7.11
numpy 1.11.0
scipy 0.17.0
sklearn 0.17.1
pandas 0.18.1
deap 1.0
xgboost 0.4
update_checker 0.11

Do you get this error every time you run the code in the notebook?

@pierluigi-failla
Copy link
Author

Yes, all of the three notebooks are affected by the same issue. I'm trying to compare with your deps:

Python 2.7.11 2.7.11
numpy 1.11.0 1.8.1
scipy 0.17.0 0.14.0
sklearn 0.17.1 0.17.1
pandas 0.18.1 0.17.1
deap 1.0 1.0.1
xgboost 0.4 0.4a30
update_checker 0.11 I do not have this

So it seems that we have few mismatched versions. I will try to update my reqs if possibile. In the meanwhile it seems that there is some empty list going around...

@pierluigi-failla
Copy link
Author

Also updating deps the issues is still there. I replicated your reqs except for update_checker that I do not think is really relevant.

@rhiever
Copy link
Contributor

rhiever commented May 14, 2016

The only major difference between our setups - as far as I can tell - is
that we use Anaconda and your install doesn't. Can you replicate this error
on your machine with an Anaconda install?

On Friday, May 13, 2016, Pierluigi Failla notifications@github.com wrote:

Also updating deps the issues is still there. I replicated your reqs
except for update_checker that I do not think is really relevant.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#141 (comment)

Randal S. Olson, Ph.D.
Postdoctoral Researcher, Institute for Biomedical Informatics
University of Pennsylvania

E-mail: rso@randalolson.com | Twitter: @randal_olson
https://twitter.com/randal_olson
http://www.randalolson.com

@pierluigi-failla
Copy link
Author

I can try to do that, but I really like to use it in my own environment. Do you plan to release TPOT only for Anaconda env?

@rhiever
Copy link
Contributor

rhiever commented May 15, 2016

Technically TPOT should work fine with any Python install, but the main
reason that I limit my technical support to Anaconda is because there's a
million ways that Python installs can go wrong. Anaconda makes those
installs easy, clean, and most importantly consistent.

The reason I brought up Anaconda in this case is to see whether you can
reproduce the issue in your system with an Anaconda install. If you can't,
then we know it's an issue with your Python install rather than TPOT itself.

On Saturday, May 14, 2016, Pierluigi Failla notifications@github.com
wrote:

I can try to do that, but I really like to use it in my own environment.
Do you plan to release TPOT only for Anaconda env?


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#141 (comment)

Randal S. Olson, Ph.D.
Postdoctoral Researcher, Institute for Biomedical Informatics
University of Pennsylvania

E-mail: rso@randalolson.com | Twitter: @randal_olson
https://twitter.com/randal_olson
http://www.randalolson.com

@rhiever
Copy link
Contributor

rhiever commented May 16, 2016

Perplexing. Do you use a specific random number seed to replicate the issue, or it literally happens every time?

@pierluigi-failla
Copy link
Author

All the time

@rhiever
Copy link
Contributor

rhiever commented May 16, 2016

I'm curious: Is your TPOT install from a clone of the current master branch?

@pierluigi-failla
Copy link
Author

I actually: pip install TPOT==0.3.0 ...

@rhiever
Copy link
Contributor

rhiever commented May 16, 2016

Ok. An Anaconda install is probably the most promising next step then.

On Monday, May 16, 2016, Pierluigi Failla notifications@github.com wrote:

I actually: pip install TPOT==0.3.0 ...


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#141 (comment)

Randal S. Olson, Ph.D.
Postdoctoral Researcher, Institute for Biomedical Informatics
University of Pennsylvania

E-mail: rso@randalolson.com | Twitter: @randal_olson
https://twitter.com/randal_olson
http://www.randalolson.com

@rhiever
Copy link
Contributor

rhiever commented May 17, 2016

Wanted to ping you to see if you tried an Anaconda install and could still reproduce the bug there. Very curious to see what's causing this error. I've run several thousand instances of TPOT on over 200 different data sets and never experienced this error.

@pierluigi-failla
Copy link
Author

I tried with Anaconda on Win 10:
conda install numpy scipy pandas scikit-learn
conda run -- pip install deap
conda run -- pip install xgboost
but the last one failed. I lately noticed that xgboost claims "pip installation may not work on some windows environment" and in fact I did not manage to install it. I guess I will try tpot again in the future, it seems really promising.

@rhiever
Copy link
Contributor

rhiever commented May 17, 2016

That's a shame about xgboost on Windows. Have seen several people have that issue. I might consider dropping xgboost from TPOT because of that.

@rhiever rhiever closed this as completed May 17, 2016
@JWWright86
Copy link

Xgboost has been disabled from pip by the authors.

pip installation on windows is currently disabled for further investigation, please install from github.

To install on a Windows 32-bit environment you need to build from source. These are the steps I took (note that I do not use Anaconda as my Python installation either.)

  • Download and install MinGW-64: http://sourceforge.net/projects/mingw-w64/
  • On the first screen of the install prompt make sure you set the Architecture to i386 and the Threads to win32
  • add mingw to your environment path
  • git clone the xgboost repository
  • cd into the xgboost main directory
  • type the following at a command prompt
git submodule init 
git submodule update`
cp make/mingw64.mk config.mk
notepad config.mk
  • Then edit the export CXX and CC statements to remove the -m64 flags.
  • again at a command prompt type

make -j4

If the build finishes successfully, you should have a file called xgboost.exe located in the project root.
You should be able to double click on this file and have a cmd window briefly appear with no errors. If you get an error about this file not being able to be run on this system, check that the -m64 compilation flags were removed.

To install the Python package do the following

cd python-package
python setup.py install

Hopefully at this stage you should be able to import xgboost from python.

For 64 bit architecture the build is similar except of course you don't want to remove the the -m64 flags in the build config file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants