text_html_output_1.png
from sklearn.utils import shuffle

import numpy as np

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()

info = pd.pivot_table(data_df, index=['Brand Name'], values=['Rating', 'Review Votes'], columns=[], aggfunc=[np.sum, np.mean], fill_value=0)
info = info.sort_values(by=('sum', 'Rating'), ascending=False)

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

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

data_df = data_df.reset_index(drop=True)

temp_data = data_df[0:20000]

temp_data.shape

counter = 0
for i in range(0, 20000):
    if abs(temp_data['Rating'][i] - temp_data['SENTIMENT_VALUE'][i]) > 1:
        counter += 1

accuracy = (temp_data.shape[0] - counter) / temp_data.shape[0]

testing2 = pd.pivot_table(temp_data, index=['Brand Name'], values=['Rating', 'Review Votes', 'SENTIMENT_VALUE'], columns=[], aggfunc=[np.sum, np.mean], fill_value=0)
testing2 = testing2.sort_values(by=('sum', 'Rating'), ascending=False)
testing2.head(10)