Chapter 13: k-Nearest Neighbors¶
Programs of chapter 13 of the book Data Algorithms (O'Reilly, 2015), running on Spark 4.3.0.
Sample input: src/main/java/org/dataalgorithms/chap13/spark/output2/R/part-00000 · src/main/java/org/dataalgorithms/chap13/spark/output2/S/part-00000 · src/main/java/org/dataalgorithms/chap13/spark/resources/R.txt · src/main/java/org/dataalgorithms/chap13/spark/resources/S.txt
Run the commands from the repository folder after building the jar (Running the programs).
Spark (Java)¶
chap13.spark.kNN¶
Source: kNN.java
scripts/run_spark.sh org.dataalgorithms.chap13.spark.kNN 2 2 src/main/java/org/dataalgorithms/chap13/spark/resources/R.txt src/main/java/org/dataalgorithms/chap13/spark/resources/S.txt /tmp/data-algorithms/chap13.spark.kNN/output
chap13.spark.kNN2¶
Source: kNN2.java
scripts/run_spark.sh org.dataalgorithms.chap13.spark.kNN2 2 28 src/main/java/org/dataalgorithms/chap13/spark/output2/R/part-00000 src/main/java/org/dataalgorithms/chap13/spark/output2/S/part-00000 /tmp/data-algorithms/chap13.spark.kNN2/output
Spark (Java 8 lambdas)¶
chap13.sparkwithlambda.kNN¶
Source: kNN.java
scripts/run_spark.sh org.dataalgorithms.chap13.sparkwithlambda.kNN 2 2 src/main/java/org/dataalgorithms/chap13/spark/resources/R.txt src/main/java/org/dataalgorithms/chap13/spark/resources/S.txt /tmp/data-algorithms/chap13.sparkwithlambda.kNN/output
Spark (Scala)¶
chap13.scala.kNN¶
Source: kNN.scala
scripts/run_spark.sh org.dataalgorithms.chap13.scala.kNN 2 2 src/main/java/org/dataalgorithms/chap13/spark/resources/R.txt src/main/java/org/dataalgorithms/chap13/spark/resources/S.txt /tmp/data-algorithms/chap13.scala.kNN/output