Chapter 11: Smarter Email Marketing with the Markov Model¶
Programs of chapter 11 of the book Data Algorithms (O'Reilly, 2015), running on Spark 4.3.0.
Sample input: data/chap11/customer_states.txt ยท data/chap11/transactions.txt
Run the commands from the repository folder after building the jar (Running the programs).
Spark (Java)¶
chap11.spark.SparkMarkov¶
Source: SparkMarkov.java
scripts/run_spark.sh org.dataalgorithms.chap11.spark.SparkMarkov data/chap11/transactions.txt
- Writes to
output/in the current directory; delete it first if it exists:rm -r output
chap11.spark.SparkMarkovWithLambda¶
Source: SparkMarkovWithLambda.java
scripts/run_spark.sh org.dataalgorithms.chap11.spark.SparkMarkovWithLambda data/chap11/transactions.txt
- Writes to
output/in the current directory; delete it first if it exists:rm -r output
Spark (Scala)¶
chap11.scala.Markov¶
Source: Markov.scala
scripts/run_spark.sh org.dataalgorithms.chap11.scala.Markov data/chap11/transactions.txt /tmp/data-algorithms/chap11.scala.Markov/output
MapReduce (Hadoop)¶
chap11.projection.memorysort.SortInMemoryProjectionDriver¶
Source: SortInMemoryProjectionDriver.java
scripts/run_mapreduce.sh org.dataalgorithms.chap11.projection.memorysort.SortInMemoryProjectionDriver data/chap11/transactions.txt /tmp/data-algorithms/chap11.projection.memorysort.SortInMemoryProjectionDriver/output
chap11.projection.secondarysort.SecondarySortProjectionDriver¶
Source: SecondarySortProjectionDriver.java
scripts/run_mapreduce.sh org.dataalgorithms.chap11.projection.secondarysort.SecondarySortProjectionDriver data/chap11/transactions.txt /tmp/data-algorithms/chap11.projection.secondarysort.SecondarySortProjectionDriver/output
chap11.statemodel.MarkovStateTransitionModelDriver¶
Source: MarkovStateTransitionModelDriver.java
scripts/run_mapreduce.sh org.dataalgorithms.chap11.statemodel.MarkovStateTransitionModelDriver data/chap11/customer_states.txt /tmp/data-algorithms/chap11.statemodel.MarkovStateTransitionModelDriver/output
Java¶
chap11.statemodel.ReadDataFromHDFS¶
Source: ReadDataFromHDFS.java
scripts/run_mapreduce.sh org.dataalgorithms.chap11.statemodel.ReadDataFromHDFS /tmp/data-algorithms/chap11.statemodel.MarkovStateTransitionModelDriver/output
- Run
MarkovStateTransitionModelDriverfirst: it writes this program's input.
chap11.statemodel.StateTransitionTableBuilder¶
Source: StateTransitionTableBuilder.java
scripts/run_mapreduce.sh org.dataalgorithms.chap11.statemodel.StateTransitionTableBuilder /tmp/data-algorithms/chap11.statemodel.MarkovStateTransitionModelDriver/output
- Run
MarkovStateTransitionModelDriverfirst: it writes this program's input.