title: Euclidean distance of sentences
body: <p>I have scipy sparse matrix with 1,16,098 sentences and 30,119 features. <strong>I want to calculate euclidean distance of each one of them to other and print 5 most similar sentences.</strong></p>
  <p>I am using the CountVectorizer approach to build the vocabulary and encode the words.</p>
  <p>But i am getting below error. Please help. I have just started to implement NLP using python.</p>
  <pre><code>vectorizer = CountVectorizer(stop_words = 'english')
  features = vectorizer.fit_transform(corpus)
  print(vectorizer.vocabulary_)
  
  features.shape
  (116098, 30119)
  
  print(len(vectorizer.vocabulary_))
  30119
  
  for i in range(0,116098):  
      for j in features:
          print(euclidean_distances(features[j],i))
  
  IndexError                                Traceback (most recent call last)
  &lt;ipython-input-56-528966153c16&gt; in &lt;module&gt;
        1 for i in range(0,116098):
        2     for j in features:
  ----&gt; 3         print(euclidean_distances(features[j],i))```
  
  ~\Anaconda3\lib\site-packages\scipy\sparse\_index.py in __getitem__(self, key)
       33     &quot;&quot;&quot;
       34     def __getitem__(self, key):
  ---&gt; 35         row, col = self._validate_indices(key)
       36         # Dispatch to specialized methods.
       37         if isinstance(row, INT_TYPES):
  
  ~\Anaconda3\lib\site-packages\scipy\sparse\_index.py in _validate_indices(self, key)
      128     def _validate_indices(self, key):
      129         M, N = self.shape
  --&gt; 130         row, col = _unpack_index(key)
      131 
      132         if isintlike(row):
  
  ~\Anaconda3\lib\site-packages\scipy\sparse\_index.py in _unpack_index(index)
      274         # not work because spmatrix.ndim is always 2.
      275         raise IndexError(
  --&gt; 276             'Indexing with sparse matrices is not supported '
      277             'except boolean indexing where matrix and index '
      278             'are equal shapes.')
  
  IndexError: Indexing with sparse matrices is not supported except boolean indexing where matrix and index are equal shapes.
  </code></pre>