Skip to content

Instantly share code, notes, and snippets.

@thekensta
Last active January 11, 2016 23:37
Show Gist options
  • Save thekensta/d81e7d01fd0e573f6c3e to your computer and use it in GitHub Desktop.
Save thekensta/d81e7d01fd0e573f6c3e to your computer and use it in GitHub Desktop.
Draw XKCD Plot for ROI
x1 = np.linspace(-0.5, 1.25, num=100)
x2 = np.linspace(0, 2, num=100)
def y1(x):
y = -2 * x**3 + 1.5 * x ** 2 + x
return y[np.argmax(y <0):]
def y2(x):
return 1 / (1 + np.exp(-5 * x + 4))
y1d = y1(x1)
y2d = y2(x2)
plt.xkcd()
plt.plot(y1d)
plt.plot(y2d)
plt.xlim(0, 100)
plt.xticks([0, 100], ['Random', 'Perfect'], )
plt.xlabel("Algortihm Performance")
plt.ylabel("Return")
plt.yticks([-0.3, 0, 0.9], ["Yikes", "Zip", "Loadsamoney"])
plt.annotate("Out of the box\nscikit-learn", xy=(50, 0.5), xytext=(25, -0.25),
arrowprops={"facecolor": "black", "shrink":0.05, "width":1})
plt.annotate("Some tweaking", xy=(65, 0.7), xytext=(50, 0.2),
arrowprops={"facecolor": "black", "shrink":0.05, "width":1})
plt.annotate("Custom\nRewrite", xy=(90, -0.25), xytext=(65, -0.1),
arrowprops={"facecolor": "black", "shrink":0.05, "width":1})
plt.annotate("What the data\nworld says", xy=(50, 0.8), xytext=(5, 0.6),
arrowprops={"facecolor": "black", "shrink":0.05, "width":1})
plt.title("The ROI on big data and ML")
plt.tick_params(which="both", left="off", right="off")
plt.savefig("/tmp/data-roi.png", bbox_inches='tight')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment