Preparing the ND4j dataset

As I said, we need an intermediate conversion and pre-process to get the training set to contain feature vectors as well as labels. The conversion is pretty straightforward: we need the feature vector and the business labels.

For this, we have the makeND4jDataSets class (see makeND4jDataSets.scala for details). The class creates a ND4j dataset object from the data structure from the alignLables function in the form of List[(imgID, bizID, labels, pixelVector)]. First, we prepare the dataset using the makeDataSet() method:

def makeDataSet(alignedData: featureAndDataAligner, bizClass: Int): DataSet = {    val alignedXData = alignedData.getImgVectors.toNDArray    val alignedLabs = alignedData.getBusinessLabels.map(x => 

Get Scala Machine Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.