4

I need to load the Multivariate Adaptive Regression Splines (MARS) algorithm from a library called pyearth on Google Colab. This is what I want to do:

# Import model from library
from pyearth import Earth

# Initialize model
reg = Earth()

However, Google Colab does not have that library by default. I get the following error prompt when I try import pyearth:

ModuleNotFoundError: No module named 'pyearth'

I therefore tried to install it using !pip, but, as seen below, it does not work either.

# Instal `pyearth`
!pip install pyearth # Runs smoothly

# Import Earth
from pyearth import Earth

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

Oddly enough, import pyearth does work.

This post addresses a very similar issua and remains unresolved. The only answer available did not work for me.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Arturo Sbr
  • 5,567
  • 4
  • 38
  • 76
  • 1
    even if you try the git installation in local, it errors out which makes me believe that there are compatibility issues. The hard way would be based on setup.py, create an environment that is compatible with it or find the alternative library. – simpleApp Apr 27 '21 at 14:33
  • You are right. For anyone interested, I opened an [issue](https://github.com/scikit-learn-contrib/py-earth/issues/216) on GitHub. – Arturo Sbr Apr 28 '21 at 14:28
  • 1
    Thank you @arturo-sbr, let me upvote the question to help SO members. – simpleApp Apr 28 '21 at 14:50

1 Answers1

4

As it turns out pyearth is a library for earth science. In other words, pyearth has nothing to do with Multivariate Adaptive Regression Splines (MARS).

The library that has the MARS algorithm is sklearn-contrib-py-earth. This is how you can import it on Google Colab:

# Clone repo
!pip install git+https://github.com/scikit-learn-contrib/py-earth@v0.2dev

# Import model
from pyearth import Earth
Arturo Sbr
  • 5,567
  • 4
  • 38
  • 76