prediction = [] for r in reviews_bigramtest: test_labels.append(r[1]) prediction.append(classifier.classify(r[0])) print("Results....") print(accuracy_score(test_labels, prediction)) print(classification_report(test_labels, prediction)) #load reviews reviews = loadReviews("imdbMovieReviews3.txt") #bigram NV without title processedReviews = textProcessing(reviews, False, 3) result = generateTrainingTestSet(processedReviews, False) reviews_training = result[0] reviews_test = result[1] ngramNaiveBayesClassifier(reviews_training, reviews_test) #bigram NV with title processedReviews = textProcessing(reviews, False, 3) result = generateTrainingTestSet(processedReviews, True) reviews_training = result[0] reviews_test = result[1] ngramNaiveBayesClassifier(reviews_training, reviews_test)
t0 = time.time() classifier_liblinear.fit(train_vectors, train_labels) t1 = time.time() prediction_liblinear = classifier_liblinear.predict(test_vectors) t2 = time.time() time_liblinear_train = t1-t0 time_liblinear_predict = t2-t1 # Print results in tabular format print("Results for LinearSVC()") print("Training time: %fs; Prediction time: %fs" % (time_liblinear_train, time_liblinear_predict)) print(accuracy_score(test_labels, prediction_liblinear)) print(classification_report(test_labels, prediction_liblinear)) #load reviews reviews = loadReviews("imdbMovieReviews3.txt") #SVM without title result = generateTrainingTestSet(reviews, False) reviews_training = result[0] reviews_test = result[1] print("SVM without Review title....") linearSVMClassifier(reviews_training, reviews_test) #SVM with title result = generateTrainingTestSet(reviews, True) reviews_training = result[0] reviews_test = result[1] print("SVM with Review title....") linearSVMClassifier(reviews_training, reviews_test)