title: Spark : regression model threshold and precision
body: <p>I have logistic regression mode, where I explicitly set the threshold to 0.5.</p>
  
  <pre><code>model.setThreshold(0.5)
  </code></pre>
  
  <p>I train the model and then I want to get basic stats -- precision, recall etc.</p>
  
  <p>This is what I do when I evaluate the model:</p>
  
  <pre><code>val metrics = new BinaryClassificationMetrics(predictionAndLabels)
  
  val precision = metrics.precisionByThreshold
  
  
  precision.foreach { case (t, p) =&gt;
  
        println(s"Threshold is: $t, Precision is: $p")
  
      }
  </code></pre>
  
  <p>I get results with only 0.0 and 1.0 as values of threshold and 0.5 is completely ignored. </p>
  
  <p>Here is the output of the above loop:</p>
  
  <p>Threshold is: 1.0, Precision is: 0.8571428571428571</p>
  
  <p>Threshold is: 0.0, Precision is: 0.3005181347150259</p>
  
  <p>When I call  metrics.thresholds() it also returns only two values, 0.0 and 1.0. </p>
  
  <p>How do I get the precision and recall values with threshold as 0.5?</p>