Ch17 Figure5


In [53]:
# Imagine someone on your data science team uses the statistic that a promotion increases shoe sales by 5,000 orders. That might sound impressive. The only thing that's missing is a measurement of scale. You need to ask a key question. How many orders does the site typically have each month? If it's 50,000 then this is a pretty good argument that you had a successful promotion. If it's 5 million then it probably didn't have much of an impact. You'll also see this with percentages. Maybe someone on the team says that red shoe sales went up by 500%. That's pretty impressive. Unless of course she went from selling two orders of red shoes to ten.

In [1]:
%matplotlib inline
sns.set_style("white")
cm = sns.color_palette('Blues', 2)

f, ax = plt.subplots(2,1, figsize=(6,6))

ax1 = ax[1]
ax = ax[0]
ax2 = ax.twinx()

ax.bar(left= np.arange(3), height=[0, 55000, 0], color=cm[0]);
ax2.bar(left= [3,4], height=[0, 5005000], color=cm[0]);
ax.bar(left= [0,1], height=[50000, 50000], color=cm[1]);
ax2.bar(left=[3,4], height=[5000000, 5000000], color=cm[1]);
ax.legend(['with promotion', 'without promotion'], bbox_to_anchor=[1.65,1])

ax.set_title('5000 surge in total sales of \n 50000 versus 500000');
ax.set_xticks(np.arange(5)+.5)
ax.set_xticklabels(['total sales \n 50000', '5000 surge in sales \n on top of 50000', '', 'total sales \n 5000000', '5000 surge in sales \n on top of 500000'], rotation=45)
ax.set_ylabel('on a scale of 50000');
ax2.set_ylabel('on a scale of 5000000');

ax1.bar(left = np.arange(3), height=[.1,0,.001], color = cm[0]);
ax1.set_xticks(np.arange(3)+.3)
ax1.set_xticklabels(['1/10 change \n of 5000/50000', '','1/1000 change \n 5000/5000000'], rotation=45)
ax1.set_ylabel('on a scale of 50000');
ax1.set_title('percentage change comparison');
ax1.set_ylim(0,.101);

f.tight_layout()
f.savefig('svg_output/ch17_fig5.svg', format='svg')


Comparing 5000 surge on a base of 5000 versus 5000000. Notice on the top, you can barely notice the surge on a five million base. Similarly, looking at percentage change, 5000 increase on the basis of five million is barely noticeable.