scikit-learn-contrib / py-earth

A Python implementation of Jerome Friedman's Multivariate Adaptive Regression Splines
http://contrib.scikit-learn.org/py-earth/
BSD 3-Clause "New" or "Revised" License
458 stars 121 forks source link

Unable to import Earth on multiple platforms #216

Closed ArturoSbr closed 3 years ago

ArturoSbr commented 3 years ago

I believe there is some sort of compatibility issue with the entire module that prevents me from importing Earth from the pyearth library. This same issue is happening on cloud computing platforms, such as Google Colab or AWS EMR, as well as locally, on both Windows and MAC OS.

Here is a recent post where the user ran into the same problem. This is my own post outlining another instance of this issue.

Google Colab example

!pip install pyearth
from pyearth import Earth

ImportError: cannot import name 'Earth' from 'pyearth' (/usr/local/lib/python3.7/dist-packages/pyearth/init.py)

Windows example

from pyearth import Earth

ImportError Traceback (most recent call last)

in ----> 1 from pyearth import Earth ImportError: cannot import name 'Earth' from 'pyearth' (D:\Users\XXXXXXX\Anaconda3\lib\site-packages\pyearth\__init__.py)

Oddly enough, import pyearth runs smoothly on both platforms.

kevin-dietz commented 3 years ago

@ArturoSbr I would recommend building pyearth directly from git instead of using pip install and see if the problem persists. That is clone the repo to your machine and run python setup.py install

Depending on your python version, you may have to instead clone branch issue 191 and run python setup.py install --cythonize

bmreiniger commented 3 years ago

pips listing of pyearth is an earth-science package, not this one: https://pypi.org/project/pyearth/

To use pip to install, specify sklearn-contrib-py-earth: https://pypi.org/project/sklearn-contrib-py-earth/

(That said, I agree with @kevin-dietz, and would suggest also considering installing from the v0.2dev branch. You can do this directly with pip, e.g. pip install git+https://github.com/scikit-learn-contrib/py-earth@v0.2dev)

ArturoSbr commented 3 years ago

@bmreiniger Thank you! This worked. I am confused though. What is the difference between pyearth and sklearn-contrib-py-earth?

bmreiniger commented 3 years ago

@ArturoSbr there's absolutely no connection besides an unfortunate naming collision. pyearth on PyPI is, as you can read from the link I gave, an earth science package; this py-earth package is for spline regression, specifically the MARS algorithm (but the name is trademarked, and so this and other packages have taken to calling their implementations "earth").

ArturoSbr commented 3 years ago

That is super unfortunate. I will close the issue. Thanks for your help!