小编Ele*_*hys的帖子

Pycharm中没有名为'pandas'的模块

我阅读了所有的主题,但我无法解决我的问题:

     Traceback (most recent call last):
     File "/home/.../.../.../reading_data.py", line 1, in <module>
     import pandas as pd
     ImportError: No module named pandas     
Run Code Online (Sandbox Code Playgroud)

这是我的环境:

Ubuntu 14.04

Pycharm版本:2016.1.4

Python版本:2.7.10

熊猫版:0.18.1

熊猫也在Jupyter的Anaconda工作.任何人都可以建议我如何解决这个问题?

python module pycharm pandas sklearn-pandas

10
推荐指数
1
解决办法
4万
查看次数

如何用树木森林标记特征重要性?

我使用sklearn绘制树木森林的特征重要性.数据框名为"heart".这里是提取已排序功能列表的代码:

importances = extc.feature_importances_
indices = np.argsort(importances)[::-1]
print("Feature ranking:")

for f in range(heart_train.shape[1]):
    print("%d. feature %d (%f)" % (f + 1, indices[f], importances[indices[f]]))
Run Code Online (Sandbox Code Playgroud)

然后我用这种方式绘制列表:

f, ax = plt.subplots(figsize=(11, 9))
plt.title("Feature ranking", fontsize = 20)
plt.bar(range(heart_train.shape[1]), importances[indices],
    color="b", 
    align="center")
plt.xticks(range(heart_train.shape[1]), indices)
plt.xlim([-1, heart_train.shape[1]])
plt.ylabel("importance", fontsize = 18)
plt.xlabel("index of the feature", fontsize = 18)
Run Code Online (Sandbox Code Playgroud)

我得到一个这样的情节:

在此输入图像描述

我的问题是:我怎么能用功能的名称替换功能的NUMBER才能使情节变得更容易理解?我试图转换包含该功能名称的字符串(这是数据框每列的名称),但我无法达到目标.

谢谢

python numpy matplotlib scikit-learn sklearn-pandas

8
推荐指数
1
解决办法
5380
查看次数