Skip to content

Instantly share code, notes, and snippets.

@ychennay
Created May 12, 2019 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ychennay/dba39c9fc9be5b868c661e8698b2a375 to your computer and use it in GitHub Desktop.
Save ychennay/dba39c9fc9be5b868c661e8698b2a375 to your computer and use it in GitHub Desktop.
fig, ax1 = plt.subplots()
color = 'tab:red'
ax1.set_xlabel('λ (Inverse Model Complexity)')
ax1.set_ylabel('Prediction Bias', color=color)
ax1.plot(lambdas, bias, color=color)
ax1.tick_params(axis='y', labelcolor=color)
ax2 = ax1.twinx()
color = 'tab:blue'
ax2.set_ylabel('Prediction Variance', color=color)
ax2.plot(lambdas, variance, color=color)
ax2.tick_params(axis='y', labelcolor=color)
fig.tight_layout()
plt.title("Relationship Between Bias, Variance, and Model Complexity")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment