Skip to content

Commit

Permalink
small change
Browse files Browse the repository at this point in the history
  • Loading branch information
DB Tsai committed Nov 25, 2014
1 parent 9c51eef commit cdb5cef
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,16 @@ class StandardScalerModel private[mllib] (
vector match {
case dv: DenseVector =>
val values = dv.values.clone()
val size = values.size
var i = 0
if (withStd) {
val localFactor = factor
while (i < values.length) {
while (i < size) {
values(i) = (values(i) - localShift(i)) * localFactor(i)
i += 1
}
} else {
while (i < values.length) {
while (i < size) {
values(i) -= localShift(i)
i += 1
}
Expand All @@ -122,8 +123,9 @@ class StandardScalerModel private[mllib] (
vector match {
case dv: DenseVector =>
val values = dv.values.clone()
val size = values.size
var i = 0
while(i < values.length) {
while(i < size) {
values(i) *= localFactor(i)
i += 1
}
Expand All @@ -133,8 +135,9 @@ class StandardScalerModel private[mllib] (
// so we can re-use it to save memory.
val indices = sv.indices
val values = sv.values.clone()
val size = values.size
var i = 0
while (i < indices.length) {
while (i < size) {
values(i) *= localFactor(indices(i))
i += 1
}
Expand Down

0 comments on commit cdb5cef

Please sign in to comment.