How to use the ml.ArrayStat function in ml

To help you get started, we’ve selected a few ml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github repetere / modelscript / build / modelscript.esm.js View on Github external
checkType: true,
  }, options, {
    delimiter: '\t',
  });
  return loadCSV(filepath, tsvOptions);
}

var csvUtils = /*#__PURE__*/Object.freeze({
  loadCSVURI: loadCSVURI,
  loadCSV: loadCSV,
  loadTSV: loadTSV
});

const avg = MachineLearning.ArrayStat.mean;
const mean = avg;
const sum = MachineLearning.ArrayStat.sum;
const scale = (a, d) => a.map(x => (x - avg(a)) / d);
const max = a => a.concat([]).sort((x, y) => x < y)[0];
const min = a => a.concat([]).sort((x, y) => x > y)[0];
const sd = MachineLearning.ArrayStat.standardDeviation; //(a, av) => Math.sqrt(avg(a.map(x => (x - av) * x)));


/**
 * Returns an array of the squared different of two arrays
 * @memberOf util
 * @param {Number[]} left 
 * @param {Number[]} right 
 * @returns {Number[]} Squared difference of left minus right array
 */
function squaredDifference(left, right) {
  return left.reduce((result, val, index, arr) => { 
    result.push(Math.pow((right[index]-val), 2));
github repetere / modelscript / build / modelscript.esm.js View on Github external
async function loadTSV(filepath, options) {
  const tsvOptions = Object.assign({
    checkType: true,
  }, options, {
    delimiter: '\t',
  });
  return loadCSV(filepath, tsvOptions);
}

var csvUtils = /*#__PURE__*/Object.freeze({
  loadCSVURI: loadCSVURI,
  loadCSV: loadCSV,
  loadTSV: loadTSV
});

const avg = MachineLearning.ArrayStat.mean;
const mean = avg;
const sum = MachineLearning.ArrayStat.sum;
const scale = (a, d) => a.map(x => (x - avg(a)) / d);
const max = a => a.concat([]).sort((x, y) => x < y)[0];
const min = a => a.concat([]).sort((x, y) => x > y)[0];
const sd = MachineLearning.ArrayStat.standardDeviation; //(a, av) => Math.sqrt(avg(a.map(x => (x - av) * x)));


/**
 * Returns an array of the squared different of two arrays
 * @memberOf util
 * @param {Number[]} left 
 * @param {Number[]} right 
 * @returns {Number[]} Squared difference of left minus right array
 */
function squaredDifference(left, right) {