human
2. Custom Transformers
In the previous section, I defined two classes ItemSelector and VotesToDictTransformer, and the commonality of these two is that they inherited the TransformerMixin class. TransformerMixin is the base class of many built-in transformers and vectorizers in scikit-learn, e.g. CountVectorizer, TfidfVectorizer, TfidfTransformer, DictVectorizer, etc. We define the transform() function to manipulate the data in a more custom way. For example, ItemSelector returns a subset of dataframe based on given column names, and VotesToDictTransformer transforms a dataframe into a list of dictionaries.  
To demonstrate how useful customer transformers are, let's define another one. Say, we hypothesize that the sentiment of each review can be a strong feature for predict the star rating. Then we would need a SentimentTransformer class. 
To avoid spending time to train our own sentiment classifier, we use the TextBlob package for its built-in sentiment analysis feature."
Please write code following the instructions in jupyter notebook style.

What is a code to 2?
assistant
#Here is code to 2.

from textblob import TextBlob

class SentimentTransformer(TransformerMixin, BaseEstimator):
    def fit(self, x, y=None):
        return self

    def transform(self, texts):
        features = []
        for text in texts:
            blob = TextBlob(text.decode('utf-8'))
            features.append({'polarity': binarize_number(blob.sentiment.polarity, 0.5),
                             'subjectivity': binarize_number(blob.sentiment.subjectivity, 0.5)})
        return features