title: How to use sqrt on Double in Spark Scala
body: <p>I am trying to calculate Root Mean Square Error (RMSE) manually on Spark (Scala 2.11) </p>
  
  <p><a href="https://i.stack.imgur.com/diNb7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/diNb7.png" alt="se"></a></p>
  
  <p>As screenshot above, I calculate Square Error (SE) for each row </p>
  
  <pre><code>val predicted_with_sqr_err = predicted.withColumn("se", pow(($"medianHouseValue" - $"prediction"), lit(2)))
  </code></pre>
  
  <p>Then I calculate Mean Square Error (MSE)</p>
  
  <pre><code>val sum_se = predicted_with_sqr_err.agg(sum("se")).first.get(0)
  val sum_se_double = sum_se.toString.toDouble
  val mean_sqr_err = (1.0/predicted_with_sqr_err.count)*sum_se_double 
  </code></pre>
  
  <p>It worked fine. But when I trying to square root to calculate Root Mean Square Error (RMSE). </p>
  
  <pre><code>val root_mean_sqr_err = sqrt(mean_sqr_err)
  </code></pre>
  
  <p>It give error: </p>
  
  <pre><code>&lt;console&gt;:83: error: overloaded method value sqrt with alternatives:
    (colName: String)org.apache.spark.sql.Column &lt;and&gt;
    (e: org.apache.spark.sql.Column)org.apache.spark.sql.Column
   cannot be applied to (Double)
         val root_mean_sqr_err = sqrt(mean_sqr_err)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/AOKN5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AOKN5.png" alt="sqrt error"></a></p>
  
  <p>How should I fix ? </p>