我需要从名为pyearth
Google Colab 的库中加载多元自适应回归样条 (MARS) 算法。这就是我想要做的:
# Import model from library
from pyearth import Earth
# Initialize model
reg = Earth()
但是,默认情况下,Google Colab 没有该库。我尝试时收到以下错误提示import pyearth
:
ModuleNotFoundError:没有名为“pyearth”的模块
因此,我尝试使用 安装它!pip
,但是如下所示,它也不起作用。
# 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)
奇怪的是,import pyearth
确实有效。
这篇文章解决了一个非常相似的问题,但仍未解决。唯一可用的答案对我不起作用。