Return Array[Double] from SGD instead of DoubleMatrix

This commit is contained in:
Shivaram Venkataraman 2013-07-17 16:08:34 -07:00
parent 45f3c85518
commit 217667174e
2 changed files with 4 additions and 6 deletions

View file

@ -50,7 +50,7 @@ object GradientDescent {
stepSize: Double,
numIters: Int,
initialWeights: Array[Double],
miniBatchFraction: Double=1.0) : (DoubleMatrix, Array[Double]) = {
miniBatchFraction: Double=1.0) : (Array[Double], Array[Double]) = {
val stochasticLossHistory = new ArrayBuffer[Double](numIters)
@ -75,6 +75,6 @@ object GradientDescent {
reg_val = update._2
}
(weights, stochasticLossHistory.toArray)
(weights.toArray, stochasticLossHistory.toArray)
}
}

View file

@ -126,10 +126,8 @@ class LogisticRegression private (var stepSize: Double, var miniBatchFraction: D
initalWeightsWithIntercept,
miniBatchFraction)
val weightsArray = weights.toArray()
val intercept = weightsArray(0)
val weightsScaled = weightsArray.tail
val intercept = weights(0)
val weightsScaled = weights.tail
val model = new LogisticRegressionModel(weightsScaled, intercept, stochasticLosses)