Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including numnormalize with all npm packages installed. Try it out:

var numnormalize = require("numnormalize")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

numnormalize v1.0.1

functions of the normalization of numerical data for the training of neural networks

Number normalize


$ npm i numnormalize --save

The need for the normalization of data samples is conditioned by the very nature of the variables used in neural network models. Being different in physical sense, they can often differ greatly in absolute values. So, for example, the sample can contain both concentration, measured in tenths or hundredths of percent, and pressure in hundreds of thousands of pascals. Normalization of data allows you to bring all used numerical values ​​of variables to the same area of ​​their change, which makes it possible to bring them together in one neural network model.

In order to normalize the data, you need to know exactly the limits of the changes in the values ​​of the corresponding variables (minimum and maximum theoretically possible values). Then the limits of the normalization interval will correspond to them. When it is impossible to set the limits of variable changes precisely, they are set taking into account the minimum and maximum values ​​in the available data sample.

The most common way to normalize input and output variables is linear normalization.


const brain = require('brain.js');
const net = new brain.NeuralNetwork();
const { linearNormalize, linearDeNormalize, getMaxMin } = require('../index');

const inputData = [
    [ 0,     1,     2,        3,     4],
    [34,    45,    23,       43,   -54],
    [ 3,  0.23,  0.25, -0.92324,   0.1],
    [ 2,  0.23, -0.25,  0.92324,   0.1],
    [ 1, -0.12,  2.32,    54.24, 123.1]

const outputData = [[

const maxminInput = getMaxMin(inputData);
const maxminOutput = getMaxMin(outputData);

const normInput = linearNormalize({ data: inputData, maxmin: maxminInput });
const normOutput = linearNormalize({ data: outputData, maxmin: maxminOutput });

const trainData =, i) => ({
    input: row,
    output: normOutput[0]


const data = linearNormalize({ data: [ [36, 23, 10, 53, 4] ], maxmin: maxminInput });

console.log('Search for solutions for');

let answer =[0]);

console.log('ANSWER norm:');

answer = linearDeNormalize({ data: [answer], maxmin: maxminOutput });

console.log('ANSWER de norm:');

One way of non-linear normalization is using a sigmoid logistic function or a hyperbolic tangent.


const { nonLinearNormalize, nonLinearDeNormalize, getMaxMin } = require('numnormolize');


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free