Skip to content

Instantly share code, notes, and snippets.

@ababycat
Last active March 17, 2018 13:26
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 ababycat/c4e4110e9e02a6d6adb99e377453f789 to your computer and use it in GitHub Desktop.
Save ababycat/c4e4110e9e02a6d6adb99e377453f789 to your computer and use it in GitHub Desktop.
show f1 score use matplotlib in python
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def f1_score(precision, recall):
return precision*recall/(precision+recall)
x = np.arange(1e-3, 1, 1e-3)
y = np.arange(1e-3, 1, 1e-3)
X, Y = np.meshgrid(x, y)
Z = f1_score(X, Y)
fig = plt.figure()
ax = Axes3D(fig)
ax.plot_surface(X, Y, Z)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment