มีความสัมพันธ์ระหว่าง numFeatures ใน HashingTF ใน Spark MLlib และจำนวนคำศัพท์จริงในเอกสาร (ประโยค) หรือไม่?
List<Row> 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<Row> sentenceData = spark.createDataFrame(data, schema);
Tokenizer tokenizer = new Tokenizer().setInputCol("sentence").setOutputCol("words");
Dataset<Row> wordsData = tokenizer.transform(sentenceData);
int numFeatures = 20;
HashingTF hashingTF = new HashingTF()
.setInputCol("words")
.setOutputCol("rawFeatures")
.setNumFeatures(numFeatures);
Dataset<Row> featurizedData = hashingTF.transform(wordsData);
ตามที่กล่าวไว้ในเอกสารประกอบของ Spark Mllib นั้น HashingTF จะแปลงแต่ละประโยคให้เป็นเวกเตอร์คุณลักษณะที่มี numFeatures เป็นความยาว จะเกิดอะไรขึ้นหากแต่ละเอกสารในกรณีนี้ ประโยคประกอบด้วยคำศัพท์หลายพันคำ ค่า numFeatures ควรเป็นเท่าใด จะคำนวณค่านั้นได้อย่างไร?