Skip to content

Instantly share code, notes, and snippets.

@geraldstanje
Created July 31, 2014 20:48
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 geraldstanje/51c292d691c3732c84cf to your computer and use it in GitHub Desktop.
Save geraldstanje/51c292d691c3732c84cf to your computer and use it in GitHub Desktop.
sklearn example
#! /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