<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 1. Task
Step1:  Unpack to extract structure
Step2:  Votes are still crammed in a dictionary. Let's unpack it.
Step3:  Quick data visualization
Step4:  3. Problem formulation
Define what's a positive and a negative sentiment
We will ignore all reviews with rating = 3, since they tend to have a neutral sentiment.  Reviews with a rating of 4 or higher will be considered positive, while the ones with rating of 2 or lower will have a negative sentiment.
Step5:  4. Feature engineering
The goal is to convert data of the following form into something that is useful for machine learning.
'My wife took me here on my birthday for breakfast and it was excellent.  The weather was perfect which made sitting outside overlooking their grounds an absolute pleasure.  Our waitress was excellent and our food arrived quickly on the semi-busy Saturday morning.  It looked like the place fills up pretty quickly so the earlier you get here the better.\n\nDo yourself a favor and get their Bloody Mary.  It was phenomenal and simply the best I\'ve ever had.  I\'m pretty sure they only use ingredients from their garden and blend them fresh when you order it.  It was amazing.\n\nWhile EVERYTHING on the menu looks excellent, I had the white truffle scrambled eggs vegetable skillet and it was tasty and delicious.  It came with 2 pieces of their griddled bread with was amazing and it absolutely made the meal complete.  It was the best "toast" I\'ve ever had.\n\nAnyway, I can\'t wait to go back!',
Step6:  5. Model/Algorithm selection & training
Finally, we are ready to train a model.
Step7:  6a. Evaluate the model (Quantitatively)
Step8:  6b. Evaluate the model (Qualitatively)
Let us start by picking the most popular restraunt
Step9:  Sort the reviews based on the predicted sentiment and explore
Step10:  Explore some very bad sentiment reviews
Step11:  Explore some very good sentiment reviews
<ASSISTANT_TASK:>
Python Code:
!head -n 2 ../data/yelp/yelp_training_set_review.json
reviews = gl.SFrame.read_csv('../data/yelp/yelp_training_set_review.json', header = False)
reviews
reviews[0]
Explanation: 1. Task: Predicting sentiment from product reviews
The goal of this task is to know if a particular review has a positive, or negative review associated with  it.
 Input : Raw text blob of review data
My wife took me here on my birthday for breakfast and it was excellent.  The weather was perfect which made sitting outside overlooking their grounds an absolute pleasure.
 Output : Positive!
2. Getting access to data
End of explanation
reviews=reviews.unpack('X1','')
reviews
Explanation: Unpack to extract structure
End of explanation
reviews = reviews.unpack('votes', '')
reviews
Explanation: Votes are still crammed in a dictionary. Let's unpack it.
End of explanation
reviews.show()
gl.canvas.set_target('ipynb')
Explanation: Quick data visualization
End of explanation
reviews['stars'].show(view = 'Categorical')
#ignore all 3* reviews
reviews = reviews[reviews['stars'] != 3]
#positive sentiment = 4* or 5* reviews
reviews['sentiment'] = reviews['stars'] >=4
reviews['sentiment'].show(view = 'Categorical')
Explanation: 3. Problem formulation
Define what's a positive and a negative sentiment
We will ignore all reviews with rating = 3, since they tend to have a neutral sentiment.  Reviews with a rating of 4 or higher will be considered positive, while the ones with rating of 2 or lower will have a negative sentiment.
End of explanation
reviews['word_count'] = gl.text_analytics.count_words(reviews['text'])
reviews['word_count']
Explanation: 4. Feature engineering
The goal is to convert data of the following form into something that is useful for machine learning.
'My wife took me here on my birthday for breakfast and it was excellent.  The weather was perfect which made sitting outside overlooking their grounds an absolute pleasure.  Our waitress was excellent and our food arrived quickly on the semi-busy Saturday morning.  It looked like the place fills up pretty quickly so the earlier you get here the better.\n\nDo yourself a favor and get their Bloody Mary.  It was phenomenal and simply the best I\'ve ever had.  I\'m pretty sure they only use ingredients from their garden and blend them fresh when you order it.  It was amazing.\n\nWhile EVERYTHING on the menu looks excellent, I had the white truffle scrambled eggs vegetable skillet and it was tasty and delicious.  It came with 2 pieces of their griddled bread with was amazing and it absolutely made the meal complete.  It was the best "toast" I\'ve ever had.\n\nAnyway, I can\'t wait to go back!',
End of explanation
train_data, test_data = reviews.random_split(.8, seed=0)
sentiment_model = gl.logistic_classifier.create(train_data,
                                                     target='sentiment',
                                                     features=['word_count'],
                                                     validation_set=test_data)
Explanation: 5. Model/Algorithm selection & training
Finally, we are ready to train a model.
End of explanation
sentiment_model.evaluate(test_data, metric='roc_curve')
sentiment_model.show(view='Evaluation')
Explanation: 6a. Evaluate the model (Quantitatively)
End of explanation
most_popular_business = 'VVeogjZya58oiTxK7qUjAQ'
most_popular_business_data = test_data[test_data['business_id'] == most_popular_business]
most_popular_business_data
Explanation: 6b. Evaluate the model (Qualitatively)
Let us start by picking the most popular restraunt
End of explanation
most_popular_business_data['predictions'] = sentiment_model.predict(most_popular_business_data,
                                               output_type = 'probability')
most_popular_business_data = most_popular_business_data.sort('predictions')
Explanation: Sort the reviews based on the predicted sentiment and explore
End of explanation
print most_popular_business_data['text'][1]
Explanation: Explore some very bad sentiment reviews
End of explanation
print most_popular_business_data['text'][-2]
# 7. Deployment
Explanation: Explore some very good sentiment reviews
End of explanation
<END_TASK>