Skip to content

Instantly share code, notes, and snippets.

@lievcin
Last active February 12, 2018 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lievcin/1e6a28b1d77bb2a2ff2889bff3c27f6f to your computer and use it in GitHub Desktop.
Save lievcin/1e6a28b1d77bb2a2ff2889bff3c27f6f to your computer and use it in GitHub Desktop.
pipeline = Pipeline([
# Use FeatureUnion to combine the features from subject and body
('union', FeatureUnion(
transformer_list=[
('review_text', Pipeline([
('selector', ItemSelector(key='review_text')),
('count_dict', CountVectorizer()),
])),
('rating', Pipeline([
('selector', ItemSelector(key='rating')),
('rating_dict', CountVectorizer())
])),
('verified_purchase', Pipeline([
('selector', ItemSelector(key='verified_purchase')),
('verified_dict', CountVectorizer())
]))
]
)),
('classifier', MultinomialNB(alpha=0.2)),
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment