title: Printing top values of each cluster in DBSCAN
body: <p>I am implementing a code for text clustering in python using k means and DBSCAN. The K Means code is written as below:</p>
  <pre><code>    from __future__ import print_function
      from sklearn.cluster import KMeans
      num_clusters = 5
      km = KMeans(n_clusters=num_clusters)
      %time km.fit(tfidf_matrix)
      clusters = km.labels_.tolist()
  
      import pandas as pd
      films = { 'title': titles, 'rank': ranks, 'synopsis': synopses, 'cluster': clusters, 'genre': genres }
      frame = pd.DataFrame(films, index = [clusters] , columns = ['rank', 'title', 'cluster', 'genre'])
  
  
      print(&quot;Top terms per cluster:&quot;)
      print()
      order_centroids = km.cluster_centers_.argsort()[:, ::-1]
      for i in range(num_clusters):
          print(&quot;Cluster %d words:&quot; % i, end='')
          for ind in order_centroids[i, :6]:
              print(' %s' % vocab_frame.loc[terms[ind].split(' ')].values.tolist()[0][0].encode('utf-8', 'ignore'), end=',')
          print()
          print()
          print(&quot;Cluster %d titles:&quot; % i, end='')
          for title in frame.loc[i]['title'].values.tolist():
              print(' %s,' % title, end='')
          print()
  </code></pre>
  <p>The output is as desired:</p>
  <p>Cluster 0 words: b'soldiers', b'killed', b'army', b'camps', b'war', b'command',</p>
  <p>Cluster 1 words: b'police', b'killed', b'car', b'murders', b'apartments', b'asks',
  ...</p>
  <p>Now, when running the same code with DBSCAN, What I could do is:</p>
  <pre><code>    from sklearn.cluster import DBSCAN 
      DBS_clf = DBSCAN(eps=.85, min_samples=1.5)
      DBS_clf.fit(tfidf_matrix)
      DBS_clusters = DBS_clf.labels_.tolist()
  
  </code></pre>
  <p>but I could not get the top terms printed (for indices 0 and above as -1 is for noise) as I could find no alternate for cluster_centers_ for DBSCAN, which is of course logical as DBSCAN has a very different working. Please guide as I am scratching my head with no understanding of what I should do. I am not very good at Python.</p>