Return Array[Double] from SGD instead of DoubleMatrix
This commit is contained in:
parent
45f3c85518
commit
217667174e
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue