Created
June 5, 2017 17:06
-
-
Save cadrev/cb6ebe8101faa4b3f858c699adbe5566 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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