title: Spark in Scala: how do I compare two columns to number of locations where they are different?
body: <p>I have a DataFrame in Spark called <code>df</code>. I have trained and machine learning model on a couple features and simply want to compute the accuracy between the <code>label</code> and <code>prediction</code> column. </p>
  
  <pre><code>scala&gt; df.columns
  res32: Array[String] = Array(feature1, feature2, label, prediction)
  </code></pre>
  
  <p>This would be mind-numbingly simple in numpy:</p>
  
  <pre><code>accuracy = np.sum(df.label == df.prediction) / float(len(df))
  </code></pre>
  
  <p>Is there a similarly easy way to do this in Spark using Scala?</p>
  
  <p>I should also mention I'm completely new to Scala.</p>