text_plain_output_1.png
from nltk.sentiment.vader import SentimentIntensityAnalyzer

from sklearn.utils import shuffle

import pandas as pd

data_file = '../input/Amazon_Unlocked_Mobile.csv'
data = pd.read_csv(data_file)

data_df = pd.DataFrame(data)

data_df = shuffle(data_df)

data_df = data_df.dropna()

corr_matrix = data_df.corr()
corr_matrix['Rating'].sort_values(ascending=False)

corr_matrix = data_df.corr()
corr_matrix['Price'].sort_values(ascending=False)

all_reviews = data_df['Reviews']

data_df = data_df.reset_index(drop=True)

all_reviews = data_df['Reviews']
all_sent_values = []
all_sentiments = []

from nltk.sentiment.vader import SentimentIntensityAnalyzer
def sentiment_value(paragraph):
    analyser = SentimentIntensityAnalyzer()
    result = analyser.polarity_scores(paragraph)
    score = result['compound']
    return round(score, 1)

for i in range(0, 20000):
    all_sent_values.append(sentiment_value(all_reviews[i]))

temp_data = data_df[0:20000]

temp_data.shape

SENTIMENT_VALUE = []
SENTIMENT = []
for i in range(0, 20000):
    sent = all_sent_values[i]
    if sent <= 1 and sent >= 0.5:
        SENTIMENT.append('V.Positive')
        SENTIMENT_VALUE.append(5)
    elif sent < 0.5 and sent > 0:
        SENTIMENT.append('Positive')
        SENTIMENT_VALUE.append(4)
    elif sent == 0:
        SENTIMENT.append('Neutral')
        SENTIMENT_VALUE.append(3)
    elif sent < 0 and sent >= -0.5:
        SENTIMENT.append('Negative')
        SENTIMENT_VALUE.append(2)
    else:
        SENTIMENT.append('V.Negative')
        SENTIMENT_VALUE.append(1)

temp_data['SENTIMENT_VALUE'] = SENTIMENT_VALUE
temp_data['SENTIMENT'] = SENTIMENT