From 6a8119ca000feddec0938384041e88e9f4e5381f Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Sun, 5 Jul 2020 12:18:38 +0530 Subject: [PATCH] sahh modified navie_id --- naive_bayes/nb_author_id.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/naive_bayes/nb_author_id.py b/naive_bayes/nb_author_id.py index f69d57d8408..5b348a67b5e 100644 --- a/naive_bayes/nb_author_id.py +++ b/naive_bayes/nb_author_id.py @@ -11,7 +11,7 @@ """ import sys -from time import time +from time import ti sys.path.append("../tools/") from email_preprocess import preprocess @@ -24,8 +24,17 @@ -######################################################### ### your code goes here ### +from sklearn.naive_bayes import GaussianNB +clf=GaussianNB() +t0=time() +clf.fit(features_train[0:1400],labels_train[0:1400]) +print("training time",round(time()-t0,3),"s") +t0=time() +pred_label= clf.predict(features_test) +print("testing time:",round(time()-t0,3),"s") +from sklearn.metrics import accuracy_score +acc=accuracy_score(labels_test,pred_label) #########################################################