levithomason / anny

Anny is an artificial neural network, yo!
http://levithomason.github.io/anny/
17 stars 3 forks source link

Normalize min max #22

Closed levithomason closed 9 years ago

levithomason commented 9 years ago

Extends Util.normalize() to allow specifying a min/max value other than the min/max in the current array.

Useful if normalizing many arrays and the current array does not contain the global min or global max:

var data = [
  {input: [0, 1, 2], output: 0},
  {input: [3, 4, 5], output: 0},
  {input: [6, 7, 8], output: 0}
];

var normalized = data.map(function(sample) {
  // not every array has min 0 and max 8, but we can specify the min/max
  // this ensures each sample is scaled to the correct global min/max
  sample.input = anny.util.normalize(sample.input, 0, 8)
  return sample;
});