In [2]:
import graphlab
In [3]:
products = graphlab.SFrame('amazon_baby.gl/')
[INFO] This non-commercial license of GraphLab Create is assigned to jinntrance@gmail.comand will expire on September 27, 2016. For commercial licensing options, visit https://dato.com/buy/.
[INFO] Start server at: ipc:///tmp/graphlab_server-10951 - Server binary: /usr/local/lib/python2.7/site-packages/graphlab/unity_server - Server log: /tmp/graphlab_server_1443701271.log
[INFO] GraphLab Server Version: 1.6.1
In [18]:
products.head()
Out[18]:
name
review
rating
word_count
awesome
great
fantastic
Planetwise Flannel Wipes
These flannel wipes are
OK, but in my opinion ...
3.0
{'and': 5, '6': 1,
'stink': 1, 'because' ...
0
0
0
Planetwise Wipe Pouch
it came early and was not
disappointed. i love ...
5.0
{'and': 3, 'love': 1,
'it': 2, 'highly': 1, ...
0
0
0
Annas Dream Full Quilt
with 2 Shams ...
Very soft and comfortable
and warmer than it ...
5.0
{'and': 2, 'quilt': 1,
'it': 1, 'comfortable': ...
0
0
0
Stop Pacifier Sucking
without tears with ...
This is a product well
worth the purchase. I ...
5.0
{'ingenious': 1, 'and':
3, 'love': 2, ...
0
0
0
Stop Pacifier Sucking
without tears with ...
All of my kids have cried
non-stop when I tried to ...
5.0
{'and': 2, 'parents!!':
1, 'all': 2, 'puppet.': ...
0
1
0
Stop Pacifier Sucking
without tears with ...
When the Binky Fairy came
to our house, we didn't ...
5.0
{'and': 2, 'this': 2,
'her': 1, 'help': 2, ...
0
1
0
A Tale of Baby's Days
with Peter Rabbit ...
Lovely book, it's bound
tightly so you may no ...
4.0
{'shop': 1, 'noble': 1,
'is': 1, 'it': 1, 'as': ...
0
0
0
Baby Tracker® - Daily
Childcare Journal, ...
Perfect for new parents.
We were able to keep ...
5.0
{'and': 2, 'all': 1,
'right': 1, 'when': 1, ...
0
0
0
Baby Tracker® - Daily
Childcare Journal, ...
A friend of mine pinned
this product on Pinte ...
5.0
{'and': 1, 'help': 1,
'give': 1, 'is': 1, ' ...
0
0
0
Baby Tracker® - Daily
Childcare Journal, ...
This has been an easy way
for my nanny to record ...
4.0
{'journal.': 1, 'nanny':
1, 'standarad': 1, ...
0
0
0
amazing
love
horrible
bad
terrible
awful
wow
hate
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
[10 rows x 15 columns]
In [4]:
products['word_count'] = graphlab.text_analytics.count_words(products['review'])
In [7]:
products.head()
Out[7]:
name
review
rating
word_count
awesome
great
fantastic
Planetwise Flannel Wipes
These flannel wipes are
OK, but in my opinion ...
3.0
{'and': 5, '6': 1,
'stink': 1, 'because' ...
0
0
0
Planetwise Wipe Pouch
it came early and was not
disappointed. i love ...
5.0
{'and': 3, 'love': 1,
'it': 2, 'highly': 1, ...
0
0
0
Annas Dream Full Quilt
with 2 Shams ...
Very soft and comfortable
and warmer than it ...
5.0
{'and': 2, 'quilt': 1,
'it': 1, 'comfortable': ...
0
0
0
Stop Pacifier Sucking
without tears with ...
This is a product well
worth the purchase. I ...
5.0
{'ingenious': 1, 'and':
3, 'love': 2, ...
0
0
0
Stop Pacifier Sucking
without tears with ...
All of my kids have cried
non-stop when I tried to ...
5.0
{'and': 2, 'parents!!':
1, 'all': 2, 'puppet.': ...
0
1
0
Stop Pacifier Sucking
without tears with ...
When the Binky Fairy came
to our house, we didn't ...
5.0
{'and': 2, 'this': 2,
'her': 1, 'help': 2, ...
0
1
0
A Tale of Baby's Days
with Peter Rabbit ...
Lovely book, it's bound
tightly so you may no ...
4.0
{'shop': 1, 'noble': 1,
'is': 1, 'it': 1, 'as': ...
0
0
0
Baby Tracker® - Daily
Childcare Journal, ...
Perfect for new parents.
We were able to keep ...
5.0
{'and': 2, 'all': 1,
'right': 1, 'when': 1, ...
0
0
0
Baby Tracker® - Daily
Childcare Journal, ...
A friend of mine pinned
this product on Pinte ...
5.0
{'and': 1, 'help': 1,
'give': 1, 'is': 1, ' ...
0
0
0
Baby Tracker® - Daily
Childcare Journal, ...
This has been an easy way
for my nanny to record ...
4.0
{'journal.': 1, 'nanny':
1, 'standarad': 1, ...
0
0
0
amazing
love
horrible
bad
terrible
awful
wow
hate
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
[10 rows x 15 columns]
In [5]:
wc = products['word_count']
def word_count(w,sets):
if w in sets:
return sets[w]
return 0
selected_words = ['awesome', 'great', 'fantastic', 'amazing', 'love', 'horrible', 'bad', 'terrible', 'awful', 'wow', 'hate']
freq = {}
for word in selected_words:
products[word] = products['word_count'].apply(lambda sets:word_count(word, sets))
print word, products[word].sum()
awesome 2090
great 45206
fantastic 932
amazing 1363
love 42065
horrible 734
bad 3724
terrible 748
awful 383
wow 144
hate 1220
In [6]:
graphlab.canvas.set_target('ipynb')
In [7]:
products['name'].show()
In [67]:
giraffe_reviews = products[products['name'] == 'Vulli Sophie the Giraffe Teether'].sort('rating', ascending=False)
diaper_champ_reviews = products[products['name'] == 'Baby Trend Diaper Champ'].sort('rating', ascending=False )
In [9]:
len(giraffe_reviews)
Out[9]:
785
In [10]:
giraffe_reviews['rating'].show(view='Categorical')
In [57]:
products['sentiment'].show(view='Categorical')
test_data['sentiment'].show(view='Categorical')
In [20]:
#ignore all 3* reviews
products = products[products['rating'] != 3]
In [21]:
#positive sentiment = 4* or 5* reviews
products['sentiment'] = products['rating'] >=4
In [16]:
products.head()
Out[16]:
name
review
rating
word_count
sentiment
Planetwise Wipe Pouch
it came early and was not
disappointed. i love ...
5.0
{'and': 3, 'love': 1,
'it': 2, 'highly': 1, ...
1
Annas Dream Full Quilt
with 2 Shams ...
Very soft and comfortable
and warmer than it ...
5.0
{'and': 2, 'quilt': 1,
'it': 1, 'comfortable': ...
1
Stop Pacifier Sucking
without tears with ...
This is a product well
worth the purchase. I ...
5.0
{'ingenious': 1, 'and':
3, 'love': 2, ...
1
Stop Pacifier Sucking
without tears with ...
All of my kids have cried
non-stop when I tried to ...
5.0
{'and': 2, 'parents!!':
1, 'all': 2, 'puppet.': ...
1
Stop Pacifier Sucking
without tears with ...
When the Binky Fairy came
to our house, we didn't ...
5.0
{'and': 2, 'cute': 1,
'help': 2, 'doll': 1, ...
1
A Tale of Baby's Days
with Peter Rabbit ...
Lovely book, it's bound
tightly so you may no ...
4.0
{'shop': 1, 'be': 1,
'is': 1, 'it': 1, 'as': ...
1
Baby Tracker® - Daily
Childcare Journal, ...
Perfect for new parents.
We were able to keep ...
5.0
{'feeding,': 1, 'and': 2,
'all': 1, 'right': 1, ...
1
Baby Tracker® - Daily
Childcare Journal, ...
A friend of mine pinned
this product on Pinte ...
5.0
{'and': 1, 'help': 1,
'give': 1, 'is': 1, ...
1
Baby Tracker® - Daily
Childcare Journal, ...
This has been an easy way
for my nanny to record ...
4.0
{'journal.': 1, 'all': 1,
'standarad': 1, ...
1
Baby Tracker® - Daily
Childcare Journal, ...
I love this journal and
our nanny uses it ...
4.0
{'all': 1, 'forget': 1,
'just': 1, "daughter's": ...
1
[10 rows x 5 columns]
In [22]:
train_data,test_data = products.random_split(.8, seed=0)
selected_words
Out[22]:
['awesome',
'great',
'fantastic',
'amazing',
'love',
'horrible',
'bad',
'terrible',
'awful',
'wow',
'hate']
In [23]:
sentiment_model = graphlab.logistic_classifier.create(train_data,
target='sentiment',
features=['word_count'],
validation_set=test_data)
selected_words_model = graphlab.logistic_classifier.create(train_data,
target='sentiment',
features=selected_words,
validation_set=test_data)
selected_words_model['coefficients']
PROGRESS: Logistic regression:
PROGRESS: --------------------------------------------------------
PROGRESS: Number of examples : 133448
PROGRESS: Number of classes : 2
PROGRESS: Number of feature columns : 1
PROGRESS: Number of unpacked features : 219217
PROGRESS: Number of coefficients : 219218
PROGRESS: Starting L-BFGS
PROGRESS: --------------------------------------------------------
PROGRESS: +-----------+----------+-----------+--------------+-------------------+---------------------+
PROGRESS: | Iteration | Passes | Step size | Elapsed Time | Training-accuracy | Validation-accuracy |
PROGRESS: +-----------+----------+-----------+--------------+-------------------+---------------------+
PROGRESS: | 1 | 5 | 0.000002 | 2.754409 | 0.841481 | 0.839989 |
PROGRESS: | 2 | 9 | 3.000000 | 4.277167 | 0.947425 | 0.894877 |
PROGRESS: | 3 | 10 | 3.000000 | 4.975438 | 0.923768 | 0.866232 |
PROGRESS: | 4 | 11 | 3.000000 | 5.657798 | 0.971779 | 0.912743 |
PROGRESS: | 5 | 12 | 3.000000 | 6.190100 | 0.975511 | 0.908900 |
PROGRESS: | 6 | 13 | 3.000000 | 6.772363 | 0.899991 | 0.825967 |
PROGRESS: | 10 | 18 | 1.000000 | 9.463507 | 0.988715 | 0.916256 |
PROGRESS: +-----------+----------+-----------+--------------+-------------------+---------------------+
PROGRESS: Logistic regression:
PROGRESS: --------------------------------------------------------
PROGRESS: Number of examples : 133448
PROGRESS: Number of classes : 2
PROGRESS: Number of feature columns : 11
PROGRESS: Number of unpacked features : 11
PROGRESS: Number of coefficients : 12
PROGRESS: Starting Newton Method
PROGRESS: --------------------------------------------------------
PROGRESS: +-----------+----------+--------------+-------------------+---------------------+
PROGRESS: | Iteration | Passes | Elapsed Time | Training-accuracy | Validation-accuracy |
PROGRESS: +-----------+----------+--------------+-------------------+---------------------+
PROGRESS: | 1 | 2 | 0.107295 | 0.844299 | 0.842842 |
PROGRESS: | 2 | 3 | 0.175599 | 0.844186 | 0.842842 |
PROGRESS: | 3 | 4 | 0.245192 | 0.844276 | 0.843142 |
PROGRESS: | 4 | 5 | 0.317181 | 0.844269 | 0.843142 |
PROGRESS: | 5 | 6 | 0.390611 | 0.844269 | 0.843142 |
PROGRESS: | 6 | 7 | 0.466214 | 0.844269 | 0.843142 |
PROGRESS: +-----------+----------+--------------+-------------------+---------------------+
Out[23]:
name
index
class
value
(intercept)
None
1
1.36728315229
awesome
None
1
1.05800888878
great
None
1
0.883937894898
fantastic
None
1
0.891303090304
amazing
None
1
0.892802422508
love
None
1
1.39989834302
horrible
None
1
-1.99651800559
bad
None
1
-0.985827369929
terrible
None
1
-2.09049998487
awful
None
1
-1.76469955631
[12 rows x 4 columns]
Note: Only the head of the SFrame is printed.
You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.
In [53]:
coef = selected_words_model['coefficients']
coef.sort('value',ascending=False)
Out[53]:
name
index
class
value
love
None
1
1.39989834302
(intercept)
None
1
1.36728315229
awesome
None
1
1.05800888878
amazing
None
1
0.892802422508
fantastic
None
1
0.891303090304
great
None
1
0.883937894898
wow
None
1
-0.0541450123333
bad
None
1
-0.985827369929
hate
None
1
-1.40916406276
awful
None
1
-1.76469955631
[12 rows x 4 columns]
Note: Only the head of the SFrame is printed.
You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.
In [55]:
sentiment_model.evaluate(test_data, metric='roc_curve')
print sentiment_model.evaluate(test_data)
print selected_words_model.evaluate(test_data)
{'confusion_matrix': Columns:
target_label int
predicted_label int
count int
Rows: 4
Data:
+--------------+-----------------+-------+
| target_label | predicted_label | count |
+--------------+-----------------+-------+
| 0 | 1 | 1328 |
| 0 | 0 | 4000 |
| 1 | 1 | 26515 |
| 1 | 0 | 1461 |
+--------------+-----------------+-------+
[4 rows x 3 columns]
, 'accuracy': 0.916256305548883}
{'confusion_matrix': Columns:
target_label int
predicted_label int
count int
Rows: 4
Data:
+--------------+-----------------+-------+
| target_label | predicted_label | count |
+--------------+-----------------+-------+
| 0 | 0 | 234 |
| 0 | 1 | 5094 |
| 1 | 1 | 27846 |
| 1 | 0 | 130 |
+--------------+-----------------+-------+
[4 rows x 3 columns]
, 'accuracy': 0.8431419649291376}
In [31]:
sentiment_model.show(view='Evaluation')
In [44]:
giraffe_reviews['predicted_sentiment'] = sentiment_model.predict(giraffe_reviews, output_type='probability')
giraffe_reviews[-1]
Out[44]:
{'amazing': 0,
'awesome': 0,
'awful': 0,
'bad': 0,
'fantastic': 0,
'great': 0,
'hate': 0,
'horrible': 0,
'love': 0,
'name': 'Vulli Sophie the Giraffe Teether',
'predicted_sentiment': 0.999325063425381,
'rating': 5.0,
'review': 'I know several baits that are enjoying the soft, flexible Sophie giraffe. No wonder she made it to the Top Baby Products!',
'sentiment': 1,
'terrible': 0,
'word_count': {'are': 1,
'baby': 1,
'baits': 1,
'enjoying': 1,
'flexible': 1,
'giraffe.': 1,
'i': 1,
'it': 1,
'know': 1,
'made': 1,
'no': 1,
'products!': 1,
'several': 1,
'she': 1,
'soft,': 1,
'sophie': 1,
'that': 1,
'the': 2,
'to': 1,
'top': 1,
'wonder': 1},
'wow': 0}
In [68]:
diaper_champ_reviews['predicted_sentiment'] = sentiment_model.predict(diaper_champ_reviews, output_type='probability')
print diaper_champ_reviews.head()
diaper_champ_reviews['predicted_sentiment'] = selected_words_model.predict(diaper_champ_reviews, output_type='probability')
print diaper_champ_reviews.head()
+-------------------------+-------------------------------+--------+
| name | review | rating |
+-------------------------+-------------------------------+--------+
| Baby Trend Diaper Champ | I see that there are compl... | 5.0 |
| Baby Trend Diaper Champ | This truly is the champ of... | 5.0 |
| Baby Trend Diaper Champ | Excellent diaper disposal ... | 5.0 |
| Baby Trend Diaper Champ | We love our diaper champ. ... | 5.0 |
| Baby Trend Diaper Champ | Two girlfriends and two fa... | 5.0 |
| Baby Trend Diaper Champ | this works really well. I... | 5.0 |
| Baby Trend Diaper Champ | I am glad I bought this! I... | 5.0 |
| Baby Trend Diaper Champ | I originally put this item... | 5.0 |
| Baby Trend Diaper Champ | I am so glad I got the Dia... | 5.0 |
| Baby Trend Diaper Champ | I recieved this pail as a ... | 5.0 |
+-------------------------+-------------------------------+--------+
+-------------------------------+---------+-------+-----------+---------+------+
| word_count | awesome | great | fantastic | amazing | love |
+-------------------------------+---------+-------+-----------+---------+------+
| {'all': 1, '-': 2, 'over':... | 0 | 0 | 0 | 0 | 0 |
| {'and': 3, 'stink': 1, 'al... | 0 | 1 | 0 | 0 | 0 |
| {'control': 1, 'am': 1, 'i... | 0 | 0 | 0 | 0 | 0 |
| {'and': 3, 'over.': 1, 'al... | 0 | 0 | 0 | 0 | 1 |
| {'just': 1, '-': 3, 'both'... | 0 | 0 | 0 | 0 | 0 |
| {'and': 3, 'drop': 1, 'bag... | 0 | 0 | 0 | 0 | 0 |
| {'and': 1, 'garbage': 1, '... | 0 | 0 | 0 | 0 | 0 |
| {'lysol': 1, 'all': 2, 'ba... | 0 | 0 | 0 | 0 | 0 |
| {'and': 2, 'all': 1, 'just... | 0 | 0 | 0 | 0 | 0 |
| {'and': 2, 'garbage': 1, "... | 0 | 0 | 0 | 0 | 0 |
+-------------------------------+---------+-------+-----------+---------+------+
+----------+-----+----------+-------+-----+------+-----------+---------------------+
| horrible | bad | terrible | awful | wow | hate | sentiment | predicted_sentiment |
+----------+-----+----------+-------+-----+------+-----------+---------------------+
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.99996068212 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.999604357958 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.999994864775 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.998779072633 |
| 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0.999999604504 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.998693566706 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.998185268633 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.999999642488 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.97415225478 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.999616123196 |
+----------+-----+----------+-------+-----+------+-----------+---------------------+
[10 rows x 17 columns]
+-------------------------+-------------------------------+--------+
| name | review | rating |
+-------------------------+-------------------------------+--------+
| Baby Trend Diaper Champ | I see that there are compl... | 5.0 |
| Baby Trend Diaper Champ | This truly is the champ of... | 5.0 |
| Baby Trend Diaper Champ | Excellent diaper disposal ... | 5.0 |
| Baby Trend Diaper Champ | We love our diaper champ. ... | 5.0 |
| Baby Trend Diaper Champ | Two girlfriends and two fa... | 5.0 |
| Baby Trend Diaper Champ | this works really well. I... | 5.0 |
| Baby Trend Diaper Champ | I am glad I bought this! I... | 5.0 |
| Baby Trend Diaper Champ | I originally put this item... | 5.0 |
| Baby Trend Diaper Champ | I am so glad I got the Dia... | 5.0 |
| Baby Trend Diaper Champ | I recieved this pail as a ... | 5.0 |
+-------------------------+-------------------------------+--------+
+-------------------------------+---------+-------+-----------+---------+------+
| word_count | awesome | great | fantastic | amazing | love |
+-------------------------------+---------+-------+-----------+---------+------+
| {'all': 1, '-': 2, 'over':... | 0 | 0 | 0 | 0 | 0 |
| {'and': 3, 'stink': 1, 'al... | 0 | 1 | 0 | 0 | 0 |
| {'control': 1, 'am': 1, 'i... | 0 | 0 | 0 | 0 | 0 |
| {'and': 3, 'over.': 1, 'al... | 0 | 0 | 0 | 0 | 1 |
| {'just': 1, '-': 3, 'both'... | 0 | 0 | 0 | 0 | 0 |
| {'and': 3, 'drop': 1, 'bag... | 0 | 0 | 0 | 0 | 0 |
| {'and': 1, 'garbage': 1, '... | 0 | 0 | 0 | 0 | 0 |
| {'lysol': 1, 'all': 2, 'ba... | 0 | 0 | 0 | 0 | 0 |
| {'and': 2, 'all': 1, 'just... | 0 | 0 | 0 | 0 | 0 |
| {'and': 2, 'garbage': 1, "... | 0 | 0 | 0 | 0 | 0 |
+-------------------------------+---------+-------+-----------+---------+------+
+----------+-----+----------+-------+-----+------+-----------+---------------------+
| horrible | bad | terrible | awful | wow | hate | sentiment | predicted_sentiment |
+----------+-----+----------+-------+-----+------+-----------+---------------------+
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.796940851291 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.904755808093 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.796940851291 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.940876393428 |
| 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0.347684052736 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.796940851291 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.796940851291 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.796940851291 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.796940851291 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.796940851291 |
+----------+-----+----------+-------+-----+------+-----------+---------------------+
[10 rows x 17 columns]
In [21]:
giraffe_reviews.head()
Out[21]:
name
review
rating
word_count
predicted_sentiment
Vulli Sophie the Giraffe
Teether ...
He likes chewing on all
the parts especially the ...
5.0
{'and': 1, 'all': 1,
'because': 1, 'it': 1, ...
0.999513023521
Vulli Sophie the Giraffe
Teether ...
My son loves this toy and
fits great in the diaper ...
5.0
{'and': 1, 'right': 1,
'help': 1, 'just': 1, ...
0.999320678306
Vulli Sophie the Giraffe
Teether ...
There really should be a
large warning on the ...
1.0
{'and': 2, 'all': 1,
'latex.': 1, 'being': 1, ...
0.013558811687
Vulli Sophie the Giraffe
Teether ...
All the moms in my moms'
group got Sophie for ...
5.0
{'and': 2, 'one!': 1,
'all': 1, 'love': 1, ...
0.995769474148
Vulli Sophie the Giraffe
Teether ...
I was a little skeptical
on whether Sophie was ...
5.0
{'and': 3, 'all': 1,
'old': 1, 'her.': 1, ...
0.662374415673
Vulli Sophie the Giraffe
Teether ...
I have been reading about
Sophie and was going ...
5.0
{'and': 6, 'seven': 1,
'already': 1, 'love': 1, ...
0.999997148186
Vulli Sophie the Giraffe
Teether ...
My neice loves her sophie
and has spent hours ...
5.0
{'and': 4, 'drooling,':
1, 'love': 1, 'her.': 1, ...
0.989190989536
Vulli Sophie the Giraffe
Teether ...
What a friendly face!
And those mesmerizing ...
5.0
{'and': 3, 'chew': 1,
"don't": 1, 'is': 1, ...
0.999563518413
Vulli Sophie the Giraffe
Teether ...
We got this just for my
son to chew on instea ...
5.0
{'chew': 2, 'because': 1,
'just': 2, 'what': 1, ...
0.970160542725
Vulli Sophie the Giraffe
Teether ...
My baby seems to like
this toy, but I could ...
3.0
{'and': 2, 'already': 1,
'in': 1, 'some': 1, ' ...
0.195367644588
[10 rows x 5 columns]
In [62]:
giraffe_reviews = giraffe_reviews.sort('predicted_sentiment', ascending=False)
diaper_champ_reviews = diaper_champ_reviews.sort('predicted_sentiment', ascending=False)
diaper_champ_reviews
Out[62]:
name
review
rating
word_count
awesome
great
fantastic
Baby Trend Diaper Champ
I LOVE LOVE LOVE this
product! It is SO much ...
4.0
{'rating': 1,
'contacted': 1, 'over': ...
0
1
0
Baby Trend Diaper Champ
Love it, love it, love
it! This lives up to ...
5.0
{'instead': 1, 'all': 1,
'already': 1, 'love': 3, ...
0
0
0
Baby Trend Diaper Champ
I received my Diaper
Champ at my baby shower ...
5.0
{'bags.': 1, "don't": 1,
'son.': 1, 'of,': 1, ...
0
0
0
Baby Trend Diaper Champ
Works great - no smells.
LOVE that it uses reg ...
5.0
{'and': 2, 'bags.': 1,
'garbage': 1, 'wastef ...
0
2
0
Baby Trend Diaper Champ
I love this diaper pale
and wouldn't dream of ...
5.0
{'and': 3, 'love': 1,
'use.': 1, 'is': 2, ' ...
0
2
0
Baby Trend Diaper Champ
We had 2 diaper Genie's
both given to us as a ...
4.0
{'hand.': 1, 'both': 1,
'(required': 1, 'befo ...
0
0
0
Baby Trend Diaper Champ
I love this diaper pail.
It keeps the diapers ...
4.0
{'and': 1, 'old': 1,
'extra': 1, 'is': 1, ...
0
0
0
Baby Trend Diaper Champ
This is absolutely, by
far, the best diaper ...
5.0
{'just': 3, 'money': 1,
'still': 3, 'fine': 1, ...
0
0
0
Baby Trend Diaper Champ
Love the Diaper Champ. I
had planned to get the ...
4.0
{'reviews,': 1, 'infant':
1, 'bags.': 1, 'just' ...
0
0
0
Baby Trend Diaper Champ
I have a 10 year old
daughter and an 8 month ...
5.0
{'lysol': 1, 'all': 1,
'just': 2, 'hand,': 1, ...
0
0
0
amazing
love
horrible
bad
terrible
awful
wow
hate
sentiment
predicted_sentiment
0
3
0
0
0
0
0
0
1
0.998423414594
0
3
0
0
0
0
0
0
1
0.996192539732
0
3
0
0
0
0
0
0
1
0.996192539732
0
1
0
0
0
0
0
0
1
0.989387539605
0
1
0
0
0
0
0
0
1
0.989387539605
0
2
0
0
0
0
0
0
1
0.984739056527
0
2
0
0
0
0
0
0
1
0.984739056527
0
2
0
0
0
0
0
0
1
0.984739056527
0
2
0
0
0
0
0
0
1
0.984739056527
0
2
0
0
0
0
0
0
1
0.984739056527
[298 rows x 17 columns]
Note: Only the head of the SFrame is printed.
You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.
In [24]:
giraffe_reviews.head()
Out[24]:
name
review
rating
word_count
predicted_sentiment
Vulli Sophie the Giraffe
Teether ...
Sophie, oh Sophie, your
time has come. My ...
5.0
{'giggles': 1, 'all': 1,
"violet's": 2, 'food' ...
1.0
Vulli Sophie the Giraffe
Teether ...
I'm not sure why Sophie
is such a hit with the ...
4.0
{'peace': 1, 'month': 1,
'bright': 1, 'softer' ...
0.999999999703
Vulli Sophie the Giraffe
Teether ...
I'll be honest...I bought
this toy because all the ...
4.0
{'all': 2, 'pops': 1,
'existence.': 1, ...
0.999999999392
Vulli Sophie the Giraffe
Teether ...
We got this little
giraffe as a gift from a ...
5.0
{'all': 2, "don't": 1,
'(literally).so': 1, ...
0.99999999919
Vulli Sophie the Giraffe
Teether ...
As a mother of 16month
old twins; I bought ...
5.0
{'cute': 1, 'all': 1,
'reviews.': 2, 'just' ...
0.999999998657
Vulli Sophie the Giraffe
Teether ...
Sophie the Giraffe is the
perfect teething toy. ...
5.0
{'just': 2, 'both': 1,
'month': 1, 'ears,': 1, ...
0.999999997108
Vulli Sophie the Giraffe
Teether ...
Sophie la giraffe is
absolutely the best toy ...
5.0
{'and': 5, 'the': 1,
'all': 1, 'that': 2, ...
0.999999995589
Vulli Sophie the Giraffe
Teether ...
My 5-mos old son took to
this immediately. The ...
5.0
{'just': 1, 'shape': 2,
'mutt': 1, '"dog': 1, ...
0.999999995573
Vulli Sophie the Giraffe
Teether ...
My nephews and my four
kids all had Sophie in ...
5.0
{'and': 4, 'chew': 1,
'all': 1, 'perfect;': 1, ...
0.999999989527
Vulli Sophie the Giraffe
Teether ...
Never thought I'd see my
son French kissing a ...
5.0
{'giggles': 1, 'all': 1,
'out,': 1, 'over': 1, ...
0.999999985069
[10 rows x 5 columns]
In [25]:
giraffe_reviews[0]['review']
Out[25]:
"Sophie, oh Sophie, your time has come. My granddaughter, Violet is 5 months old and starting to teeth. What joy little Sophie brings to Violet. Sophie is made of a very pliable rubber that is sturdy but not tough. It is quite easy for Violet to twist Sophie into unheard of positions to get Sophie into her mouth. The little nose and hooves fit perfectly into small mouths, and the drooling has purpose. The paint on Sophie is food quality.Sophie was born in 1961 in France. The maker had wondered why there was nothing available for babies and made Sophie from the finest rubber, phthalate-free on St Sophie's Day, thus the name was born. Since that time millions of Sophie's populate the world. She is soft and for babies little hands easy to grasp. Violet especially loves the bumpy head and horns of Sophie. Sophie has a long neck that easy to grasp and twist. She has lovely, sizable spots that attract Violet's attention. Sophie has happy little squeaks that bring squeals of delight from Violet. She is able to make Sophie squeak and that brings much joy. Sophie's smooth skin is soothing to Violet's little gums. Sophie is 7 inches tall and is the exact correct size for babies to hold and love.As you well know the first thing babies grasp, goes into their mouths- how wonderful to have a toy that stimulates all of the senses and helps with the issue of teething. Sophie is small enough to fit into any size pocket or bag. Sophie is the perfect find for babies from a few months to a year old. How wonderful to hear the giggles and laughs that emanate from babies who find Sophie irresistible. Viva La Sophie!Highly Recommended. prisrob 12-11-09"
In [26]:
giraffe_reviews[1]['review']
Out[26]:
"I'm not sure why Sophie is such a hit with the little ones, but my 7 month old baby girl is one of her adoring fans. The rubber is softer and more pleasant to handle, and my daughter has enjoyed chewing on her legs and the nubs on her head even before she started teething. She also loves the squeak that Sophie makes when you squeeze her. Not sure what it is but if Sophie is amongst a pile of her other toys, my daughter will more often than not reach for Sophie. And I have the peace of mind of knowing that only edible and safe paints and materials have been used to make Sophie, as opposed to Bright Starts and other baby toys made in China. Now that the research is out on phthalates and other toxic substances in baby toys, I think it's more important than ever to find good quality toys that are also safe for our babies to handle and put in their mouths. Sophie is a must-have for every new mom in my opinion. Even if your kid is one of the few that can take or leave her, it's worth a try. Vulli, the makers of Sophie, also make natural rubber teething rings that my daughter loves as well."
In [27]:
giraffe_reviews[-1]['review']
Out[27]:
"My son (now 2.5) LOVED his Sophie, and I bought one for every baby shower I've gone to. Now, my daughter (6 months) just today nearly choked on it and I will never give it to her again. Had I not been within hearing range it could have been fatal. The strange sound she was making caught my attention and when I went to her and found the front curved leg shoved well down her throat and her face a purply/blue I panicked. I pulled it out and she vomited all over the carpet before screaming her head off. I can't believe how my opinion of this toy has changed from a must-have to a must-not-use. Please don't disregard any of the choking hazard comments, they are not over exaggerated!"
In [28]:
giraffe_reviews[-2]['review']
Out[28]:
"This children's toy is nostalgic and very cute. However, there is a distinct rubber smell and a very odd taste, yes I tried it, that my baby did not enjoy. Also, if it is soiled it is extremely difficult to clean as the rubber is a kind of porus material and does not clean well. The final thing is the squeaking device inside which stopped working after the first couple of days. I returned this item feeling I had overpaid for a toy that was defective and did not meet my expectations. Please do not be swayed by the cute packaging and hype surounding it as I was. One more thing, I was given a full refund from Amazon without any problem."
In [ ]:
Content source: jinntrance/MOOC
Similar notebooks: