我有一个包含50个功能的5000个产品的数据集.其中一列是"颜色",列中有100多种颜色.我正在尝试绘制一个条形图,仅显示前10种颜色以及每种颜色中有多少种产品.
top_colors = df.colors.value_counts()
top_colors[:10].plot(kind='barh')
plt.xlabel('No. of Products');
Run Code Online (Sandbox Code Playgroud)
使用Seaborn:
sns.factorplot("colors", data=df , palette="PuBu_d");
Run Code Online (Sandbox Code Playgroud)
1)有更好的方法吗?
2)我怎样才能用Seaborn复制这个?
3) How do i plot such that the highest count is at the top (i.e black at the very top of the bar chart)
我正在使用 scikit-learn 随机森林来拟合训练数据(~30mb),但我的笔记本电脑不断崩溃,耗尽应用程序内存。测试数据比训练数据大几倍。使用 Macbook Air 2GHz 8GB 内存。
有哪些方法可以解决这个问题?
rf = RandomForestClassifier(n_estimators = 100, n_jobs=4)
print "20 Fold CV Score: ", np.mean(cross_validation.cross_val_score(rf, X_train_a, y_train, cv=20, scoring='roc_auc'))
Run Code Online (Sandbox Code Playgroud)