title: What is the relation between numFeatures in HashingTF in Spark MLlib and actual number of terms in a document?
body: <p>Is there any relation between numFeatures in HashingTF in Spark MLlib and the actual number of terms in a document(sentence)?</p>
  
  <pre><code>List&lt;Row&gt; data = Arrays.asList(
    RowFactory.create(0.0, "Hi I heard about Spark"),
    RowFactory.create(0.0, "I wish Java could use case classes"),
    RowFactory.create(1.0, "Logistic regression models are neat")
  );
  StructType schema = new StructType(new StructField[]{
    new StructField("label", DataTypes.DoubleType, false, Metadata.empty()),
    new StructField("sentence", DataTypes.StringType, false, Metadata.empty())
  });
  Dataset&lt;Row&gt; sentenceData = spark.createDataFrame(data, schema);
  
  Tokenizer tokenizer = new Tokenizer().setInputCol("sentence").setOutputCol("words");
  Dataset&lt;Row&gt; wordsData = tokenizer.transform(sentenceData);
  
  int numFeatures = 20;
  HashingTF hashingTF = new HashingTF()
    .setInputCol("words")
    .setOutputCol("rawFeatures")
    .setNumFeatures(numFeatures);
  
  Dataset&lt;Row&gt; featurizedData = hashingTF.transform(wordsData);
  </code></pre>
  
  <p>As mentioned in the documentation of Spark Mllib, HashingTF converts each sentence into a feature vector of having numFeatures as length. 
  What will happen if each document here, in this case, sentence contains thousands of terms? What should be the value of numFeatures? How to calculate that value?</p>