code: function featureBagging(trainingSet, n, replacement, seed) {
                if (trainingSet.columns < n) {
                  throw new RangeError('N should be less or equal to the number of columns of X');
                }
  
                var distribution = random.integer(0, trainingSet.columns - 1);
                var engine = random.engines.mt19937();
                if (seed === undefined) {
                  engine = engine.autoSeed();
                } else if (Number.isInteger(seed)) {
                  engine = engine.seed(seed);
                } else {
                  throw new RangeError(`Expected seed must be undefined or integer not ${seed}`);
                }
  
                var toRet = new Matrix$1(trainingSet.rows, n);
  
                if (replacement) {
                  var usedIndex = new Array(n);
                  for (var i = 0; i < n; ++i) {
                    var index = distribution(engine);
                    usedIndex[i] = index;
                    toRet.setColumn(i, trainingSet.getColumn(index));
                  }
                } else {
                  usedIndex = new Set();
                  index = distribution(engine);
                  for (i = 0; i < n; ++i) {
                    while (usedIndex.has(index)) {
                      index = distribution(engine);
                    }
                    toRet.setColumn(i, trainingSet.getColumn(index));
                    usedIndex.add(index);
                  }
                  usedIndex = Array.from(usedIndex);
                }
  
                return {
                  X: toRet,
                  usedIndex: usedIndex
                };
              }
docs: selects n features from the training set with or without replacement, returns the new training set and the indexes used.
  @ignore
  @param {Matrix} trainingSet
  @param {number} n - features.
  @param {boolean} replacement
  @param {number} seed - seed for the random selection, must be a 32-bit integer.
  @return {object}