title: Python scikit-learn SelectKBest words from sentences by speakers
body: <p>I'm trying to use scikit-learn function SelectKBest on a database that contains sentences from two speakers. 
  My goal is to find the 30 best words that can act as features to separate these two speakers, which I want to print to the screen. </p>
  
  <p>The sentences are stored in a list <code>sentences[]</code> and I have the information as for who is the speaker for each of the sentences (stored in another list <code>speakers[]</code>)</p>
  
  <p>I also need to create vectors for those K best features and be able to use classifiers on those vectors.</p>
  
  <p>Current code: (sentences contains 10000 sentences for each speaker, sorted)</p>
  
  <pre class="lang-py prettyprint-override"><code>speakers = [0] * 10000 + [1] * 10000
  vectorizer = TfidfVectorizer()
  vectors = vectorizer.fit_transform(sentences)
  
  kbest = SelectKBest(chi2, k=30).fit(vectors, speakers)
  outcome = kbest.get_support()
  for i in range(0,len(sentences)):
      if outcome[i]:
          print (sentences[i])
  </code></pre>
  
  <p>I'm not sure if it finds the correct words or selects whole sentences, and I'm not very sure how to print the words it finds if it does. (currently, it obviously prints whole sentences as I am printing directly a sentence that has a matching index to what SelectKBest found).</p>
  
  <p><strong>I probably need to find the word in the i'th position of the feature vector, but I'm not sure how to do that.</strong></p>