Data Normalizing
Formula
newVal = (oldVal-min) / (max-min)
Ugly Scala Example
package com.hascode
import scala.collection.mutable.LinkedList
object NormalizerExample extends App {
val dataSet = LinkedList(1., 6.5, 3., 6.2, 20., 31.2, 50.2, 12., 0.24, 1.224, 2.2, 3.)
for ((num, index) <- dataSet.zipWithIndex) {
dataSet(index) = (num - dataSet.min) / (dataSet.max - dataSet.min)
}
println("Normalized: " + dataSet)
}
Normalized: LinkedList(0.01521216973578863, 0.12921819759798853, 0.05947594797769014, 0.12324029048767723, 0.3982240175619966, 0.6213992163469515, 1.0, 1.0, 0.07531115879828326, 0.40498283261802576, 0.7319742489270387, 1.0)