title: 'Pipeline' object has no attribute 'get_feature_names' in scikit-learn
body: <p>I am basically clustering some of my documents using mini_batch_kmeans and kmeans algorithm. I simply followed the tutorial is the scikit-learn website the link for that is given below:
  <a href="http://scikit-learn.org/stable/auto_examples/text/document_clustering.html" rel="nofollow noreferrer">http://scikit-learn.org/stable/auto_examples/text/document_clustering.html</a></p>
  
  <p>They are using some of the method for the vectorizing one of which is HashingVectorizer. In the hashingVectorizer they are making a pipeline with TfidfTransformer() method.</p>
  
  <pre><code># Perform an IDF normalization on the output of HashingVectorizer
  hasher = HashingVectorizer(n_features=opts.n_features,
                                 stop_words='english', non_negative=True,
                                 norm=None, binary=False)
  vectorizer = make_pipeline(hasher, TfidfTransformer())
  </code></pre>
  
  <p>Once doing so, the vectorizer what I get from that does not have the method get_feature_names(). But since I am using it for clustering, I need to get the "terms" using this "get_feature_names()" </p>
  
  <pre><code>terms = vectorizer.get_feature_names()
  for i in range(true_k):
      print("Cluster %d:" % i, end='')
      for ind in order_centroids[i, :10]:
          print(' %s' % terms[ind], end='')
      print()
  </code></pre>
  
  <p>How do I solve this error?</p>
  
  <p>My whole code is show below:</p>
  
  <pre><code>X_train_vecs, vectorizer = vector_bow.count_tfidf_vectorizer(_contents)
  mini_kmeans_batch = MiniBatchKmeansTechnique()
  # MiniBatchKmeans without the LSA dimensionality reduction
  mini_kmeans_batch.mini_kmeans_technique(number_cluster=8, X_train_vecs=X_train_vecs,
                                                  vectorizer=vectorizer, filenames=_filenames, contents=_contents, is_dimension_reduced=False)
  </code></pre>
  
  <p>The count vectorizor piped with tfidf. </p>
  
  <pre><code>def count_tfidf_vectorizer(self,contents):
      count_vect = CountVectorizer()
      vectorizer = make_pipeline(count_vect,TfidfTransformer())
      X_train_vecs = vectorizer.fit_transform(contents)
      print("The count of bow : ", X_train_vecs.shape)
      return X_train_vecs, vectorizer
  </code></pre>
  
  <p>and the mini_batch_kmeans class is as below: </p>
  
  <pre><code>class MiniBatchKmeansTechnique():
      def mini_kmeans_technique(self, number_cluster, X_train_vecs, vectorizer,
                                filenames, contents, svd=None, is_dimension_reduced=True):
          km = MiniBatchKMeans(n_clusters=number_cluster, init='k-means++', max_iter=100, n_init=10,
                           init_size=1000, batch_size=1000, verbose=True, random_state=42)
          print("Clustering sparse data with %s" % km)
          t0 = time()
          km.fit(X_train_vecs)
          print("done in %0.3fs" % (time() - t0))
          print()
          cluster_labels = km.labels_.tolist()
          print("List of the cluster names is : ",cluster_labels)
          data = {'filename':filenames, 'contents':contents, 'cluster_label':cluster_labels}
          frame = pd.DataFrame(data=data, index=[cluster_labels], columns=['filename', 'contents', 'cluster_label'])
          print(frame['cluster_label'].value_counts(sort=True,ascending=False))
          print()
          grouped = frame['cluster_label'].groupby(frame['cluster_label'])
          print(grouped.mean())
          print()
          print("Top Terms Per Cluster :")
  
          if is_dimension_reduced:
              if svd != None:
                  original_space_centroids = svd.inverse_transform(km.cluster_centers_)
                  order_centroids = original_space_centroids.argsort()[:, ::-1]
          else:
              order_centroids = km.cluster_centers_.argsort()[:, ::-1]
  
          terms = vectorizer.get_feature_names()
          for i in range(number_cluster):
              print("Cluster %d:" % i, end=' ')
              for ind in order_centroids[i, :10]:
                  print(' %s' % terms[ind], end=',')
              print()
              print("Cluster %d filenames:" % i, end='')
              for file in frame.ix[i]['filename'].values.tolist():
                  print(' %s,' % file, end='')
              print()
  </code></pre>