Train MLPC using train dataset and selected features

In the main, add following.

val mlpcModel = trainMLPC(train,features)

Let's test the model for accuracy.

// Here, we apply the MLPC model built using train data on the test dataset.
val resultMLPC = mlpcModel.transform(test)
// This method detailed below will print the accuracy of the model on the test data.
printAccuracy(resultMLPC)

Following is the printAccuracy that will print the accuracy of the model by comparing the actual vs predicted class.