title: how to "normalize" vectors values when using Spark CountVectorizer?
body: <p><code>CountVectorizer</code> and <code>CountVectorizerModel</code> often creates a sparse feature vector that looks like this:</p>
  
  <pre><code>(10,[0,1,4,6,8],[2.0,1.0,1.0,1.0,1.0])
  </code></pre>
  
  <p>this basically says the total size of the vocabulary is 10, the current document has 5 unique elements, and in the feature vector, these 5 unique elements take position at 0, 1, 4, 6 and 8. Also, one of the elements show up twice, therefore the 2.0 value.</p>
  
  <p>Now, I would like to "normalize" the above feature vector and make it look like this,</p>
  
  <pre><code>(10,[0,1,4,6,8],[0.3333,0.1667,0.1667,0.1667,0.1667])
  </code></pre>
  
  <p>i.e., each value is divided by 6, the total number of all elements together. For example, <code>0.3333 = 2.0/6</code>.</p>
  
  <p>So is there a way to do this efficiently here?</p>
  
  <p>Thanks!</p>