O'Reilly logo

Machine Learning with Spark - Second Edition by Nick Pentreath, Manpreet Singh Ghotra, Rajdeep Dua

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

IDF

The inverse document frequency(IDF)represents how much information the word provides: is the term common or rare across the corpus. It is the log scaled inverse fraction of the documents containing the word, calculated by division of the total number of documents by the number of documents containing the termTF-IDF

TF-IDF is calculated by multiplying TF and IDF.

The following example calculates TFIDF for each term in the Apache Spark README.md file:

object TfIdfSample{   def main(args: Array[String]) {     // TODO replace with path specific to your machine     val file = Util.SPARK_HOME + "/README.md"     val spConfig = (new         SparkConf).setMaster("local").setAppName("SparkApp") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required