title: Attribute error while using scikit-learn
body: <p>I am trying to find similar questions using scikit using cosine similarity. I was trying this sample code available on the internet. <a href="https://stackoverflow.com/questions/12118720/python-tf-idf-cosine-to-find-document-similarity">Link1</a> and <a href="https://stackoverflow.com/questions/11911469/tfidf-for-search-queries">Link2</a></p>
  
  <pre><code>from sklearn.feature_extraction.text import CountVectorizer
  from sklearn.feature_extraction.text import TfidfTransformer
  from nltk.corpus import stopwords
  import numpy as np
  import numpy.linalg as LA
  
  train_set = ["The sky is blue.", "The sun is bright."]
  test_set = ["The sun in the sky is bright."]
  stopWords = stopwords.words('english')
  
  vectorizer = CountVectorizer(stop_words = stopWords)
  transformer = TfidfTransformer()
  
  trainVectorizerArray = vectorizer.fit_transform(train_set).toarray()
  trainVectorizerArray = vectorizer.
  testVectorizerArray = vectorizer.transform(test_set).toarray()
  print 'Fit Vectorizer to train set', trainVectorizerArray
  print 'Transform Vectorizer to test set', testVectorizerArray
  cx = lambda a, b : round(np.inner(a, b)/(LA.norm(a)*LA.norm(b)), 3)
  
  for vector in trainVectorizerArray:
      print vector
      for testV in testVectorizerArray:
          print testV
          cosine = cx(vector, testV)
          print cosine
  
  transformer.fit(trainVectorizerArray)
  print transformer.transform(trainVectorizerArray).toarray()
  
  transformer.fit(testVectorizerArray)
  tfidf = transformer.transform(testVectorizerArray)
  print tfidf.todense()
  </code></pre>
  
  <p>I always get this error</p>
  
  <pre><code>Traceback (most recent call last):
  File "C:\Users\Animesh\Desktop\NLP\ngrams2.py", line 14, in &lt;module&gt;
  trainVectorizerArray = vectorizer.fit_transform(train_set).toarray()
  File "C:\Python27\lib\site-packages\scikit_learn-0.13.1-py2.7-win32.egg\sklearn  \feature_extraction\text.py", line 740, in fit_transform
  raise ValueError("empty vocabulary; training set may have"
  ValueError: empty vocabulary; training set may have contained only stop words or min_df  (resp. max_df) may be too high (resp. too low).
  </code></pre>
  
  <p>I even checked the code available on <a href="http://pyevolve.sourceforge.net/wordpress/?p=1589" rel="nofollow noreferrer">this link</a>. There I got error <code>AttributeError: 'CountVectorizer' object has no attribute 'vocabulary'</code>.</p>
  
  <p>How to solve this issue ?</p>
  
  <p>I am using Python 2.7.3 on Windows 7 32 Bit and scikit_learn 0.13.1.</p>