You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[nltk_data] Downloading package stopwords to
[nltk_data] C:\Users\ketan\AppData\Roaming\nltk_data...
[nltk_data] Package stopwords is already up-to-date!
C:\Users\ketan\Anaconda3\lib\site-packages\sklearn\cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
C:\Users\ketan\Anaconda3\lib\site-packages\sklearn\ensemble\weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an internal NumPy module and should not be imported. It will be removed in a future NumPy release.
from numpy.core.umath_tests import inner1d
Splitting the dataset into the Training set and Test set
X_train, X_test, y_train, y_test=train_test_split(X, y, test_size=0.20, random_state=0)
defresultPrintHelper(classifier, X_test, y_test):
# Predicting the Test set resultsy_pred=classifier.predict(X_test)
print("Accuracy score is: {}".format(accuracy_score(y_test, y_pred)))
print("Precision score is: {}".format(precision_score(y_test, y_pred)))
print("Recall score is: {}".format(recall_score(y_test, y_pred)))
print("F1 score is: {}".format(f1_score(y_test, y_pred)))
print("------Confusion Matirx------")
print(confusion_matrix(y_test, y_pred))
Classifiers
1. Naive Bayes
# Fitting Naive Bayes to the Training setbayesClassifier=GaussianNB()
bayesClassifier.fit(X_train, y_train)
resultPrintHelper(bayesClassifier, X_test, y_test)
Accuracy score is: 0.73
Precision score is: 0.6842105263157895
Recall score is: 0.883495145631068
F1 score is: 0.7711864406779663
------Confusion Matirx------
[[55 42]
[12 91]]
Accuracy score is: 0.67
Precision score is: 0.7176470588235294
Recall score is: 0.5922330097087378
F1 score is: 0.648936170212766
------Confusion Matirx------
[[73 24]
[42 61]]
Accuracy score is: 0.705
Precision score is: 0.8333333333333334
Recall score is: 0.5339805825242718
F1 score is: 0.650887573964497
------Confusion Matirx------
[[86 11]
[48 55]]
About
Review Classification project is about determining whether the review is positive or negative.