Skip to content
Snippets Groups Projects
Commit 21766717 authored by Shivaram Venkataraman's avatar Shivaram Venkataraman
Browse files

Return Array[Double] from SGD instead of DoubleMatrix

parent 45f3c855
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ object GradientDescent { ...@@ -50,7 +50,7 @@ object GradientDescent {
stepSize: Double, stepSize: Double,
numIters: Int, numIters: Int,
initialWeights: Array[Double], initialWeights: Array[Double],
miniBatchFraction: Double=1.0) : (DoubleMatrix, Array[Double]) = { miniBatchFraction: Double=1.0) : (Array[Double], Array[Double]) = {
val stochasticLossHistory = new ArrayBuffer[Double](numIters) val stochasticLossHistory = new ArrayBuffer[Double](numIters)
...@@ -75,6 +75,6 @@ object GradientDescent { ...@@ -75,6 +75,6 @@ object GradientDescent {
reg_val = update._2 reg_val = update._2
} }
(weights, stochasticLossHistory.toArray) (weights.toArray, stochasticLossHistory.toArray)
} }
} }
...@@ -126,10 +126,8 @@ class LogisticRegression private (var stepSize: Double, var miniBatchFraction: D ...@@ -126,10 +126,8 @@ class LogisticRegression private (var stepSize: Double, var miniBatchFraction: D
initalWeightsWithIntercept, initalWeightsWithIntercept,
miniBatchFraction) miniBatchFraction)
val weightsArray = weights.toArray() val intercept = weights(0)
val weightsScaled = weights.tail
val intercept = weightsArray(0)
val weightsScaled = weightsArray.tail
val model = new LogisticRegressionModel(weightsScaled, intercept, stochasticLosses) val model = new LogisticRegressionModel(weightsScaled, intercept, stochasticLosses)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment