Skip to content

Instantly share code, notes, and snippets.

@cadrev
Created June 5, 2017 17:06
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 cadrev/cb6ebe8101faa4b3f858c699adbe5566 to your computer and use it in GitHub Desktop.
Save cadrev/cb6ebe8101faa4b3f858c699adbe5566 to your computer and use it in GitHub Desktop.
# Create an array of Multinomial Naive Bayes
multi_class = [MultinomialNB(alpha=factor) for factor in np.concatenate((np.arange(0, 3.1, 0.1), [5, 10]))]
for nb in multi_class:
nb.fit(X_train, y_train)
import seaborn as sns
from sklearn.metrics import precision_recall_curve
from sklearn.metrics import average_precision_score
# Plot results, need mo palitan ung xlim sa pag plot.
plt.title('Precision Recall Curve')
plt.ylim((0.6,1.05))
plt.xlim((0,1))
for nb in multi_class:
precision, recall, _ = precision_recall_curve(y_test,nb.predict(X_test))
average_precision = average_precision_score(y_test, nb.predict(X_test),average="micro")
plt.plot(recall, precision)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment