预测概率的代码如下:

class LRModel(weights:Vector, intercept:Double, rate:Double) extends Serializable{
  val weightMatrix=weights
  def predictPoint(dataMatrix: Vector) = {
    val margin = dot(weightMatrix, dataMatrix) + intercept
    val score = 1.0 / (1.0 + math.exp(-margin))
    score/(score+(1-score)/rate)
  }
}