Skip to content

Instantly share code, notes, and snippets.

@sadimanna
Created June 20, 2020 20:39
Show Gist options
  • Select an option

  • Save sadimanna/e955fffeabf370f0eaa0f382f4e28d65 to your computer and use it in GitHub Desktop.

Select an option

Save sadimanna/e955fffeabf370f0eaa0f382f4e28d65 to your computer and use it in GitHub Desktop.
def prcurve(y,pred):
P = []
R = []
thresholds = np.arange(0.0,1.0+0.01,0.01)
for th in thresholds:
P.append(precision(y,pred,th))
R.append(recall(y,pred,th))
plt.figure(figsize=(10,10))
plt.plot(R,P,linewidth=2)
plt.xlim(0.0, 1.0)
plt.ylim(0.0, 1.0)
plt.xlabel("Recall",fontsize=12)
plt.ylabel("Precision",fontsize=12)
plt.legend(fontsize=10, loc='best')
plt.title("Precision Recall Curve",fontsize=12)
plt.savefig('Precision_Recall_Curve.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment