Spark MLlib LinearRegression线性回归

2018-03-07  本文已影响0人  SmileySure

线性回归

简书不支持Latex。。。这一部分在csdn
http://blog.csdn.net/u010557442/article/details/79474920

源码分析

/**
 * :: DeveloperApi ::
 * A simple updater for gradient descent *without* any regularization.
 * Uses a step-size decreasing with the square root of the number of iterations.
 */
@DeveloperApi
class SimpleUpdater extends Updater {
  override def compute(
      weightsOld: Vector,
      gradient: Vector,
      stepSize: Double,
      iter: Int,
      regParam: Double): (Vector, Double) = {
    //当前迭代次数的平方根的倒数作为趋近的因子α
    val thisIterStepSize = stepSize / math.sqrt(iter)
    val brzWeights: BV[Double] = weightsOld.asBreeze.toDenseVector
    brzAxpy(-thisIterStepSize, gradient.asBreeze, brzWeights)

    (Vectors.fromBreeze(brzWeights), 0)
  }
}
上一篇下一篇

猜你喜欢

热点阅读