July 2018
Intermediate to advanced
334 pages
8h 20m
English
We start by transforming the probabilityDensities dataframe from before:
val finalPreds: DataFrame= probabilityDensities.map { probRow => if (probRow.getDouble(0) < broadcastTerm) { 1.0 /* Fraud is flagged here */ } else 0.0 }.toDF("PDF")
Now, let's create a new dataframe with two dataframes—the testing dataframe, and the final predictions dataframe. Drop the "label" column in the testing dataframe and do a cross-join with the finalpreds dataframe. Do not forget to persist the new dataframe with the default storage level (MEMORY_AND_DISK):
val labelAndPredictions: DataFrame = testingDframe.drop("label").crossJoin(finalPreds).cache() println("Label And Predictions: " ) labelAndPredictions.show() ...Read now
Unlock full access