Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
small change
  • Loading branch information
DB Tsai committed Nov 25, 2014
commit cdb5cefc89548e6d040b06765cce7b684c7854a9
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we move var i = 0 inside each closure? It feels safer.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size -> nnz

var i = 0
while (i < indices.length) {
while (i < size) {
values(i) *= localFactor(indices(i))
i += 1
}
Expand Down