build/modelscript.cjs.js
function StandardScalerTransforms(vector = [], nan_value = -1, return_nan=false) {
  const average = avg(vector);
  const standard_dev = sd(vector);
  const maximum = max(vector);
  const minimum = min(vector);
  const scale = (z) => {
    const scaledValue = (z - average) / standard_dev;
    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 * standard_dev) + 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 StandardScalerTransforms(vector = [], nan_value = -1, return_nan=false) {
  const average = avg(vector);
  const standard_dev = sd(vector);
  const maximum = max(vector);
  const minimum = min(vector);
  const scale = (z) => {
    const scaledValue = (z - average) / standard_dev;
    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 * standard_dev) + 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 StandardScalerTransforms ( vector = [ ] , nan_value = - 1 , return_nan = false ) { const average = avg ( vector ) ; const standard_dev = sd ( vector ) ; const maximum = max ( vector ) ; const minimum = min ( vector ) ; const scale = ( z ) => { const scaledValue = ( z - average ) / standard_dev ; 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 * standard_dev ) + 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 standard 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 standard scale new inputs and reverse scale new outputs