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.
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/[email protected]
# Import model
from pyearth import Earth