build/modelscript.umd.js
function MinMaxScalerTransforms(vector = [], nan_value = -1, return_nan=false) {
              const average = avg$2(vector);
              const standard_dev = sd(vector);
              const maximum = max$1(vector);
              const minimum = min$1(vector);
              const scale = (z) => {
                const scaledValue = (z - average) / (maximum - minimum);
                if (isNaN(scaledValue) && return_nan) return scaledValue;
                else if (isNaN(scaledValue) && return_nan === false) return (isNaN(standard_dev)) ? z : standard_dev;
                else return scaledValue;
              }; // equivalent to MinMaxScaler(z)
              const descale = (scaledZ) => {
                const descaledValue = (scaledZ * (maximum - minimum)) + average;
                if (isNaN(descaledValue) && return_nan) return descaledValue;
                else if (isNaN(descaledValue) && return_nan === false) return (isNaN(standard_dev)) ? scaledZ : standard_dev;
                else return descaledValue;
              };
              const values = vector.map(scale)
                .map(val => {
                  if (isNaN(val)) return nan_value;
                  else return val;
                });
              return {
                components: {
                  average,
                  standard_dev,
                  maximum,
                  minimum,
                },
                scale,
                descale,
                values,
              };
            }
function MinMaxScalerTransforms(vector = [], nan_value = -1, return_nan=false) {
              const average = avg$2(vector);
              const standard_dev = sd(vector);
              const maximum = max$1(vector);
              const minimum = min$1(vector);
              const scale = (z) => {
                const scaledValue = (z - average) / (maximum - minimum);
                if (isNaN(scaledValue) && return_nan) return scaledValue;
                else if (isNaN(scaledValue) && return_nan === false) return (isNaN(standard_dev)) ? z : standard_dev;
                else return scaledValue;
              }; // equivalent to MinMaxScaler(z)
              const descale = (scaledZ) => {
                const descaledValue = (scaledZ * (maximum - minimum)) + average;
                if (isNaN(descaledValue) && return_nan) return descaledValue;
                else if (isNaN(descaledValue) && return_nan === false) return (isNaN(standard_dev)) ? scaledZ : standard_dev;
                else return descaledValue;
              };
              const values = vector.map(scale)
                .map(val => {
                  if (isNaN(val)) return nan_value;
                  else return val;
                });
              return {
                components: {
                  average,
                  standard_dev,
                  maximum,
                  minimum,
                },
                scale,
                descale,
                values,
              };
            }
function MinMaxScalerTransforms ( vector = [ ] , nan_value = - 1 , return_nan = false ) { const average = avg$2 ( vector ) ; const standard_dev = sd ( vector ) ; const maximum = max$1 ( vector ) ; const minimum = min$1 ( vector ) ; const scale = ( z ) => { const scaledValue = ( z - average ) / ( maximum - minimum ) ; if ( isNaN ( scaledValue ) && return_nan ) return scaledValue ; else if ( isNaN ( scaledValue ) && return_nan === false ) return ( isNaN ( standard_dev ) ) ? z : standard_dev ; else return scaledValue ; } ; // equivalent to MinMaxScaler(z)
 const descale = ( scaledZ ) => { const descaledValue = ( scaledZ * ( maximum - minimum ) ) + average ; if ( isNaN ( descaledValue ) && return_nan ) return descaledValue ; else if ( isNaN ( descaledValue ) && return_nan === false ) return ( isNaN ( standard_dev ) ) ? scaledZ : standard_dev ; else return descaledValue ; } ; const values = vector . map ( scale ) . map ( val => { if ( isNaN ( val ) ) return nan_value ; else return val ; } ) ; return { components : { average , standard_dev , maximum , minimum , } , scale , descale , values , } ; }
This function returns two functions that can mix max scale new inputs and reverse scale new outputs
@param {Number[]} values - array of numbers
@returns {Object} - {scale[ Function ], descale[ Function ]}
This function returns two functions that can mix max scale new inputs and reverse scale new outputs