This file contains 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
from flask import Flask, jsonify, request, json | |
from flask_pymongo import PyMongo | |
from bson.objectid import ObjectId | |
from datetime import datetime | |
from flask_bcrypt import Bcrypt | |
# from flask_cors import CORS | |
# from flask_jwt_extended import JWTManager | |
app = Flask(__name__) |
This file contains 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
#!pip install afinn | |
from afinn import Afinn | |
afn = Afinn() | |
# Predicting sentiment on our reviews | |
sentiment_polarity = [afn.score(review) for review in test_reviews] | |
predicted_sentiments = ['positive' if score >= 1.0 else 'negative' for score in sentiment_polarity] | |
# Evaluation | |
from sklearn.metrics import accuracy_score, f1_score, precision_score, recall_score, confusion_matrix |
This file contains 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
# !pip install contractions | |
import nltk | |
nltk.download('stopwords') | |
nltk.download('punkt') | |
import contractions | |
from bs4 import BeautifulSoup | |
import unicodedata | |
import re | |
import nltk | |
import numpy as np |
This file contains 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
# Load the csv file | |
df = pd.read_csv('IMDB_reviews.csv') | |
# Extract the reviews and sentiments | |
reviews = np.array(df['review']) | |
sentiments = np.array(df['sentiment']) | |
# splitting the data into train and test sets | |
train_reviews = reviews[:35000] | |
train_sentiment = reviews[:35000] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder