Created
July 31, 2014 20:48
-
-
Save geraldstanje/51c292d691c3732c84cf to your computer and use it in GitHub Desktop.
sklearn example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
from sklearn.feature_extraction.text import CountVectorizer | |
content = ["Bursting the Big Data bubble starts with appreciating certain nuances about its products and patterns","the real solutions that are useful in dealing with Big Data will be needed and in demand even if the notion of Big Data falls from the height of its hype into the trough of disappointment"] | |
X = vectorizer.fit_transform(content) | |
vectorizer = CountVectorizer(min_df=1) | |
print(vectorizer) | |
vectorizer.get_feature_names() | |
X_train = vectorizer.fit_transform(content) | |
num_samples, num_features = X_train.shape | |
print("#samples: %d, #features: %d" % (num_samples, num_features)) #samples: 5, #features: 25 #samples: 2, #features: 37 | |
vectorizer = CountVectorizer(min_df=1, stop_words='english') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment