In [1]:
# import
import graphlab as gl
import matplotlib.pyplot as plt
import numpy as np

%matplotlib inline
gl.canvas.set_target('ipynb')

In [2]:
data = gl.SFrame('data/amazon_baby.gl/')


This non-commercial license of GraphLab Create for academic use is assigned to atul9806@yahoo.in and will expire on February 02, 2018.
[INFO] graphlab.cython.cy_server: GraphLab Create v2.1 started. Logging: C:\Users\Atul\AppData\Local\Temp\graphlab_server_1504142928.log.0

In [3]:
data.head(4)


Out[3]:
name review rating
Planetwise Flannel Wipes These flannel wipes are
OK, but in my opinion ...
3.0
Planetwise Wipe Pouch it came early and was not
disappointed. i love ...
5.0
Annas Dream Full Quilt
with 2 Shams ...
Very soft and comfortable
and warmer than it ...
5.0
Stop Pacifier Sucking
without tears with ...
This is a product well
worth the purchase. I ...
5.0
[4 rows x 3 columns]


In [4]:
def remove_punctuation(text):
    import string
    return text.translate(None, string.punctuation)

In [5]:
data['review_clean'] = data['review'].apply(remove_punctuation)

In [7]:
data = data.fillna('review', '')

In [8]:
data = data[data['rating'] != 3]

In [9]:
data['sentiment'] = data['rating'].apply(lambda rating : +1 if rating > 3 else -1)

In [10]:
train_data, test_data = data.random_split(.8, seed=1)

In [ ]: