我目前正在iPython笔记本上关注analyticsvidhya.com上的初学者级贷款预测分类问题。
(https://www.analyticsvidhya.com/blog/2016/01/complete-tutorial-learn-data-science-python-scratch-2/)
我在Jupyter上使用内联Pylab。
到目前为止,我们已经对数据透视表和条形图进行了编码。但是,当我尝试绘制2个条形图时,会得到3个条形图,其中一个空白。
# pivot table
temp1 = df['Credit_History'].value_counts(ascending=True)
temp2 = df.pivot_table(values='Loan_Status',index=['Credit_History'],aggfunc=lambda x: x.map({'Y':1,'N':0}).mean())
print ('Frequency Table for Credit History:')
print (temp1)
# bar graphs
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8,4))
ax1 = fig.add_subplot(121)
ax1.set_xlabel('Credit_History')
ax1.set_ylabel('Count of Applicants')
ax1.set_title("Applicants by Credit_History")
temp1.plot(kind='bar')
ax2 = fig.add_subplot(122)
temp2.plot(kind = 'bar')
ax2.set_xlabel('Credit_History')
ax2.set_ylabel('Probability of getting loan')
ax2.set_title("Probability of getting loan by credit history")
为什么不只返回2个条形图?
当我尝试其他方法时:
“或者,也可以通过将它们组合成堆叠图表来可视化这两个图:”
temp3.plot(kind='bar', stacked=True, color=['red','blue'], grid=False)
如示例中所示,它会正确返回一个组合的条形图,但之前的2个条形图不起作用。
谢谢。
答案 0 :(得分:1)
尝试以下操作:在绘制数据框时传递轴对象
FailedPreconditionError (see above for traceback): Attempting to use
uninitialized value import/InceptionV3/Logits/Conv2d_1c_1x1/weights
[[node import/InceptionV3/Logits/Conv2d_1c_1x1/weights/read
(defined at label_image.py:33) ]]