IPython ImportError: cannot import name Layout
IPython ImportError: cannot import name Layout
我正在尝试基于 this article
的 CatBoost
在它的代码中,CatBoost 在 model.fit()
中有 plot
,所以我想在我的 IPython.
上尝试一下
这是我的 CatBoost 代码:
from catboost import CatBoostRegressor
# indicate categorical features for CatBoost
categorical_features_indices = np.where(X.dtypes != np.float)[0]
model=CatBoostRegressor(iterations=50, depth=3, learning_rate=0.1,
loss_function='RMSE')
model.fit(X_train, y_train,
cat_features=categorical_features_indices,
use_best_model=True,
eval_set=(X_validation, y_validation), plot=True)
但是,它无法显示任何情节并一直给我错误:
我确实安装了 ipywidgets 和 ipython。
你知道如何处理这个问题吗?
终于把问题解决了,现在可以看到这个剧情了
在我的例子中,解决方案是安装 Conda
并创建一个 conda 虚拟环境,然后通过 Conda 安装 ipywidgets
。
让我在这里写下所有细节,希望对您有所帮助。 这可能只会帮助 Mac 用户
- 在此处下载 Conda:https://www.continuum.io/downloads
- 将 conda 添加到
$PATH
中:How to run Conda?
- 创建 Conda 虚拟环境
conda create -n yourenvname python=x.x anaconda
- 激活conda虚拟环境
source activate yourenvname
- 在此虚拟环境中安装 IPython Notebook(如果您已经有用户 python
virtualenv
并为此安装了 IPython,则可以跳过此步骤):
(yourenvname)$ pip install jupyter
(yourenvname)$ pip install ipykernel
(yourenvname)$ python -m ipykernel install --user --name testenv --display-name "Python2 (yourenvname)"
,如果你有多个ipykernel,这里testenv
也要改成别的名字
- 安装ipywidgets,
(yourenvname)$ conda install ipywidgets --no-deps
- 安装 catboost,
(yourenvname)$ pip install catboost
- 打开 Jupyter Notebook,
jupyter notebook
并在 Python2 (yourenvname)
下创建一个新笔记本,然后它应该可以工作了
注意:如果不起作用,请在第 8 步之前,试试这个:
pip install widgetsnbextension
jupyter nbextension enable --py widgetsnbextension --sys-prefix
我正在尝试基于 this article
的 CatBoost在它的代码中,CatBoost 在 model.fit()
中有 plot
,所以我想在我的 IPython.
这是我的 CatBoost 代码:
from catboost import CatBoostRegressor
# indicate categorical features for CatBoost
categorical_features_indices = np.where(X.dtypes != np.float)[0]
model=CatBoostRegressor(iterations=50, depth=3, learning_rate=0.1,
loss_function='RMSE')
model.fit(X_train, y_train,
cat_features=categorical_features_indices,
use_best_model=True,
eval_set=(X_validation, y_validation), plot=True)
但是,它无法显示任何情节并一直给我错误:
我确实安装了 ipywidgets 和 ipython。 你知道如何处理这个问题吗?
终于把问题解决了,现在可以看到这个剧情了
在我的例子中,解决方案是安装 Conda
并创建一个 conda 虚拟环境,然后通过 Conda 安装 ipywidgets
。
让我在这里写下所有细节,希望对您有所帮助。 这可能只会帮助 Mac 用户
- 在此处下载 Conda:https://www.continuum.io/downloads
- 将 conda 添加到
$PATH
中:How to run Conda? - 创建 Conda 虚拟环境
conda create -n yourenvname python=x.x anaconda
- 激活conda虚拟环境
source activate yourenvname
- 在此虚拟环境中安装 IPython Notebook(如果您已经有用户 python
virtualenv
并为此安装了 IPython,则可以跳过此步骤):(yourenvname)$ pip install jupyter
(yourenvname)$ pip install ipykernel
(yourenvname)$ python -m ipykernel install --user --name testenv --display-name "Python2 (yourenvname)"
,如果你有多个ipykernel,这里testenv
也要改成别的名字
- 安装ipywidgets,
(yourenvname)$ conda install ipywidgets --no-deps
- 安装 catboost,
(yourenvname)$ pip install catboost
- 打开 Jupyter Notebook,
jupyter notebook
并在Python2 (yourenvname)
下创建一个新笔记本,然后它应该可以工作了
注意:如果不起作用,请在第 8 步之前,试试这个:
pip install widgetsnbextension
jupyter nbextension enable --py widgetsnbextension --sys-prefix